From 42c7f89543bbc7cd03af30127e4f79cfbc9eeceb Mon Sep 17 00:00:00 2001 From: watchakorn-18k Date: Sat, 24 Oct 2026 22:09:09 +0700 Subject: [PATCH] M10: keep Hangul first in a Korean UI when Thai is also needed samples() reversed the whole script list for a Korean UI, which put the Bengali and Thai entries ahead of Hangul. Swap Hangul and Kana instead, so the order is Hangul, Han, Kana, then Bengali and Thai. A test covers the mixed case. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01Cs5R9irCMt9rwfhpkwxvSn --- crates/ui-egui/src/cjk.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/cjk.rs b/crates/ui-egui/src/cjk.rs index 42af1a96..8a946a4b 100644 --- a/crates/ui-egui/src/cjk.rs +++ b/crates/ui-egui/src/cjk.rs @@ -124,7 +124,7 @@ fn samples(need: u8, ui: u8) -> Vec<(char, Vec<&'static str>)> { (THAI, ('ก', THAI_FONTS.to_vec())), ]; match ui { - HANGUL => v.reverse(), + HANGUL => v.swap(0, 2), HAN => v.swap(0, 1), BENGALI | THAI => { if let Some(pos) = v.iter().position(|(bit, _)| *bit == ui) { @@ -157,6 +157,7 @@ pub fn faces(need: u8, lang: &str, have: &dyn Fn(char) -> bool) -> Vec mod tests { use super::*; + /// Each script is found in text and tied to its UI language code. #[test] fn scripts_and_languages() { assert_eq!(scripts("Frame 1"), 0); @@ -185,6 +186,7 @@ mod tests { assert!(shows("en", true) && shows("tr", true)); } + /// The UI language's script leads the fallback order; the others follow. #[test] fn the_ui_language_script_comes_first() { let order = |need, ui| samples(need, ui).into_iter().map(|(c, _)| c).collect::(); @@ -196,6 +198,8 @@ mod tests { assert_eq!(order(HANGUL, 0), "한"); assert_eq!(order(THAI, 0), "ก"); assert_eq!(order(THAI | KANA, language("th")), "กあ"); + // A Korean UI draws Hangul in a Korean face before the Thai or Bengali ones. + assert_eq!(order(KANA | HAN | HANGUL | BENGALI | THAI, HANGUL), "한漢あঅก"); // Han without kana outside a Japanese or Korean UI reads as Chinese. assert_eq!(order(HAN, 0), "们"); assert_eq!(first_face(HAN, 0), Some("Noto Sans CJK SC"));