text, ui: the CJK fallback fonts follow the interface language

- `effectcraft_text::fonts::set_cjk_locale` lets the host say whose face should draw Han
  ideographs instead of leaving it to the locale environment, and drops the fallback cache when
  it changes. `han_order` reads that request first; the tag → order rule moves into the pure
  `han_order_for`, so it can be tested without touching process state.
- `theme::install` now takes the stored `general.language` value and registers one CJK system
  fallback per script in every font family, the interface's own script first: kana for Japanese,
  a Han character for `zh-hans` / `zh-hant`, then the other script so names in it still render.
  A face is registered at most once, and a machine with no CJK font installs nothing (the web
  build installs nothing, as before).
- Before this the probe was always `あ`, so Han text was drawn by the Japanese face whenever the
  operating system's locale was not Chinese: a Chinese interface, and Chinese file, layer or
  template names on any locale, both got Japanese glyph forms.
- Tests: the tag → order rule (`zh`, `zh_Hans`, `zh-Hant-TW`, `ko`, `ja`, `en`, empty), and the
  registration order plus once-only registration for a Chinese, a Japanese and an English
  interface.
This commit is contained in:
FeiLiuEM
2026-10-09 19:27:47 +08:00
parent 4aaadd0ed3
commit a4d1e8d0b3
9 changed files with 194 additions and 32 deletions
+1 -1
View File
@@ -548,7 +548,7 @@ mod tests {
fn app() -> (EffectcraftApp, egui::Context) {
let ctx = egui::Context::default();
let mut app = EffectcraftApp::new(effectcraft_engine::Session::default());
crate::theme::install(&ctx, &app.tokens);
crate::theme::install(&ctx, &app.tokens, &app.session.prefs.general.language);
app.session.execute("comp.new", json!({"name": "Main", "width": 640, "height": 360})).unwrap();
(app, ctx)
}
+1 -1
View File
@@ -844,7 +844,7 @@ mod tests {
fn premiere_export_dialog() {
let mut app = EffectcraftApp::new(effectcraft_engine::Session::default());
let ctx = egui::Context::default();
crate::theme::install(&ctx, &app.tokens);
crate::theme::install(&ctx, &app.tokens, &app.session.prefs.general.language);
app.session.execute("comp.new", json!({"name": "Spot", "width": 64, "height": 36, "frameRate": 25, "duration": 1})).unwrap();
app.session.execute("layer.newSolid", json!({"color": "#ff0000"})).unwrap();
crate::menus::invoke(&mut app, &ctx, "file.exportTimeline", json!({})).unwrap();
+2 -2
View File
@@ -540,7 +540,7 @@ mod tests {
s.prefs.push_recent("/projects/Alpha.ecproj");
let mut app = EffectcraftApp::new(s);
let ctx = egui::Context::default();
crate::theme::install(&ctx, &app.tokens);
crate::theme::install(&ctx, &app.tokens, &app.session.prefs.general.language);
ctx.run_ui(Default::default(), |_| {}).textures_delta.clear();
ctx.run_ui(Default::default(), |ui| {
app.auto.begin_frame();
@@ -573,7 +573,7 @@ mod tests {
app.ui.start_screen = true;
app.ui.home_learn = true;
let ctx = egui::Context::default();
crate::theme::install(&ctx, &app.tokens);
crate::theme::install(&ctx, &app.tokens, &app.session.prefs.general.language);
let frame = |app: &mut EffectcraftApp| {
ctx.run_ui(Default::default(), |ui| {
app.auto.begin_frame();
+2 -2
View File
@@ -194,7 +194,7 @@ mod tests {
fn gallery_lists_renders_and_opens_templates() {
let mut app = app_with_store();
let ctx = egui::Context::default();
crate::theme::install(&ctx, &app.tokens);
crate::theme::install(&ctx, &app.tokens, &app.session.prefs.general.language);
// File ▸ New ▸ New Project from Template… opens the Templates tab.
let ev = app.session.execute("file.newFromTemplate", json!({})).unwrap();
assert_eq!(ev["frontend"], "file.newFromTemplate");
@@ -250,7 +250,7 @@ mod tests {
fn my_custom_rgb_dialog() {
let mut app = app_with_store();
let ctx = egui::Context::default();
crate::theme::install(&ctx, &app.tokens);
crate::theme::install(&ctx, &app.tokens, &app.session.prefs.general.language);
// Menu check marks follow the active comp's viewer.
app.session.execute("comp.new", json!({"name": "C", "width": 64, "height": 48})).unwrap();
let item = crate::menus::menu_items(&app).into_iter().find(|m| m.id == "view.customRgb").expect("menu item");
+1 -1
View File
@@ -170,7 +170,7 @@ mod tests {
fn app() -> (EffectcraftApp, egui::Context) {
let ctx = egui::Context::default();
let app = EffectcraftApp::new(effectcraft_engine::Session::default());
crate::theme::install(&ctx, &app.tokens);
crate::theme::install(&ctx, &app.tokens, &app.session.prefs.general.language);
(app, ctx)
}