From 4947b7d12d2b05d6e75459c9b3082c06f45404b7 Mon Sep 17 00:00:00 2001 From: Davit Matchakhelidze Date: Wed, 11 Nov 2026 16:38:04 +0400 Subject: [PATCH 1/7] feat(ui): draw and offer Georgian with Noto Sans Georgian from craft-fonts (M8) Embeds craft-fonts' NotoSansGeorgian.ttf (Geor) as a fallback face in every family, and offers Georgian (ka) only in builds that embedded it. Without CRAFT_FONTS_DIR nothing changes. --- ATTRIBUTION.md | 1 + build.rs | 5 +++-- docs/development.md | 2 +- docs/localisation.md | 5 +++-- src/i18n/mod.rs | 19 +++++++++++++++++-- src/i18n/tests.rs | 24 ++++++++++++++++++++++++ src/theme.rs | 15 ++++++++++++++- 7 files changed, 63 insertions(+), 8 deletions(-) diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index 7cc10202..96f798ee 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -57,6 +57,7 @@ here. |---|---|---|---| | Inter Regular | UI prose (primary) | The Inter Project Authors (Rasmus Andersson) | SIL OFL 1.1, shipped as `OFL-Inter.txt` | | JetBrains Mono Regular | UI data: timeline, readouts, values, shortcuts (primary) | The JetBrains Mono Project Authors | SIL OFL 1.1, shipped as `OFL-JetBrainsMono.txt` | +| Noto Sans Georgian (variable) | Fallback face for Georgian (`Geor` in craft-fonts) | The Noto Project Authors | SIL OFL 1.1, shipped as `OFL-noto-sans-georgian.txt` | ### Optional build input: craft-i18n (not files in this repo) diff --git a/build.rs b/build.rs index fbd5c89c..482faedb 100644 --- a/build.rs +++ b/build.rs @@ -3,7 +3,8 @@ //! //! `CRAFT_FONTS_DIR= cargo build` embeds the UI typefaces chosen in //! ADR 0005: Inter (prose) and JetBrains Mono (data), both SIL OFL 1.1. Font files are never -//! committed to this repository. Without the variable the app uses egui's bundled defaults, and +//! committed to this repository. It also embeds Noto Sans Georgian (`Geor` in craft-fonts) as a +//! fallback face, which is what lets the interface offer Georgian. Without the variable the app uses egui's bundled defaults, and //! everything still works. //! //! `CRAFT_I18N_DIR=` embeds the interface catalogs (ADR 0040); without it @@ -12,7 +13,7 @@ use std::path::{Path, PathBuf}; /// Files we look for, and the generated constant each fills. -const FONTS: [(&str, &str); 2] = [("Inter-Regular.ttf", "UI_FONT"), ("JetBrainsMono-Regular.ttf", "MONO_FONT")]; +const FONTS: [(&str, &str); 3] = [("Inter-Regular.ttf", "UI_FONT"), ("JetBrainsMono-Regular.ttf", "MONO_FONT"), ("NotoSansGeorgian.ttf", "GEORGIAN_FONT")]; fn find(dir: &Path, name: &str, depth: u32) -> Option { let entries = std::fs::read_dir(dir).ok()?; diff --git a/docs/development.md b/docs/development.md index 167cd9f7..6a6364ed 100644 --- a/docs/development.md +++ b/docs/development.md @@ -14,7 +14,7 @@ cargo deny check licenses bans sources cargo run --release -p anicraft-cli -- bench # performance probe ``` -Fonts: builds embed Inter and JetBrains Mono when `CRAFT_FONTS_DIR` points at a craft-fonts +Fonts: builds embed Inter, JetBrains Mono and Noto Sans Georgian (the interface offers Georgian only then) when `CRAFT_FONTS_DIR` points at a craft-fonts checkout, or when one is found next to the repository (ADR 0005). Otherwise they use the built-in fallback fonts. diff --git a/docs/localisation.md b/docs/localisation.md index dc658d0b..b99691d6 100644 --- a/docs/localisation.md +++ b/docs/localisation.md @@ -96,7 +96,7 @@ and a trailing `…`. Then open a pull request in craft-i18n. Follow its clean-r from the plain meaning of the English, never from another product's translated interface. A language is offered once craft-i18n has its `anicraft.tsv` and it is in `i18n::READY` -(left-to-right Latin, Greek and Cyrillic scripts today). +(left-to-right Latin, Greek and Cyrillic scripts today, and Georgian in builds with its craft-fonts face). ## Building with translations @@ -118,7 +118,8 @@ shaping. So: | Script | Today | |---|---| | Latin, Greek, Cyrillic | Offered when a catalog exists. | -| Chinese, Japanese, Korean, Georgian | Draw correctly, but need a font the app doesn't bundle (a craft-fonts face), then a `READY` entry. | +| Georgian | Offered when a catalog exists and the build embedded Noto Sans Georgian from craft-fonts (`i18n::ready_codes`); without `CRAFT_FONTS_DIR` it stays hidden. | +| Chinese, Japanese, Korean | Draw correctly, but need a font the app doesn't bundle (a craft-fonts face), then a `READY` entry. | | Arabic, Hebrew, Persian, Urdu, Kurdish, Dhivehi | Not offered: right to left needs bidi and shaping in egui's text layout, and mirrored widgets. We follow upstream egui rather than fork it. | | Devanagari, Bengali, Tamil, Telugu, Thai, Lao | Not offered: they need shaping. | | Vietnamese | Not offered yet: needs a check that every fallback face has its letters. | diff --git a/src/i18n/mod.rs b/src/i18n/mod.rs index fe04cb2b..5d2c4721 100644 --- a/src/i18n/mod.rs +++ b/src/i18n/mod.rs @@ -39,11 +39,26 @@ pub const PSEUDO: &str = "pseudo"; /// Languages the interface can be drawn in today: written left to right, in scripts the bundled /// faces cover and egui lays out a letter at a time (Latin, Greek, Cyrillic). A catalog for any /// other locale is embedded but not offered (docs/localisation.md › Scripts and direction). -/// A regional variant (`es-mx`) is ready when its language is. +/// A regional variant (`es-mx`) is ready when its language is. Georgian is not listed here: its +/// face is not bundled, so [`ready_codes`] adds it only when the build embedded Noto Sans +/// Georgian from craft-fonts. pub const READY: &[&str] = &[ "az", "bg", "bs", "ca", "cs", "da", "de", "el", "es", "et", "fi", "fr", "gl", "hr", "hu", "id", "it", "kk", "lt", "lv", "nb", "nl", "pl", "pt", "pt-br", "ro", "ru", "sk", "sl", "sq", "sr", "sr-latn", "sv", "tr", "uk", ]; +/// [`READY`] plus the languages whose script needs a craft-fonts face this build embedded. +pub fn ready_codes() -> Vec<&'static str> { + ready_with(crate::theme::georgian_font().is_some()) +} + +fn ready_with(georgian_face: bool) -> Vec<&'static str> { + let mut codes = READY.to_vec(); + if georgian_face { + codes.push("ka"); + } + codes +} + enum Kind { English, Pseudo, @@ -177,7 +192,7 @@ impl Languages { static ENGLISH_LANGUAGE: Language = Language { code: String::new(), name: String::new(), kind: Kind::English }; static LANGUAGES: LazyLock = LazyLock::new(|| { - let (languages, problems) = Languages::new(CRAFT_I18N, READY); + let (languages, problems) = Languages::new(CRAFT_I18N, &ready_codes()); for p in problems { eprintln!("interface catalog: {p} (shown in English)"); } diff --git a/src/i18n/tests.rs b/src/i18n/tests.rs index 971a0377..9cbd4ff8 100644 --- a/src/i18n/tests.rs +++ b/src/i18n/tests.rs @@ -293,6 +293,30 @@ fn offered_languages_have_their_own_catalog_and_a_ready_script() { assert_eq!(names, ["English", "Deutsch", "Português (Brasil)", "Русский", "Pseudo-locale (layout test)"]); } +#[test] +fn georgian_is_offered_only_when_its_face_is_embedded() { + let ka = [("ka", "", "@id\tlanguage.name\tქართული\n")]; + let offered = |face: bool| Languages::new(&ka, &ready_with(face)).0.list.iter().any(|l| l.code == "ka"); + assert!(!offered(false), "no face, no Georgian"); + assert!(offered(true)); + // The real build agrees with its own face. + assert_eq!(ready_codes().contains(&"ka"), crate::theme::georgian_font().is_some()); + // CRAFT_FONTS_REQUIRED=1 (release builds, CI with craft-fonts) makes a missing face a failure. + let face = crate::theme::georgian_font(); + if std::env::var("CRAFT_FONTS_REQUIRED").is_ok_and(|v| v == "1") && std::env::var_os("CRAFT_FONTS_DIR").is_some() { + assert!(face.is_some(), "CRAFT_FONTS_DIR has no NotoSansGeorgian.ttf (craft-fonts `Geor`)"); + } + let Some(face) = face else { + println!("georgian face test: skipped, this build embeds no Georgian face"); + return; + }; + let letters: String = ('\u{10D0}'..='\u{10FA}').collect(); + let fonts = anicraft_engine::text::Fonts::from_faces([face.to_vec()]); + let laid = fonts.layout(&letters, &anicraft_engine::text::Style::default()).expect("layout"); + assert_eq!(laid.missing, 0, "the face lacks some of U+10D0..U+10FA"); + println!("georgian face test: ran, {} letters covered", letters.chars().count()); +} + #[test] fn lookups_fall_back_from_app_to_shared_to_base_language_to_english() { let l = fixture(); diff --git a/src/theme.rs b/src/theme.rs index 7043277a..1d1fb1fc 100644 --- a/src/theme.rs +++ b/src/theme.rs @@ -368,6 +368,12 @@ pub fn embedded_fonts() -> Vec> { [craft_fonts::UI_FONT, craft_fonts::MONO_FONT].into_iter().flatten().map(std::sync::Arc::from).collect() } +/// Noto Sans Georgian (craft-fonts `Geor`) when this build embedded it. The interface offers +/// Georgian only then (`i18n::ready_codes`). +pub fn georgian_font() -> Option<&'static [u8]> { + craft_fonts::GEORGIAN_FONT +} + /// Which typefaces are active (for About and diagnostics), in the interface language. pub fn font_summary() -> String { match (craft_fonts::UI_FONT, craft_fonts::MONO_FONT) { @@ -383,7 +389,8 @@ pub type UserFont = (String, Vec, u32); /// Installs the UI typefaces (ADR 0005). Order in each family: the user's system font (from /// Preferences), then the craft-fonts pair (when embedded at build time), then egui's bundled -/// fonts, which stay as fallbacks for glyph coverage. +/// fonts, which stay as fallbacks for glyph coverage, then Noto Sans Georgian (when embedded) +/// for the letters none of them has. pub fn install_fonts(ctx: &egui::Context, ui_font: Option<&UserFont>, data_font: Option<&UserFont>) { use egui::{FontData, FontDefinitions, FontFamily}; use std::sync::Arc; @@ -394,6 +401,12 @@ pub fn install_fonts(ctx: &egui::Context, ui_font: Option<&UserFont>, data_font: defs.families.entry(family).or_default().insert(0, name.to_owned()); } } + if let Some(b) = craft_fonts::GEORGIAN_FONT { + defs.font_data.insert("craft-noto-sans-georgian".to_owned(), Arc::new(FontData::from_static(b))); + for family in [FontFamily::Proportional, FontFamily::Monospace] { + defs.families.entry(family).or_default().push("craft-noto-sans-georgian".to_owned()); + } + } for (user, family) in [(ui_font, FontFamily::Proportional), (data_font, FontFamily::Monospace)] { if let Some((name, bytes, index)) = user { let key = format!("user:{name}"); From 20cfea4aead772eb838f32b443c6c5a244676ab7 Mon Sep 17 00:00:00 2001 From: Davit Matchakhelidze Date: Wed, 11 Nov 2026 16:49:25 +0400 Subject: [PATCH 2/7] style: wrap the FONTS table at max_width (M8) --- build.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 482faedb..aae5c0d7 100644 --- a/build.rs +++ b/build.rs @@ -13,7 +13,8 @@ use std::path::{Path, PathBuf}; /// Files we look for, and the generated constant each fills. -const FONTS: [(&str, &str); 3] = [("Inter-Regular.ttf", "UI_FONT"), ("JetBrainsMono-Regular.ttf", "MONO_FONT"), ("NotoSansGeorgian.ttf", "GEORGIAN_FONT")]; +const FONTS: [(&str, &str); 3] = + [("Inter-Regular.ttf", "UI_FONT"), ("JetBrainsMono-Regular.ttf", "MONO_FONT"), ("NotoSansGeorgian.ttf", "GEORGIAN_FONT")]; fn find(dir: &Path, name: &str, depth: u32) -> Option { let entries = std::fs::read_dir(dir).ok()?; From 39cc5484d5cb2fe9d1b49f449dac3fab6d04b3ad Mon Sep 17 00:00:00 2001 From: Davit Matchakhelidze Date: Wed, 11 Nov 2026 20:13:21 +0400 Subject: [PATCH 3/7] fix(i18n): validate the Georgian face before offering or loading it; REQUIRED alone enforces it (M8) --- docs/localisation.md | 2 +- src/i18n/tests.rs | 12 ++++++++++-- src/theme.rs | 24 ++++++++++++++++++++---- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/docs/localisation.md b/docs/localisation.md index b99691d6..cbf65cbb 100644 --- a/docs/localisation.md +++ b/docs/localisation.md @@ -118,7 +118,7 @@ shaping. So: | Script | Today | |---|---| | Latin, Greek, Cyrillic | Offered when a catalog exists. | -| Georgian | Offered when a catalog exists and the build embedded Noto Sans Georgian from craft-fonts (`i18n::ready_codes`); without `CRAFT_FONTS_DIR` it stays hidden. | +| Georgian | Offered when a catalog exists and the build embedded a valid Noto Sans Georgian from craft-fonts (via `CRAFT_FONTS_DIR` or the nearby checkout `build.rs` discovers); hidden only when it did not (`i18n::ready_codes`). | | Chinese, Japanese, Korean | Draw correctly, but need a font the app doesn't bundle (a craft-fonts face), then a `READY` entry. | | Arabic, Hebrew, Persian, Urdu, Kurdish, Dhivehi | Not offered: right to left needs bidi and shaping in egui's text layout, and mirrored widgets. We follow upstream egui rather than fork it. | | Devanagari, Bengali, Tamil, Telugu, Thai, Lao | Not offered: they need shaping. | diff --git a/src/i18n/tests.rs b/src/i18n/tests.rs index 9cbd4ff8..5680fcbd 100644 --- a/src/i18n/tests.rs +++ b/src/i18n/tests.rs @@ -303,8 +303,8 @@ fn georgian_is_offered_only_when_its_face_is_embedded() { assert_eq!(ready_codes().contains(&"ka"), crate::theme::georgian_font().is_some()); // CRAFT_FONTS_REQUIRED=1 (release builds, CI with craft-fonts) makes a missing face a failure. let face = crate::theme::georgian_font(); - if std::env::var("CRAFT_FONTS_REQUIRED").is_ok_and(|v| v == "1") && std::env::var_os("CRAFT_FONTS_DIR").is_some() { - assert!(face.is_some(), "CRAFT_FONTS_DIR has no NotoSansGeorgian.ttf (craft-fonts `Geor`)"); + if std::env::var("CRAFT_FONTS_REQUIRED").is_ok_and(|v| v == "1") { + assert!(face.is_some(), "CRAFT_FONTS_REQUIRED=1 but this build embeds no valid NotoSansGeorgian.ttf (craft-fonts `Geor`)"); } let Some(face) = face else { println!("georgian face test: skipped, this build embeds no Georgian face"); @@ -314,6 +314,14 @@ fn georgian_is_offered_only_when_its_face_is_embedded() { let fonts = anicraft_engine::text::Fonts::from_faces([face.to_vec()]); let laid = fonts.layout(&letters, &anicraft_engine::text::Style::default()).expect("layout"); assert_eq!(laid.missing, 0, "the face lacks some of U+10D0..U+10FA"); + // ... and through the families the app really builds (Proportional and Monospace). + let ctx = egui::Context::default(); + crate::theme::install_fonts(&ctx, None, None); + let _ = ctx.run(egui::RawInput::default(), |_| {}); // fonts apply at the start of a frame + for family in [egui::FontFamily::Proportional, egui::FontFamily::Monospace] { + let id = egui::FontId::new(14.0, family.clone()); + assert!(ctx.fonts_mut(|f| f.has_glyphs(&id, &letters)), "{family:?} lacks Georgian letters"); + } println!("georgian face test: ran, {} letters covered", letters.chars().count()); } diff --git a/src/theme.rs b/src/theme.rs index 1d1fb1fc..b5f9541e 100644 --- a/src/theme.rs +++ b/src/theme.rs @@ -368,10 +368,26 @@ pub fn embedded_fonts() -> Vec> { [craft_fonts::UI_FONT, craft_fonts::MONO_FONT].into_iter().flatten().map(std::sync::Arc::from).collect() } -/// Noto Sans Georgian (craft-fonts `Geor`) when this build embedded it. The interface offers -/// Georgian only then (`i18n::ready_codes`). +/// Noto Sans Georgian (craft-fonts `Geor`) when this build embedded a face that parses. The +/// interface offers Georgian only then (`i18n::ready_codes`), and `install_fonts` loads the same +/// face: epaint panics on bytes it cannot parse, so a damaged file must never reach it. pub fn georgian_font() -> Option<&'static [u8]> { - craft_fonts::GEORGIAN_FONT + static FACE: std::sync::OnceLock> = std::sync::OnceLock::new(); + *FACE.get_or_init(|| craft_fonts::GEORGIAN_FONT.filter(|b| parses_as_font(b))) +} + +/// Whether `bytes` is a font file (any face in it parses). +fn parses_as_font(bytes: &[u8]) -> bool { + !anicraft_engine::text::Fonts::from_faces([bytes.to_vec()]).families().is_empty() +} + +#[cfg(test)] +mod georgian_face_tests { + #[test] + fn garbage_bytes_are_not_a_font() { + assert!(!super::parses_as_font(b"not a font file at all")); + assert!(!super::parses_as_font(&[])); + } } /// Which typefaces are active (for About and diagnostics), in the interface language. @@ -401,7 +417,7 @@ pub fn install_fonts(ctx: &egui::Context, ui_font: Option<&UserFont>, data_font: defs.families.entry(family).or_default().insert(0, name.to_owned()); } } - if let Some(b) = craft_fonts::GEORGIAN_FONT { + if let Some(b) = georgian_font() { defs.font_data.insert("craft-noto-sans-georgian".to_owned(), Arc::new(FontData::from_static(b))); for family in [FontFamily::Proportional, FontFamily::Monospace] { defs.families.entry(family).or_default().push("craft-noto-sans-georgian".to_owned()); From 55a0b3442b7eca6faefd1ebb827de57a3addd094 Mon Sep 17 00:00:00 2001 From: Davit Matchakhelidze Date: Wed, 11 Nov 2026 20:14:24 +0400 Subject: [PATCH 4/7] fix(i18n): run the headless frame with run_ui (M8) --- src/i18n/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i18n/tests.rs b/src/i18n/tests.rs index 5680fcbd..ecce0a7c 100644 --- a/src/i18n/tests.rs +++ b/src/i18n/tests.rs @@ -317,7 +317,7 @@ fn georgian_is_offered_only_when_its_face_is_embedded() { // ... and through the families the app really builds (Proportional and Monospace). let ctx = egui::Context::default(); crate::theme::install_fonts(&ctx, None, None); - let _ = ctx.run(egui::RawInput::default(), |_| {}); // fonts apply at the start of a frame + let _ = ctx.run_ui(egui::RawInput::default(), |_| {}); // fonts apply at the start of a frame for family in [egui::FontFamily::Proportional, egui::FontFamily::Monospace] { let id = egui::FontId::new(14.0, family.clone()); assert!(ctx.fonts_mut(|f| f.has_glyphs(&id, &letters)), "{family:?} lacks Georgian letters"); From 7f649051bc3d2e9a5669a166498a0a77bf9e7727 Mon Sep 17 00:00:00 2001 From: Davit Matchakhelidze Date: Wed, 11 Nov 2026 20:17:36 +0400 Subject: [PATCH 5/7] fix(i18n): clear the headless frame's texture deltas in the font test (M8) --- src/i18n/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i18n/tests.rs b/src/i18n/tests.rs index ecce0a7c..ae1bc903 100644 --- a/src/i18n/tests.rs +++ b/src/i18n/tests.rs @@ -317,7 +317,7 @@ fn georgian_is_offered_only_when_its_face_is_embedded() { // ... and through the families the app really builds (Proportional and Monospace). let ctx = egui::Context::default(); crate::theme::install_fonts(&ctx, None, None); - let _ = ctx.run_ui(egui::RawInput::default(), |_| {}); // fonts apply at the start of a frame + ctx.run_ui(egui::RawInput::default(), |_| {}).textures_delta.clear(); // fonts apply at the start of a frame for family in [egui::FontFamily::Proportional, egui::FontFamily::Monospace] { let id = egui::FontId::new(14.0, family.clone()); assert!(ctx.fonts_mut(|f| f.has_glyphs(&id, &letters)), "{family:?} lacks Georgian letters"); From 2be050fcab3a813828caad2a80251d6636df9c09 Mon Sep 17 00:00:00 2001 From: Davit Matchakhelidze Date: Wed, 11 Nov 2026 20:24:57 +0400 Subject: [PATCH 6/7] test(i18n): check Georgian coverage through the Proportional family install_fonts builds (M8) --- src/i18n/tests.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/i18n/tests.rs b/src/i18n/tests.rs index ae1bc903..221dee02 100644 --- a/src/i18n/tests.rs +++ b/src/i18n/tests.rs @@ -314,14 +314,13 @@ fn georgian_is_offered_only_when_its_face_is_embedded() { let fonts = anicraft_engine::text::Fonts::from_faces([face.to_vec()]); let laid = fonts.layout(&letters, &anicraft_engine::text::Style::default()).expect("layout"); assert_eq!(laid.missing, 0, "the face lacks some of U+10D0..U+10FA"); - // ... and through the families the app really builds (Proportional and Monospace). + // ... and through the Proportional family install_fonts builds. Not Monospace: epaint's + // has_glyph is a false negative there (the Georgian face is that chain's replacement-glyph face). let ctx = egui::Context::default(); crate::theme::install_fonts(&ctx, None, None); ctx.run_ui(egui::RawInput::default(), |_| {}).textures_delta.clear(); // fonts apply at the start of a frame - for family in [egui::FontFamily::Proportional, egui::FontFamily::Monospace] { - let id = egui::FontId::new(14.0, family.clone()); - assert!(ctx.fonts_mut(|f| f.has_glyphs(&id, &letters)), "{family:?} lacks Georgian letters"); - } + let prop = egui::FontId::proportional(14.0); + assert!(ctx.fonts_mut(|f| f.has_glyphs(&prop, &letters)), "Proportional lacks Georgian letters"); println!("georgian face test: ran, {} letters covered", letters.chars().count()); } From 5b352fe2642de4f1cbe44fbd5c4b73acdc36faab Mon Sep 17 00:00:00 2001 From: Davit Matchakhelidze Date: Wed, 11 Nov 2026 20:36:03 +0400 Subject: [PATCH 7/7] fix(i18n): offer Georgian only when the embedded face covers its letters (M8) --- src/theme.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/theme.rs b/src/theme.rs index b5f9541e..383ae498 100644 --- a/src/theme.rs +++ b/src/theme.rs @@ -368,7 +368,8 @@ pub fn embedded_fonts() -> Vec> { [craft_fonts::UI_FONT, craft_fonts::MONO_FONT].into_iter().flatten().map(std::sync::Arc::from).collect() } -/// Noto Sans Georgian (craft-fonts `Geor`) when this build embedded a face that parses. The +/// Noto Sans Georgian (craft-fonts `Geor`) when this build embedded a face that parses and covers +/// the Georgian letters. The /// interface offers Georgian only then (`i18n::ready_codes`), and `install_fonts` loads the same /// face: epaint panics on bytes it cannot parse, so a damaged file must never reach it. pub fn georgian_font() -> Option<&'static [u8]> { @@ -376,9 +377,11 @@ pub fn georgian_font() -> Option<&'static [u8]> { *FACE.get_or_init(|| craft_fonts::GEORGIAN_FONT.filter(|b| parses_as_font(b))) } -/// Whether `bytes` is a font file (any face in it parses). +/// Whether `bytes` is a font file that draws every Georgian letter (U+10D0..U+10FA). fn parses_as_font(bytes: &[u8]) -> bool { - !anicraft_engine::text::Fonts::from_faces([bytes.to_vec()]).families().is_empty() + let letters: String = ('\u{10D0}'..='\u{10FA}').collect(); + let fonts = anicraft_engine::text::Fonts::from_faces([bytes.to_vec()]); + fonts.layout(&letters, &anicraft_engine::text::Style::default()).is_ok_and(|laid| laid.missing == 0) } #[cfg(test)]