From be04efc4fbb8d90934683026d22e8de6116b157a Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Tue, 3 Nov 2026 09:41:15 -0500 Subject: [PATCH] M10: embeddable script faces as document fallbacks; the Arabic UI with Arab embedded (#1902) Review: Noto Sans Hebrew, Devanagari and Georgian join Arabic and Thai in FALLBACK_FAMILIES, so a web build that embeds one draws that script in an Inter document; with Arab embedded the picker offers the Arabic UI catalog, as cjk::can_show intends (the docs said otherwise); the docs example lists one tag per script. Test: every_embeddable_script_face_is_a_document_fallback. Co-Authored-By: Claude Fable 5.1 --- crates/text/build.rs | 4 ++-- crates/text/src/fontdb.rs | 14 ++++++++++---- crates/text/src/fontdb_tests.rs | 25 +++++++++++++++++++++++++ docs/localization-parity.md | 12 ++++++------ docs/translating.md | 3 ++- 5 files changed, 45 insertions(+), 13 deletions(-) diff --git a/crates/text/build.rs b/crates/text/build.rs index c2a1bf4d2..e23dff936 100644 --- a/crates/text/build.rs +++ b/crates/text/build.rs @@ -4,8 +4,8 @@ //! Regular/SemiBold and Noto Sans Georgian Regular after filtering. Recipe: craft-fonts `docs/integration.md`. //! Noto Sans CJK only with `FIGCRAFT_EMBED_CJK` set (the web build's only way to show CJK UI text). //! The other scripts' faces (Noto Sans Arabic, Hebrew, Thai, Devanagari…) stay out of web builds unless -//! `FIGCRAFT_EMBED_SCRIPTS` names their script tags (`Arab,Hebr`, as the manifest's scripts column -//! lists them; #1902). +//! `FIGCRAFT_EMBED_SCRIPTS` names their script tags (`Arab,Hebr,Thai,Deva`: one tag per script wanted, +//! as the manifest's scripts column lists them; #1902). use std::fmt::Write as _; use std::path::PathBuf; diff --git a/crates/text/src/fontdb.rs b/crates/text/src/fontdb.rs index d0004fcd9..4b4bf4350 100644 --- a/crates/text/src/fontdb.rs +++ b/crates/text/src/fontdb.rs @@ -544,10 +544,13 @@ fn names(f: &skrifa::FontRef) -> (Option, Option) { (family, style) } -/// Families tried, in order, for characters a text's own font lacks. The symbol fonts come last: -/// Apple Symbols (macOS), Segoe UI Symbol (Windows) and the Noto symbol and math fonts (Linux), for -/// signs such as ⌖ and ⤒ that no text face has. -const FALLBACK_FAMILIES: [&str; 29] = [ +/// Families tried, in order, for characters a text's own font lacks. Every script face craft-fonts +/// can embed (Noto Sans Arabic, Thai, Hebrew, Devanagari, Georgian) is here after the Latin faces, +/// so a web build that embeds one (`FIGCRAFT_EMBED_SCRIPTS`, #1902) draws that script in an Inter +/// document: the browser has no other fonts. The symbol fonts come last: Apple Symbols (macOS), +/// Segoe UI Symbol (Windows) and the Noto symbol and math fonts (Linux), for signs such as ⌖ and ⤒ +/// that no text face has. +const FALLBACK_FAMILIES: [&str; 32] = [ "Inter", "Helvetica Neue", "Arial", @@ -571,6 +574,9 @@ const FALLBACK_FAMILIES: [&str; 29] = [ "Leelawadee UI", "Thonburi", "Tahoma", + "Noto Sans Hebrew", + "Noto Sans Devanagari", + "Noto Sans Georgian", "Apple Symbols", "Segoe UI Symbol", "Noto Sans Symbols", diff --git a/crates/text/src/fontdb_tests.rs b/crates/text/src/fontdb_tests.rs index 5f0fa522b..2df34cf73 100644 --- a/crates/text/src/fontdb_tests.rs +++ b/crates/text/src/fontdb_tests.rs @@ -538,6 +538,31 @@ fn every_platform_has_a_thai_font_in_the_fallbacks() { } } +/// #1902: a web build has no system fonts, so a document's missing characters can only come from +/// the embedded faces. Every script face craft-fonts can embed (`FIGCRAFT_EMBED_SCRIPTS`) is a +/// document fallback after the Latin faces; else Hebrew or Devanagari typed into an Inter layer +/// would stay missing glyphs with its face embedded. +#[test] +fn every_embeddable_script_face_is_a_document_fallback() { + let at = |family: &str| FALLBACK_FAMILIES.iter().position(|f| *f == family); + let latin = at("Segoe UI").unwrap(); + for face in [ + "Noto Sans Arabic", + "Noto Sans Thai", + "Noto Sans Hebrew", + "Noto Sans Devanagari", + "Noto Sans Georgian", + "Noto Sans Symbols", + "Noto Sans Symbols 2", + ] { + assert!(at(face).is_some_and(|i| i > latin), "{face} is a fallback after the Latin faces"); + } + // And whatever script face this build embeds (CI builds have craft-fonts; CJK by request). + for f in CRAFT_FONTS.iter().filter(|f| f.family.starts_with("Noto Sans") && !f.family.contains("CJK")) { + assert!(FALLBACK_FAMILIES.contains(&f.family), "embedded {} is a document fallback", f.family); + } +} + // The paths are Unix absolute paths (font managers are a macOS thing): on Windows they aren't absolute. #[cfg(unix)] #[test] diff --git a/docs/localization-parity.md b/docs/localization-parity.md index d26dfbbdc..67cfad441 100644 --- a/docs/localization-parity.md +++ b/docs/localization-parity.md @@ -81,10 +81,10 @@ supported by both apps (CJK, Arabic and Devanagari shaping, IME); Figma has no v nothing (startup and memory measured unchanged); no CJK font installed means tofu, never a crash. The web build has no system fonts: built with craft-fonts and `FIGCRAFT_EMBED_CJK=1` it embeds Noto Sans CJK SC (+16 MB) and offers Japanese, Korean and Simplified Chinese; otherwise the language picker and - System leave them out. `FIGCRAFT_EMBED_SCRIPTS=Arab,Hebr` (script tags as the craft-fonts manifest - lists them) embeds those scripts' faces as well, so an Arabic or Persian document draws in Noto Sans - Arabic (+0.8 MB) instead of missing-glyph boxes (#1902); the picker's languages don't change. No - font file is in this repo. + System leave them out. `FIGCRAFT_EMBED_SCRIPTS=Arab,Hebr,Thai,Deva` (one tag per script wanted, as + the craft-fonts manifest lists them) embeds those scripts' faces as well, so an Arabic or Persian + document draws in Noto Sans Arabic (+0.8 MB) instead of missing-glyph boxes (#1902), and with `Arab` + the picker offers the Arabic UI catalog too, as on the desktop. No font file is in this repo. ## Languages @@ -94,7 +94,7 @@ supported by both apps (CJK, Arabic and Devanagari shaping, IME); Figma has no v | Simplified Chinese (Mandarin) | zh-Hans | 2,216 / 2,352 (94.2%, draft) | yes | CJK text and IME in documents; UI text in an installed Chinese face, ahead of Japanese ones (web: the `FIGCRAFT_EMBED_CJK` build); no Traditional Chinese catalog (zh-TW, zh-HK read English) | no | draft | 1–2 (after native review) | | Spanish | es, es-419 | 2,352 / 2,352 (100%, draft); es-419 overlays 104 Latin American wordings (draft) | yes | Latin | no | draft | 0–1 (after native review) | | Hindi | hi | 0 (0%) | no | Devanagari shaping works in documents; UI font fallback to check | no | none | 4–7 | -| Arabic | ar | 1,857 / 1,857 UI strings, 620 command labels, 31 menu wordings (draft, counted 2026-10-28) | catalog complete; native review pending | Existing bidi/shaping and Arabic system fallback; web: documents draw in Noto Sans Arabic only in a build with `FIGCRAFT_EMBED_SCRIPTS=Arab` (the font budget leaves it out otherwise, #1902), the UI language not offered; panels do not mirror | no | draft | review + panel mirroring (not re-estimated) | +| Arabic | ar | 1,857 / 1,857 UI strings, 620 command labels, 31 menu wordings (draft, counted 2026-10-28) | catalog complete; native review pending | Existing bidi/shaping and Arabic system fallback; web: only a build with `FIGCRAFT_EMBED_SCRIPTS=Arab` embeds Noto Sans Arabic (the font budget leaves it out otherwise, #1902); documents draw in it and the picker offers the Arabic UI then; panels do not mirror | no | draft | review + panel mirroring (not re-estimated) | | French | fr | 2,328 / 2,352 (99.0%, draft) | yes | Latin | no | draft | 1–2 (after native review) | | Portuguese | pt-BR | 2,331 / 2,352 (99.1%, draft) | yes | Latin | no | draft | 1–2 (after native review) | | Indonesian | id | 2,292 / 2,352 (97.4%, draft) | yes | Latin | no | draft | 1–2 (after native review) | @@ -128,7 +128,7 @@ Hindi and Arabic. Traditional Chinese is not planned (no catalog; its users see | Date | Change | Summary | |---|---|---| -| 2026-11-03 | patch | M10, #1902: the web build drew Persian and Arabic text as missing-glyph boxes. The browser has no system fonts, and `crates/text/build.rs` keeps the web catalog to Inter, Noto Sans Georgian, the wordmark and (with `FIGCRAFT_EMBED_CJK`) Noto Sans CJK, so craft-fonts' Noto Sans Arabic never reached it. `FIGCRAFT_EMBED_SCRIPTS=Arab,Hebr,…` (script tags as the manifest's scripts column lists them) now embeds those scripts' faces in a web build; the default build, its size and the UI languages on offer are unchanged. Test: `web_embeds_other_scripts_faces_only_when_asked` in the build script. | +| 2026-11-03 | patch | M10, #1902: the web build drew Persian and Arabic text as missing-glyph boxes. The browser has no system fonts, and `crates/text/build.rs` keeps the web catalog to Inter, Noto Sans Georgian, the wordmark and (with `FIGCRAFT_EMBED_CJK`) Noto Sans CJK, so craft-fonts' Noto Sans Arabic never reached it. `FIGCRAFT_EMBED_SCRIPTS=Arab,Hebr,…` (script tags as the manifest's scripts column lists them) now embeds those scripts' faces in a web build; the default build and its size are unchanged, and with `Arab` embedded the picker offers the Arabic UI as well (`cjk::can_show`, as on the desktop). Noto Sans Hebrew, Devanagari and Georgian join Arabic and Thai among the document fallbacks, so an embedded face draws its script in an Inter document. Tests: `web_embeds_other_scripts_faces_only_when_asked` in the build script, `every_embeddable_script_face_is_a_document_fallback`. | | 2026-10-30 | minor | Bosnian (`bs`, Bosanski) draft catalog: every UI string (1,906), command label (629) and menu wording (31), machine-drafted in Latin script with ijekavian forms and marked as a draft awaiting native review. Bosnian plurals: one for 1, 21, 31… (not 11), few for 2–4, 22–24… (not 12–14), other for the rest. Grade and hours unchanged (Bosnian is not one of the twelve key languages) | | 2026-10-29 | minor | German terminology corrections (M10): gradient stops, OpenType stylistic sets and the Home-screen preference; partial review, catalog remains a draft. Nine existing translations corrected; keys, placeholders, coverage, grade and estimates unchanged | | 2026-10-28 | minor | Arabic draft: 1,857 UI entries, 620 command labels and 31 menu wordings, with count-neutral plurals. AI-assisted, native review pending. Desktop uses the existing Arabic fallback and bidi; web requires an embedded Arabic face. No panel mirroring or parity-grade increase claimed | diff --git a/docs/translating.md b/docs/translating.md index e3599a08a..b24a4e04b 100644 --- a/docs/translating.md +++ b/docs/translating.md @@ -80,7 +80,8 @@ UI language (see `crates/ui-egui/src/cjk.rs`). The web build has no system fonts so Japanese, Korean and Chinese appear there only in a build with craft-fonts and `FIGCRAFT_EMBED_CJK=1` (Noto Sans CJK SC, +16 MB); otherwise they are left out of the picker. The other scripts' faces (Noto Sans Arabic, Hebrew, Thai, Devanagari) join a web build only with -`FIGCRAFT_EMBED_SCRIPTS=Arab,Hebr` (the manifest's script tags), for documents in those scripts (#1902). A +`FIGCRAFT_EMBED_SCRIPTS=Arab,Hebr,Thai,Deva` (one tag per script wanted, as the manifest lists them), for +documents in those scripts; with `Arab` embedded the picker offers Arabic too (#1902). A Chinese UI puts its Chinese face first so Han takes Simplified Chinese shapes. Georgian is drawn in craft-fonts' Noto Sans Georgian, one of the built-in faces in `theme::install_fonts`, or else in an installed font on the desktop. Web builds keep it only when the craft-fonts they're built with has