FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
CJK fonts: Chinese faces after the Japanese ones, so Japanese keeps Japanese glyph forms
Brandon Thomas12f2ea17d6c2
diff --git a/crates/ui-egui/src/cjk.rs b/crates/ui-egui/src/cjk.rsindex a92ccc36e..b7c8811ce 100644--- a/crates/ui-egui/src/cjk.rs+++ b/crates/ui-egui/src/cjk.rs@@ -42,8 +42,9 @@ fn system_font() -> Option<Arc<FontData>> {.clone()}-/// Append Chinese faces after Latin UI fonts and before the Japanese fallbacks. This keeps the-/// interface's Latin typography and uses Chinese glyph forms for media and track names.+/// Append Chinese faces after the Latin UI fonts and the Japanese fallbacks. This keeps the+/// interface's Latin typography and Japanese glyph forms, and covers the simplified and+/// traditional hanzi in media and track names that Japanese fonts lack.pub(crate) fn install(fonts: &mut FontDefinitions) {let chinese: Vec<_> = craft_fonts().collect();if chinese.is_empty() {diff --git a/crates/ui-egui/src/theme.rs b/crates/ui-egui/src/theme.rsindex fdce69c89..3a81ae123 100644--- a/crates/ui-egui/src/theme.rs+++ b/crates/ui-egui/src/theme.rs@@ -269,8 +269,10 @@ pub fn install(ctx: &egui::Context, t: &Tokens) {fonts.families.entry(FontFamily::Monospace).or_default().insert(0, "jbmono".into());fonts.families.insert(FontFamily::Name("semibold".into()), vec!["inter-semibold".into(), "inter".into()]);fonts.families.insert(FontFamily::Name("medium".into()), vec!["inter-medium".into(), "inter".into()]);- crate::cjk::install(&mut fonts);+ // Japanese before Chinese: the two share code points, and Japanese text must keep Japanese+ // glyph forms; Chinese faces still cover the hanzi Japanese fonts lackadd_craft_fonts(&mut fonts);+ crate::cjk::install(&mut fonts);ctx.set_fonts(fonts);apply_visuals(ctx, t);}@@ -376,7 +378,7 @@ mod tests {let ctx = egui::Context::default();for kind in [ThemeKind::Dark, ThemeKind::Medium, ThemeKind::Light] {install(&ctx, &Tokens::for_kind(kind));- let _ = ctx.run_ui(egui::RawInput::default(), |_| {});+ ctx.run_ui(egui::RawInput::default(), |_| {}).textures_delta.clear();ctx.fonts_mut(|fonts| {for family in font_families() {let font = FontId::new(13.0, family);@@ -391,6 +393,8 @@ mod tests {}});}+ // the layouts above put glyphs in the atlas: take that update so it isn't dropped unapplied+ ctx.run_ui(egui::RawInput::default(), |_| {}).textures_delta.clear();}/// Built with craft-fonts: every font family ends with the Japanese faces (BIZ UDPGothicdiff --git a/docs/contributing.md b/docs/contributing.mdindex 93c84c440..570259e19 100644--- a/docs/contributing.md+++ b/docs/contributing.md@@ -90,8 +90,9 @@ FilmCraft uses its bundled and system fonts. A `CRAFT_FONTS_DIR` that is not a cwarning, or an error with `CRAFT_FONTS_REQUIRED=1` (release builds set both). Tests on these fonts'glyphs skip when it is empty; when you touch fonts, run the gates both with and without it.-Chinese media names and track labels use the `Hans` / `Hant` craft-fonts faces before the Japanese-fallbacks in every UI font family, regardless of interface language. Without those build inputs,+Chinese media names and track labels use the `Hans` / `Hant` craft-fonts faces after the Japanese+fallbacks in every UI font family, regardless of interface language (Japanese and Chinese share code+points, so Japanese text keeps Japanese glyph forms; the Chinese faces cover hanzi the Japanese ones lack). Without those build inputs,native builds look up an installed Chinese face (for example Microsoft YaHei or Noto Sans CJK SC)once and reuse it across theme changes. No system font files are bundled or copied into the app.Web builds depend on the font faces selected by `crates/text/build.rs`; they cannot scan system fonts.