M10: render Persian and Arabic in default web builds

This commit is contained in:
mahmoud committed 2026-11-07 12:55:45 +03:30
1 parent 3635c23070
commit 9e3ab8e43d
10 files changed
+376 -74

No files matched your search

Generated
+1
View File
@@ -2084,6 +2084,7 @@ dependencies = [
"craft-font-catalog",
"figcraft-doc",
"figcraft-geom",
"flate2",
"harfrust 0.13.3",
"icu_segmenter",
"log",
+4 -2
View File
@@ -2,7 +2,7 @@
**Stage: alpha** · next: beta, ~26 points and ~162–292 h away (one Opus 5.5 agent; ~33–67 h wall-clock with 5 agents)
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-06 · **Change:** minor (the left rail's and tab strip's icons are larger, 20 pt (#553); Suggest auto layout adds nested auto layout frames by rows and columns and keeps the placement of the design, as the help center describes (#1823); the Local variables window selects several variables (click, Shift+click for a range, Cmd/Ctrl+click to toggle, Escape to clear) and delete, move to a group and scope act on the selected local variables in one undo step (#2002); the desktop UI takes a system face for Ethiopic, Devanagari, Gurmukhi, Gujarati, Tamil, Telugu, Kannada and Malayalam, Sinhala, Lao, Myanmar, Khmer, Armenian and Georgian as it did for Hebrew and Arabic, so a String variable's Amharic value draws in the panels instead of boxes (#2014); a layer's effect binding takes only a field its effect has; ; the boolean operation menu leads each entry with an original icon (#2003); glass takes one sample instead of its dispersion window where the colours split under 1/256 px; glass bends towards its core, and rounded rectangles work it out in closed form; glass's light is a line on its bevel and splay turns the bend towards the centre; glass bends with a thick-lens profile and splits its colours over 8 steps; glass effects take variables and keep their frost within 0–100; web host bridge: `?host=parent` or `data-host="page"` hands a page the app's files, documented in the hosting guide; a connector end moved with Cmd/Ctrl held goes on any part of an object, and stays there as the object moves or resizes; a tap on a plugin panel's button keeps what was typed in its fields; a Dash cap setting (none, round or square) on Dash and Custom strokes, drawn on both ends of every dash; library analytics list how many layers and files use each style and variable; the Controller menu names each button as PlayStation and Switch controllers do; widgets draw lines and SVG pictures (plugin API 6); a connector end dropped along a side of a shape attaches to that side (#1708); regression tests pin a rounded shape's one-sided stroke and SVG ids and font families without XML-forbidden characters (#1351, #1124); a damaged image is refused with a reason instead of showing as an empty box (#1474); an image copied in another app pastes again on the desktop, and in the browser for the first time (#492); SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the Frame tool's Phone presets have the iPhone 17 family (#1691); Show in folder works in the Flatpak build and selects the file on Linux (#1701); a dashed line starts and ends with a half-length dash, on the canvas and in exports; the Pages, Layers and Assets search fields keep their text in the middle of the field (#1703); a board connector's path can be reshaped by dragging its path handles (#1710); boards have 16 more shapes (arrows, polygons, star, plus and flowchart symbols), in pickers that lay them out in a grid; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a stroke's Custom style takes a dash pattern of any length as a comma-separated list (#1681); a control request can set its own timeout, up to 10 minutes (`timeoutMs`; `figcraft-cli mcp --attach PORT --timeout SECONDS`) (#1696); gap 6: a widget opens its plugin's panel (plugin API 5), whose callbacks redraw it; the keyboard's Menu key opens the context menu, as Shift+F10 does; an Open link action can open in place of the prototype, with "Open in new tab" off (gap 15); a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; a live session's welcome sends the document compressed to clients that read it, about seven times smaller (#1665); a control request that times out says truthfully whether it was dropped or is still running and will take effect, and only screenshots and input blame the window (#1673); a board keeps earlier votes' results, listed newest first in Results and deleted one at a time; the object a stamp will stick to is outlined while the stamp tool is over it or a stamp is dragged over it, and board objects take no drops (gap 24); a server can list the files shared from it now for everyone who reaches it, Home ▸ Online shows them and their links carry no secret (`team_files`, part of #742); team library analytics count detached instances per component and file (gap 10); skipping the Open link notice by command is saved with the preferences at once (gap 15); a selected connector's bar on a board sets its start and end points, solid or dashed, itsLine truncated
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-07 · **Change:** minor (web builds with craft-fonts embed Noto Sans Arabic by default so Persian and Arabic text draws without extra build flags (#1902); the left rail's and tab strip's icons are larger, 20 pt (#553); Suggest auto layout adds nested auto layout frames by rows and columns and keeps the placement of the design, as the help center describes (#1823); the Local variables window selects several variables (click, Shift+click for a range, Cmd/Ctrl+click to toggle, Escape to clear) and delete, move to a group and scope act on the selected local variables in one undo step (#2002); the desktop UI takes a system face for Ethiopic, Devanagari, Gurmukhi, Gujarati, Tamil, Telugu, Kannada and Malayalam, Sinhala, Lao, Myanmar, Khmer, Armenian and Georgian as it did for Hebrew and Arabic, so a String variable's Amharic value draws in the panels instead of boxes (#2014); a layer's effect binding takes only a field its effect has; ; the boolean operation menu leads each entry with an original icon (#2003); glass takes one sample instead of its dispersion window where the colours split under 1/256 px; glass bends towards its core, and rounded rectangles work it out in closed form; glass's light is a line on its bevel and splay turns the bend towards the centre; glass bends with a thick-lens profile and splits its colours over 8 steps; glass effects take variables and keep their frost within 0–100; web host bridge: `?host=parent` or `data-host="page"` hands a page the app's files, documented in the hosting guide; a connector end moved with Cmd/Ctrl held goes on any part of an object, and stays there as the object moves or resizes; a tap on a plugin panel's button keeps what was typed in its fields; a Dash cap setting (none, round or square) on Dash and Custom strokes, drawn on both ends of every dash; library analytics list how many layers and files use each style and variable; the Controller menu names each button as PlayStation and Switch controllers do; widgets draw lines and SVG pictures (plugin API 6); a connector end dropped along a side of a shape attaches to that side (#1708); regression tests pin a rounded shape's one-sided stroke and SVG ids and font families without XML-forbidden characters (#1351, #1124); a damaged image is refused with a reason instead of showing as an empty box (#1474); an image copied in another app pastes again on the desktop, and in the browser for the first time (#492); SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the Frame tool's Phone presets have the iPhone 17 family (#1691); Show in folder works in the Flatpak build and selects the file on Linux (#1701); a dashed line starts and ends with a half-length dash, on the canvas and in exports; the Pages, Layers and Assets search fields keep their text in the middle of the field (#1703); a board connector's path can be reshaped by dragging its path handles (#1710); boards have 16 more shapes (arrows, polygons, star, plus and flowchart symbols), in pickers that lay them out in a grid; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a stroke's Custom style takes a dash pattern of any length as a comma-separated list (#1681); a control request can set its own timeout, up to 10 minutes (`timeoutMs`; `figcraft-cli mcp --attach PORT --timeout SECONDS`) (#1696); gap 6: a widget opens its plugin's panel (plugin API 5), whose callbacks redraw it; the keyboard's Menu key opens the context menu, as Shift+F10 does; an Open link action can open in place of the prototype, with "Open in new tab" off (gap 15); a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; a live session's welcome sends the document compressed to clients that read it, about seven times smaller (#1665); a control request that times out says truthfully whether it was dropped or is still running and will take effect, and only screenshots and input blame the window (#1673); a board keeps earlier votes' results, listed newest first in Results and deleted one at a time; the object a stamp will stick to is outlined while the stamp tool is over it or a stamp is dragged over it, and board objects take no drops (gap 24); a server can list the files shared from it now for everyone who reaches it, Home ▸ Online shows them and their links carry no secret (`team_files`, part of #742); team library analytics count detached instances per component and file (gap 10); skipping the Open link notice by command is saveLine truncated
FigCraft is a clean-room, open-source, pure-Rust reimplementation of the Figma design workflow,
native on macOS, Windows, Linux and FreeBSD and in the browser, fully drivable by agents through
@@ -104,7 +104,7 @@ native speakers' reviews of the nine language drafts need people.
| Traditional Chinese (Taiwan) | zh-Hant | 2,647 / 2,647 entries (100%, counted 2026-11-03) | draft (needs native review) |
| Spanish | es, es-419 | 100% (es-419: an overlay of 101 entries) | draft (needs native review) |
| Hindi | hi | 0% | none |
| Arabic | ar | 2,508 / 2,508 entries (100%, counted 2026-10-28) | draft; the window mirrors (panels swap sides); native review and mirrored panel rows pending |
| Arabic | ar | 2,508 / 2,508 entries (100%, counted 2026-10-28) | draft; web builds with craft-fonts offer Arabic by default; the window mirrors (panels swap sides); native review and mirrored panel rows pending |
| French | fr | 95% | draft (needs native review) |
| Portuguese (Brazil) | pt-BR | 95% | draft (needs native review) |
| Indonesian | id | 99% | draft (needs native review) |
@@ -133,6 +133,7 @@ Ranked; detail and milestones in [`docs/roadmap.md`](docs/roadmap.md).
## Progress log
- **2026-11-07** · M10, #1902: web builds with craft-fonts embed Noto Sans Arabic Regular by default, so Persian and Arabic text has a fallback without `FIGCRAFT_EMBED_SCRIPTS=Arab`; required web builds reject catalogs without that face. Web faces are compressed losslessly at build time and restored once at runtime to keep the default catalog within the WASM size budget. Additional scripts remain opt-in. Exact Iran Sans appearance still needs the installed font through supported browsers' local font access. Numbers unchanged.
- **2026-11-05** · M2, #1823: Suggest auto layout is its own command. `layout.suggest` used to run `layout.add` and made one row of everything. It now splits a frame's layers into rows or columns by the gaps between them, wraps each band of several layers in a hugging frame without fill and repeats inside it, so the design gets as many auto layout frames as it needs and keeps its placement where the gaps are even (the frame keeps its size). Uneven gaps, bands that start at different offsets across the flow (lined up at the smallest) and layers that overlap along both axes are reported as `warnings`, and instances and layers inside them are refused. `layout.add` is unchanged. Tests in `layout_suggest_tests.rs`. Numbers unchanged.
- **2026-11-05** · M3, #2002: the Local variables window selects several variables with a click, Shift+click (range) and Cmd/Ctrl+click (toggle), cleared by Escape or a click on the empty space; delete, move to a group and scope act on the selected local variables as one undo step (`command.batch`); inherited variables can be selected but are left out, since they change in their own collection, and the bulk menu needs two or more local variables selected (otherwise the row shows its own menu). Rename and value edits stay single-row.
- **2026-11-05** · M10, #2014: the desktop UI takes a system face for Ethiopic, Devanagari, Gurmukhi, Gujarati, Tamil, Telugu, Kannada and Malayalam, Sinhala, Lao, Myanmar, Khmer, Armenian and Georgian as it did for Hebrew and Arabic (`bidi::script_fallbacks`: one sample letter per script, the system's families for each; Bengali and Thai keep `crate::cjk`'s choice), so a layer name or a String variable's Amharic value draws in the panels instead of boxes. Test: `bidi::tests::other_scripts_take_an_installed_system_face`.
@@ -364,6 +365,7 @@ Ranked; detail and milestones in [`docs/roadmap.md`](docs/roadmap.md).
| Date | Change | Summary |
|---|---|---|
| 2026-11-07 | patch | M10, #1902: web builds with craft-fonts embed Noto Sans Arabic Regular by default, so Persian and Arabic text has a fallback without `FIGCRAFT_EMBED_SCRIPTS=Arab`; required web builds reject catalogs without that face. Web faces are compressed losslessly at build time and restored once at runtime to keep the default catalog within the WASM size budget. Additional scripts remain opt-in. Exact Iran Sans appearance still needs the installed font through supported browsers' local font access. Numbers unchanged. |
| 2026-11-03 | minor | Traditional Chinese (Taiwan) (`zh-Hant`, 繁體中文(台灣)) draft catalog: every UI string (1,975), command label (641) and menu wording (31), translated clean-room from the English source; `zh-TW`, `zh-HK`, `zh-MO` and `zh-Hant` read it while an explicit Hans stays Simplified; the desktop UI prefers an installed Noto Sans CJK TC, then Microsoft JhengHei, PingFang TC and Heiti TC; no font is bundled; native review pending. Numbers unchanged |
| 2026-11-06 | patch | M1, #2028: Edit ▸ Set default properties gives new rectangles, ellipses, polygons and stars drawn with the tools (and, set from a text layer, new text) the selected layer's properties; it only copied them for Paste properties. Tests: `default_props_tests` (3). Numbers unchanged |
| 2026-11-06 | patch | M5, #2027: `proto.settings` refuses an unknown device name with the list of devices (it saved any string, and the presenter showed no device), takes known names in any case, and answers the page's prototype settings, so `proto.settings {}` reads them back over MCP. Test: `proto_present_tests::unknown_devices_are_refused_and_settings_read_back`. Numbers unchanged |
+7
View File
@@ -8,6 +8,12 @@ description = "FigCraft text: font database (embedded craft-fonts + system fonts
[lints]
workspace = true
[build-dependencies]
flate2 = { workspace = true }
[dev-dependencies]
flate2 = { workspace = true }
[dependencies]
figcraft-geom = { workspace = true }
figcraft-doc = { workspace = true }
@@ -34,6 +40,7 @@ craft-font-catalog = { workspace = true }
# wasm) instead of its dictionaries (~1.8 MB, which would take the .wasm past the 24 MiB gate in
# packaging/web/package.sh).
[target.'cfg(target_arch = "wasm32")'.dependencies]
flate2 = { workspace = true }
icu_segmenter = { workspace = true, features = ["lstm"] }
[target.'cfg(target_os = "macos")'.dependencies]
+163 -48
View File
@@ -1,11 +1,13 @@
//! Embeds the optional craft-fonts build input (`CRAFT_FONTS_DIR`): both `fonts/manifest.txt` and the
//! opt-in Latin presentation fonts in `fonts/latin-manifest.txt` (Inter, Roboto, …). Unset or missing,
//! `CRAFT_FONTS` is empty and native apps use system fonts. Required web releases enforce Inter
//! Regular/SemiBold and Noto Sans Georgian Regular after filtering. Recipe: craft-fonts `docs/integration.md`.
//! Regular/SemiBold, Noto Sans Georgian Regular and Noto Sans Arabic 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,Thai,Deva`: one tag per script wanted,
//! as the manifest's scripts column lists them; #1902).
//! Noto Sans Arabic is included by default so Persian and Arabic remain readable without local fonts
//! (#1902). Other scripts' faces (Hebrew, Thai, Devanagari…) stay out of web builds unless
//! `FIGCRAFT_EMBED_SCRIPTS` names their script tags (`Hebr,Thai,Deva`: one tag per script wanted,
//! as the manifest's scripts column lists them).
//! `FIGCRAFT_WEB_FONTS` (comma-separated families) adds manifest families to the web build.
use std::fmt::Write as _;
use std::path::PathBuf;
@@ -20,19 +22,31 @@ fn main() {
println!("cargo::rerun-if-env-changed=FIGCRAFT_EMBED_CJK");
println!("cargo::rerun-if-env-changed=FIGCRAFT_EMBED_SCRIPTS");
println!("cargo::rerun-if-env-changed=FIGCRAFT_WEB_FONTS");
let mut src = String::from("pub static CRAFT_FONTS: &[CraftFont] = &[\n");
let dir = std::env::var_os("CRAFT_FONTS_DIR").map(PathBuf::from);
let required = std::env::var_os("CRAFT_FONTS_REQUIRED").is_some();
let wasm = std::env::var("CARGO_CFG_TARGET_ARCH").is_ok_and(|a| a == "wasm32");
let embed_cjk = std::env::var_os("FIGCRAFT_EMBED_CJK").is_some();
let embed_scripts = scripts_from(std::env::var("FIGCRAFT_EMBED_SCRIPTS").ok().as_deref());
let web_fonts = web_fonts(&std::env::var("FIGCRAFT_WEB_FONTS").unwrap_or_default());
match input_fonts(dir.as_deref(), wasm, required, embed_cjk, &embed_scripts, &web_fonts) {
let out_dir = PathBuf::from(std::env::var_os("OUT_DIR").unwrap_or_default());
// Compress the complete web catalog so adding the Arabic fallback stays within the WASM
// size budget. Each face is restored once, byte-for-byte, before the existing font consumers.
let mut src = if wasm {
String::from(
"pub static CRAFT_FONTS: std::sync::LazyLock<Vec<CraftFont>> = std::sync::LazyLock::new(|| {\n static PACKED: &[(&str, &str, &crate::embedded::PackedFont)] = &[\n",
)
} else {
String::from("pub static CRAFT_FONTS: &[CraftFont] = &[\n")
};
match input_fonts(dir.as_deref(), wasm, required, embed_cjk, &embed_scripts, &web_fonts, wasm.then_some(out_dir.as_path())) {
Ok(entries) => src.push_str(&entries),
Err(e) => println!("cargo::error={e}"),
}
src.push_str("];\n");
let out = PathBuf::from(std::env::var_os("OUT_DIR").unwrap_or_default()).join("craft_fonts.rs");
if wasm {
src.push_str(" PACKED.iter().filter_map(|(family, style, font)| Some(CraftFont { family, style, bytes: font.data()? })).collect()\n});\n");
}
let out = out_dir.join("craft_fonts.rs");
if let Err(e) = std::fs::write(&out, src) {
println!("cargo::error=writing {}: {e}", out.display());
}
@@ -64,6 +78,7 @@ fn input_fonts(
embed_cjk: bool,
embed_scripts: &[String],
web_fonts: &[String],
packed_dir: Option<&std::path::Path>,
) -> Result<String, String> {
let Some(dir) = dir else {
for family in web_fonts {
@@ -80,7 +95,7 @@ fn input_fonts(
watch(&path);
continue;
}
match craft_fonts(dir, manifest, wasm, embed_cjk, embed_scripts, web_fonts) {
match craft_fonts(dir, manifest, wasm, embed_cjk, embed_scripts, web_fonts, packed_dir) {
Ok(catalog) => {
loaded = true;
out.push_str(&catalog.entries);
@@ -96,7 +111,7 @@ fn input_fonts(
println!("cargo::warning=FIGCRAFT_WEB_FONTS: {family:?} isn't embedded: {why}");
}
if required && wasm {
for (family, style) in [("Inter", "Regular"), ("Inter", "SemiBold"), ("Noto Sans Georgian", "Regular")] {
for (family, style) in [("Inter", "Regular"), ("Inter", "SemiBold"), ("Noto Sans Georgian", "Regular"), ("Noto Sans Arabic", "Regular")] {
if !faces.iter().any(|(f, s)| f == family && s == style) {
return Err(format!("required web font missing: {family} {style}; CRAFT_FONTS_DIR must include both Latin and core release faces"));
}
@@ -135,6 +150,7 @@ fn craft_fonts(
embed_cjk: bool,
embed_scripts: &[String],
web_fonts: &[String],
packed_dir: Option<&std::path::Path>,
) -> Result<Catalog, String> {
let manifest = dir.join(manifest_rel);
watch(&manifest);
@@ -155,25 +171,67 @@ fn craft_fonts(
if cjk && !embed_cjk {
continue;
}
// Web builds have a size budget: Inter, Noto Sans Georgian (small, for the Georgian UI), only the
// SemiBold wordmark, optionally Noto Sans CJK (every CJK script, for CJK UI text), the faces
// of the scripts `FIGCRAFT_EMBED_SCRIPTS` names (an Arabic or Persian document needs Noto Sans
// Arabic, +0.8 MB; the browser has no system fonts to fall back on, #1902), and the
// Web builds have a size budget: Inter, Noto Sans Georgian (small, for the Georgian UI),
// Noto Sans Arabic (Persian/Arabic would otherwise show boxes without local fonts, #1902),
// only the SemiBold wordmark, optionally Noto Sans CJK (every CJK script, for CJK
// UI text), the faces of the scripts `FIGCRAFT_EMBED_SCRIPTS` names, and the
// families a distribution names in `FIGCRAFT_WEB_FONTS` (a Thai face for Thai text, say).
let wordmark = *family == "Archivo" && *style == "SemiBold";
let asked = scripts.split(',').map(str::trim).any(|s| embed_scripts.iter().any(|e| e.eq_ignore_ascii_case(s)));
let added = web_fonts.iter().any(|f| f == family);
if wasm && !matches!(*family, "Inter" | "Noto Sans Georgian") && !wordmark && !cjk && !asked && !added {
if wasm && !matches!(*family, "Inter" | "Noto Sans Georgian" | "Noto Sans Arabic") && !wordmark && !cjk && !asked && !added {
continue;
}
let path = dir.join(file).canonicalize().map_err(|e| format!("{file}: {e}"))?;
println!("cargo::rerun-if-changed={}", path.display());
faces.push(((*family).to_owned(), (*style).to_owned()));
let _ = writeln!(out, " CraftFont {{ family: {family:?}, style: {style:?}, bytes: include_bytes!({:?}) }},", path.display().to_string());
if let Some(packed_dir) = packed_dir.filter(|_| wasm) {
let (packed, len) = pack_font(&path, packed_dir)?;
let _ = writeln!(
out,
" ({family:?}, {style:?}, {{ static FONT: crate::embedded::PackedFont = crate::embedded::PackedFont::new(include_bytes!({:?}), {len}); &FONT }}),",
packed.display().to_string()
);
} else {
let _ =
writeln!(out, " CraftFont {{ family: {family:?}, style: {style:?}, bytes: include_bytes!({:?}) }},", path.display().to_string());
}
}
Ok(Catalog { entries: out, faces })
}
/// Write a lossless zlib copy under OUT_DIR, never into the font checkout. A path hash avoids
/// collisions between manifest entries without using their relative paths as output paths.
fn pack_font(path: &std::path::Path, out_dir: &std::path::Path) -> Result<(PathBuf, usize), String> {
use std::hash::{Hash, Hasher};
use std::io::{Read as _, Write as _};
// Keep this in step with embedded::unpack: a required face must not build successfully
// only to be discarded by the runtime decoder. Limit reads too, if the input changes.
const MAX_FONT_BYTES: u64 = 256 * 1024 * 1024;
let file = std::fs::File::open(path).map_err(|e| format!("{}: {e}", path.display()))?;
let len = file.metadata().map_err(|e| format!("{}: {e}", path.display()))?.len();
if len == 0 || len > MAX_FONT_BYTES {
return Err(format!("{}: embedded font size must be 1..={MAX_FONT_BYTES} bytes", path.display()));
}
let mut bytes = Vec::new();
file.take(MAX_FONT_BYTES + 1).read_to_end(&mut bytes).map_err(|e| format!("{}: {e}", path.display()))?;
if bytes.is_empty() || bytes.len() as u64 > MAX_FONT_BYTES {
return Err(format!("{}: embedded font size changed outside the supported range", path.display()));
}
let mut encoder = flate2::write::ZlibEncoder::new(Vec::new(), flate2::Compression::best());
encoder.write_all(&bytes).map_err(|e| format!("compressing {}: {e}", path.display()))?;
let packed = encoder.finish().map_err(|e| format!("compressing {}: {e}", path.display()))?;
let mut hash = std::collections::hash_map::DefaultHasher::new();
path.hash(&mut hash);
let output = out_dir.join(format!("font-{:016x}.zlib", hash.finish()));
std::fs::write(&output, packed).map_err(|e| format!("{}: {e}", output.display()))?;
Ok((output, bytes.len()))
}
#[cfg(test)]
#[path = "tests/support/web_fallback.rs"]
mod web_fallback;
#[cfg(test)]
mod tests {
use super::*;
@@ -181,18 +239,18 @@ mod tests {
static NEXT: AtomicU64 = AtomicU64::new(0);
struct Fixture(PathBuf);
pub(super) struct Fixture(pub(super) PathBuf);
impl Fixture {
/// Test fixture: create a unique temporary directory, write a synthetic face file and
/// install the default Georgian manifest.
fn new() -> Self {
/// install the default Georgian and Arabic manifest.
pub(super) fn new() -> Self {
let dir = std::env::temp_dir().join(format!("fig-font-input-{}-{}", std::process::id(), NEXT.fetch_add(1, Ordering::Relaxed)));
std::fs::create_dir_all(dir.join("fonts")).unwrap();
// The build script validates manifest/file presence; font bytes are checked centrally.
std::fs::write(dir.join("fonts/face.ttf"), b"synthetic build-input fixture").unwrap();
let fixture = Self(dir);
fixture.manifest("manifest.txt", &[("Noto Sans Georgian", "Regular")]);
fixture.manifest("manifest.txt", &[("Noto Sans Georgian", "Regular"), ("Noto Sans Arabic", "Regular")]);
fixture
}
@@ -210,6 +268,32 @@ mod tests {
}
}
/// Fail at build time for sizes the runtime decoder cannot accept.
#[test]
fn web_font_compression_rejects_empty_and_oversized_inputs() {
let f = Fixture::new();
let path = f.0.join("invalid.ttf");
let file = std::fs::File::create(&path).unwrap();
assert!(pack_font(&path, &f.0).unwrap_err().contains("font size"));
file.set_len(256 * 1024 * 1024 + 1).unwrap();
assert!(pack_font(&path, &f.0).unwrap_err().contains("font size"));
}
/// Web catalog entries embed lossless packed files; native entries still reference raw fonts.
#[test]
fn web_catalog_packs_fonts_and_native_keeps_original_bytes() {
let f = Fixture::new();
let web = craft_fonts(&f.0, "fonts/manifest.txt", true, false, &[], &[], Some(&f.0)).unwrap();
assert_eq!(web.entries.matches("PackedFont::new").count(), 2);
let path = f.0.join("fonts/face.ttf").canonicalize().unwrap();
let (packed, len) = pack_font(&path, &f.0).unwrap();
assert!(web.entries.contains(&packed.display().to_string()));
assert_eq!(len, std::fs::read(&path).unwrap().len());
let native = craft_fonts(&f.0, "fonts/manifest.txt", false, false, &[], &[], Some(&f.0)).unwrap();
assert!(native.entries.contains(&path.display().to_string()));
assert!(!native.entries.contains("PackedFont"));
}
/// Asserts the native Latin catalog keeps its 43 permitted presentation faces, the web
/// catalog keeps only the four Inter faces, Adobe-authored families are absent, and
/// permitted native faces remain.
@@ -217,9 +301,9 @@ mod tests {
fn restored_latin_catalog_preserves_permitted_native_faces_and_web_budget() {
let f = Fixture::new();
std::fs::write(f.0.join("fonts/latin-manifest.txt"), include_str!("tests/fixtures/latin-families.txt")).unwrap();
let native = craft_fonts(&f.0, "fonts/latin-manifest.txt", false, false, &[], &[]).unwrap();
let native = craft_fonts(&f.0, "fonts/latin-manifest.txt", false, false, &[], &[], None).unwrap();
assert_eq!(native.faces.len(), 43, "all prior permitted presentation faces remain available");
let web = craft_fonts(&f.0, "fonts/latin-manifest.txt", true, false, &[], &[]).unwrap();
let web = craft_fonts(&f.0, "fonts/latin-manifest.txt", true, false, &[], &[], None).unwrap();
assert_eq!(web.faces.len(), 4, "the web catalog keeps only the four Inter faces");
for catalog in [&native, &web] {
assert!(!catalog.entries.contains("Source Sans 3"));
@@ -227,30 +311,31 @@ mod tests {
}
assert!(native.faces.iter().any(|(family, _)| family == "Carlito"));
assert!(native.faces.iter().any(|(family, _)| family == "Liberation Serif"));
assert!(input_fonts(Some(&f.0), true, true, false, &[], &[]).is_ok());
assert!(input_fonts(Some(&f.0), true, true, false, &[], &[], None).is_ok());
}
/// Asserts required web input rejects a catalog missing Inter Regular or Inter SemiBold.
#[test]
fn required_web_rejects_core_only_and_partial_latin_catalogs() {
let f = Fixture::new();
assert!(input_fonts(Some(&f.0), true, true, false, &[], &[]).unwrap_err().contains("Inter Regular"));
assert!(input_fonts(Some(&f.0), true, true, false, &[], &[], None).unwrap_err().contains("Inter Regular"));
f.manifest("latin-manifest.txt", &[("Inter", "Regular"), ("Unrelated", "SemiBold")]);
assert!(input_fonts(Some(&f.0), true, true, false, &[], &[]).unwrap_err().contains("Inter SemiBold"));
assert!(input_fonts(Some(&f.0), true, true, false, &[], &[], None).unwrap_err().contains("Inter SemiBold"));
}
/// Asserts required web input embeds the Inter and Georgian catalogs (three entries) and
/// Asserts required web input embeds the Inter, Georgian and Arabic catalogs (four entries) and
/// rejects a manifest without Noto Sans Georgian Regular.
#[test]
fn required_web_embeds_both_catalogs_and_requires_georgian() {
let f = Fixture::new();
f.manifest("latin-manifest.txt", &[("Inter", "Regular"), ("Inter", "SemiBold")]);
let entries = input_fonts(Some(&f.0), true, true, false, &[], &[]).unwrap();
assert_eq!(entries.matches("CraftFont {").count(), 3);
let entries = input_fonts(Some(&f.0), true, true, false, &[], &[], None).unwrap();
assert_eq!(entries.matches("CraftFont {").count(), 4);
assert!(entries.contains("family: \"Inter\""));
assert!(entries.contains("family: \"Noto Sans Georgian\""));
assert!(entries.contains("family: \"Noto Sans Arabic\""));
f.manifest("manifest.txt", &[("Other", "Regular")]);
assert!(input_fonts(Some(&f.0), true, true, false, &[], &[]).unwrap_err().contains("Noto Sans Georgian Regular"));
assert!(input_fonts(Some(&f.0), true, true, false, &[], &[], None).unwrap_err().contains("Noto Sans Georgian Regular"));
}
/// Asserts absent font input is empty when optional and an error when required, while present
@@ -258,10 +343,10 @@ mod tests {
#[test]
fn optional_and_native_inputs_keep_their_existing_policy() {
let f = Fixture::new();
assert!(input_fonts(None, true, false, false, &[], &[]).unwrap().is_empty());
assert!(input_fonts(None, true, true, false, &[], &[]).unwrap_err().contains("CRAFT_FONTS_DIR is missing"));
assert!(input_fonts(Some(&f.0), true, false, false, &[], &[]).unwrap().contains("Noto Sans Georgian"));
assert!(input_fonts(Some(&f.0), false, true, false, &[], &[]).unwrap().contains("Noto Sans Georgian"));
assert!(input_fonts(None, true, false, false, &[], &[], None).unwrap().is_empty());
assert!(input_fonts(None, true, true, false, &[], &[], None).unwrap_err().contains("CRAFT_FONTS_DIR is missing"));
assert!(input_fonts(Some(&f.0), true, false, false, &[], &[], None).unwrap().contains("Noto Sans Georgian"));
assert!(input_fonts(Some(&f.0), false, true, false, &[], &[], None).unwrap().contains("Noto Sans Georgian"));
}
/// Asserts required web input rejects a manifest whose face file is missing, even when every
@@ -271,12 +356,38 @@ mod tests {
let f = Fixture::new();
f.manifest("latin-manifest.txt", &[("Inter", "Regular"), ("Inter", "SemiBold")]);
std::fs::remove_file(f.0.join("fonts/face.ttf")).unwrap();
assert!(input_fonts(Some(&f.0), true, true, false, &[], &[]).unwrap_err().contains("fonts/face.ttf"));
assert!(input_fonts(Some(&f.0), true, true, false, &[], &[], None).unwrap_err().contains("fonts/face.ttf"));
}
/// #1902: a web build leaves the other scripts' faces out (an Arabic or Persian document shows
/// missing-glyph boxes) unless `FIGCRAFT_EMBED_SCRIPTS` names their script tags; native builds
/// keep every face, as before.
/// #1902: the default web catalog needs an Arabic fallback without local-font permission
/// or an extra distribution setting; otherwise Persian and Arabic text becomes boxes.
#[test]
fn default_web_catalog_keeps_arabic_without_opt_in() {
let f = Fixture::new();
f.manifest("manifest.txt", &[("Noto Sans Georgian", "Regular"), ("Noto Sans Arabic", "Regular"), ("Noto Sans Hebrew", "Regular")]);
let entries = input_fonts(Some(&f.0), true, false, false, &[], &[], None).unwrap();
assert!(entries.contains("family: \"Noto Sans Arabic\""), "default web text must have an Arabic/Persian fallback");
assert!(!entries.contains("Noto Sans Hebrew"), "other scripts remain opt-in");
}
/// A required web release must not silently publish without its Arabic fallback.
#[test]
fn required_web_rejects_missing_arabic_regular() {
let f = Fixture::new();
f.manifest("latin-manifest.txt", &[("Inter", "Regular"), ("Inter", "SemiBold")]);
for arabic in [None, Some("Bold")] {
let mut faces = vec![("Noto Sans Georgian", "Regular")];
if let Some(style) = arabic {
faces.push(("Noto Sans Arabic", style));
}
f.manifest("manifest.txt", &faces);
let result = input_fonts(Some(&f.0), true, true, false, &[], &[], None);
assert!(result.is_err_and(|e| e.contains("Noto Sans Arabic Regular")), "missing Arabic Regular must fail the release build");
}
}
/// Arabic is a default fallback; other scripts stay opt-in through `FIGCRAFT_EMBED_SCRIPTS`.
/// Native builds keep every face, as before.
#[test]
fn web_embeds_other_scripts_faces_only_when_asked() {
let f = Fixture::new();
@@ -286,18 +397,18 @@ mod tests {
)
.unwrap();
let families = |c: &Catalog| c.faces.iter().map(|(f, _)| f.clone()).collect::<Vec<String>>();
let web = craft_fonts(&f.0, "fonts/manifest.txt", true, false, &[], &[]).unwrap();
assert_eq!(families(&web), ["Noto Sans Georgian"], "the web budget: Georgian only");
let arabic = craft_fonts(&f.0, "fonts/manifest.txt", true, false, &["Arab".to_string()], &[]).unwrap();
let web = craft_fonts(&f.0, "fonts/manifest.txt", true, false, &[], &[], None).unwrap();
assert_eq!(families(&web), ["Noto Sans Georgian", "Noto Sans Arabic"], "the default web script fallbacks");
let arabic = craft_fonts(&f.0, "fonts/manifest.txt", true, false, &["Arab".to_string()], &[], None).unwrap();
assert_eq!(families(&arabic), ["Noto Sans Georgian", "Noto Sans Arabic"]);
// Several tags, any case, spaces, and a tag among a face's several scripts.
let more = craft_fonts(&f.0, "fonts/manifest.txt", true, false, &scripts_from(Some(" hebr, LATN ")), &[]).unwrap();
assert_eq!(families(&more), ["Noto Sans Georgian", "Noto Sans Hebrew", "Noto Sans Symbols"]);
let more = craft_fonts(&f.0, "fonts/manifest.txt", true, false, &scripts_from(Some(" hebr, LATN ")), &[], None).unwrap();
assert_eq!(families(&more), ["Noto Sans Georgian", "Noto Sans Arabic", "Noto Sans Hebrew", "Noto Sans Symbols"]);
// Native builds keep every face whatever the variable says.
assert_eq!(craft_fonts(&f.0, "fonts/manifest.txt", false, false, &[], &[]).unwrap().faces.len(), 4);
assert_eq!(craft_fonts(&f.0, "fonts/manifest.txt", false, false, &[], &[], None).unwrap().faces.len(), 4);
// The variable reaches the catalog through `input_fonts`.
assert!(input_fonts(Some(&f.0), true, false, false, &["Arab".into()], &[]).unwrap().contains("Noto Sans Arabic"));
assert!(!input_fonts(Some(&f.0), true, false, false, &[], &[]).unwrap().contains("Noto Sans Arabic"));
assert!(input_fonts(Some(&f.0), true, false, false, &["Arab".into()], &[], None).unwrap().contains("Noto Sans Arabic"));
assert!(input_fonts(Some(&f.0), true, false, false, &[], &[], None).unwrap().contains("Noto Sans Arabic"));
assert!(scripts_from(None).is_empty());
}
@@ -311,11 +422,15 @@ mod tests {
let named = web_fonts(" Noto Sans Thai, ,Noto Sans Thia ");
assert_eq!(named, ["Noto Sans Thai", "Noto Sans Thia"]);
let families = |c: &Catalog| c.faces.iter().map(|(family, _)| family.clone()).collect::<Vec<_>>();
let web = craft_fonts(&f.0, "fonts/manifest.txt", true, false, &[], &named).unwrap();
let web = craft_fonts(&f.0, "fonts/manifest.txt", true, false, &[], &named, None).unwrap();
assert_eq!(families(&web), ["Noto Sans Georgian", "Noto Sans Thai"], "the named family joins; the others stay out");
assert_eq!(families(&craft_fonts(&f.0, "fonts/manifest.txt", true, false, &[], &[]).unwrap()), ["Noto Sans Georgian"], "unset: as before");
assert_eq!(craft_fonts(&f.0, "fonts/manifest.txt", false, false, &[], &[]).unwrap().faces.len(), 3, "native builds embed every family");
assert_eq!(
families(&craft_fonts(&f.0, "fonts/manifest.txt", true, false, &[], &[], None).unwrap()),
["Noto Sans Georgian"],
"unset: as before"
);
assert_eq!(craft_fonts(&f.0, "fonts/manifest.txt", false, false, &[], &[], None).unwrap().faces.len(), 3, "native builds embed every family");
assert_eq!(not_embedded(&named, &web.faces), ["Noto Sans Thia"], "a misspelt family is reported");
assert!(input_fonts(Some(&f.0), true, false, false, &[], &named).unwrap().contains("family: \"Noto Sans Thai\""));
assert!(input_fonts(Some(&f.0), true, false, false, &[], &named, None).unwrap().contains("family: \"Noto Sans Thai\""));
}
}
+88
View File
@@ -0,0 +1,88 @@
//! Lossless decoding of web fonts, shared by the document renderer and UI through static bytes.
use std::sync::OnceLock;
/// Matches the font-file limit: corrupted metadata must not request an unbounded allocation.
const MAX_UNPACKED_FONT_BYTES: usize = 256 * 1024 * 1024;
/// One embedded zlib stream, decoded at most once; invalid streams stay unavailable.
pub(crate) struct PackedFont {
bytes: &'static [u8],
unpacked_len: usize,
decoded: OnceLock<Option<Vec<u8>>>,
}
impl PackedFont {
pub(crate) const fn new(bytes: &'static [u8], unpacked_len: usize) -> Self {
Self { bytes, unpacked_len, decoded: OnceLock::new() }
}
pub(crate) fn data(&'static self) -> Option<&'static [u8]> {
self.decoded.get_or_init(|| unpack(self.bytes, self.unpacked_len)).as_deref()
}
}
/// Decode exactly the declared size, refusing malformed, incomplete or trailing data.
pub(crate) fn unpack(bytes: &[u8], unpacked_len: usize) -> Option<Vec<u8>> {
if unpacked_len == 0 || unpacked_len > MAX_UNPACKED_FONT_BYTES {
return None;
}
// A fixed output buffer prevents even a valid compressed stream expanding past its budget.
let mut decoded = Vec::new();
decoded.try_reserve_exact(unpacked_len).ok()?;
decoded.resize(unpacked_len, 0);
let mut decoder = flate2::Decompress::new(true);
let status = decoder.decompress(bytes, &mut decoded, flate2::FlushDecompress::Finish).ok()?;
(status == flate2::Status::StreamEnd && decoder.total_out() == unpacked_len as u64 && decoder.total_in() == bytes.len() as u64).then_some(decoded)
}
#[cfg(test)]
mod tests {
use super::*;
use std::io::Write as _;
// A zlib stream of the synthetic bytes "font"; no font asset is needed by these tests.
const PACKED: &[u8] = &[120, 218, 75, 203, 207, 43, 1, 0, 4, 57, 1, 184];
#[test]
fn compressed_bytes_round_trip_exactly() {
let original = b"synthetic font bytes\0\xff\x80\0synthetic font bytes";
let mut encoder = flate2::write::ZlibEncoder::new(Vec::new(), flate2::Compression::best());
encoder.write_all(original).unwrap();
let packed = encoder.finish().unwrap();
assert_eq!(unpack(&packed, original.len()).unwrap(), original);
}
#[test]
fn corrupt_truncated_and_trailing_streams_are_refused() {
assert!(unpack(b"not a zlib stream", 4).is_none());
for end in 0..PACKED.len() {
assert!(unpack(&PACKED[..end], 4).is_none(), "truncated at byte {end}");
}
let mut corrupt = PACKED.to_vec();
corrupt[11] ^= 1;
assert!(unpack(&corrupt, 4).is_none(), "checksum mismatch");
let mut trailing = PACKED.to_vec();
trailing.push(0);
assert!(unpack(&trailing, 4).is_none(), "trailing bytes");
}
#[test]
fn declared_size_is_exact_and_bounded() {
for len in [0, 3, 5, MAX_UNPACKED_FONT_BYTES + 1, usize::MAX] {
assert!(unpack(PACKED, len).is_none(), "invalid unpacked size {len}");
}
assert_eq!(unpack(PACKED, 4).unwrap(), b"font");
}
#[test]
fn decoded_bytes_and_failures_are_cached() {
static FONT: PackedFont = PackedFont::new(PACKED, 4);
static BAD: PackedFont = PackedFont::new(PACKED, 3);
let first = FONT.data().unwrap();
assert_eq!(first, b"font");
assert!(std::ptr::eq(first, FONT.data().unwrap()));
assert!(BAD.data().is_none());
assert!(BAD.decoded.get().is_some_and(Option::is_none));
}
}
+1 -1
View File
@@ -695,7 +695,7 @@ pub fn db() -> &'static RwLock<FontDb> {
fn raw_db() -> &'static RwLock<FontDb> {
DB.get_or_init(|| {
let mut db = FontDb::default();
for f in CRAFT_FONTS {
for f in CRAFT_FONTS.iter() {
if let Some(face) = Face::from_bytes(FontBytes::Static(f.bytes), 0, Some(f.family), Some(f.style)) {
db.add(face);
}
+2
View File
@@ -9,6 +9,8 @@
mod breaks;
pub mod color;
pub mod display;
#[cfg(target_arch = "wasm32")]
mod embedded;
pub mod fontdb;
mod layout;
mod onpath;
+82
View File
@@ -0,0 +1,82 @@
//! Exercise shaping with the actual default web catalog, without desktop font fallbacks.
use super::{craft_fonts, pack_font};
#[path = "../../src/embedded.rs"]
mod embedded;
use figcraft_text::fontdb::{Face, FontBytes};
#[test]
fn default_web_fonts_render_persian_and_arabic_without_system_fonts() {
let Some(dir) = std::env::var_os("CRAFT_FONTS_DIR").map(std::path::PathBuf::from).filter(|p| p.join("fonts/manifest.txt").is_file()) else {
eprintln!("craft-fonts is absent; build-policy fixtures still run, real-font shaping skipped");
return;
};
// Check source availability independently of the web filter under test. Otherwise removing
// Arabic from that filter would skip this regression instead of reproducing the boxes.
if [("Inter", "Regular"), ("Inter", "SemiBold"), ("Noto Sans Georgian", "Regular"), ("Noto Sans Arabic", "Regular")]
.iter()
.any(|(family, style)| !figcraft_text::CRAFT_FONTS.iter().any(|font| font.family == *family && font.style == *style))
{
eprintln!("complete release font catalog is absent; build-policy fixtures still run, real-font shaping skipped");
return;
}
let packed_dir = super::tests::Fixture::new();
let mut faces = Vec::new();
for manifest in ["fonts/latin-manifest.txt", "fonts/manifest.txt"] {
if dir.join(manifest).is_file() {
faces.extend(craft_fonts(&dir, manifest, true, false, &[], &[], None).unwrap().faces);
}
}
// This integration-test process owns its font database. Native embedding includes more
// families than the web, so retain only the web build's faces and disable system discovery.
figcraft_text::opt_out_of_system_fonts();
let has_all_inter_styles = ["Regular", "Italic", "SemiBold", "Bold"].iter().all(|style| faces.iter().any(|(f, s)| f == "Inter" && s == style));
let mut prior_raw_bytes = 0;
let mut packed_bytes = 0;
{
let mut db = figcraft_text::db().write().unwrap();
*db = figcraft_text::FontDb::default();
for (family, style) in faces {
let font = figcraft_text::CRAFT_FONTS.iter().find(|f| f.family == family && f.style == style).expect("manifest face is embedded");
// Run the build-time compressor and the exact WASM decoder before shaping.
let source = packed_dir.0.join("face.ttf");
std::fs::write(&source, font.bytes).unwrap();
let (packed, len) = pack_font(&source, &packed_dir.0).unwrap();
let packed = std::fs::read(packed).unwrap();
packed_bytes += packed.len();
if family != "Noto Sans Arabic" {
prior_raw_bytes += font.bytes.len();
}
let decoded = embedded::unpack(&packed, len).unwrap();
assert_eq!(decoded, font.bytes);
db.add(Face::from_bytes(FontBytes::Shared(std::sync::Arc::new(decoded)), 0, Some(font.family), Some(font.style)).unwrap());
}
}
if has_all_inter_styles {
assert!(packed_bytes < prior_raw_bytes, "including Arabic must not grow the embedded web font payload");
}
eprintln!("web font payload: {packed_bytes} compressed bytes including Arabic; {prior_raw_bytes} raw bytes before Arabic");
for family in ["Iran Sans", "Inter"] {
for characters in ["۴۵,۰۰۰ تومان به کیف پول بومرنگ شما واریز شد.", "مرحبا بالعالم ١٢٣"] {
let mut text = figcraft_doc::TextData::new(characters);
text.style.font_family = family.into();
let layout = figcraft_text::layout(&text, None, None);
assert!(!layout.glyphs.is_empty());
assert!(layout.glyphs.iter().all(|g| g.gid != 0), "missing glyphs for {family}: {characters}");
assert!(layout.glyphs.iter().any(|g| g.face.family == "Noto Sans Arabic"));
assert!(layout.lines.first().unwrap().rtl, "Arabic/Persian paragraphs run right to left");
if characters.starts_with('۴') {
let x = |at| layout.glyphs.iter().find(|g| g.char_start == at).unwrap().x;
assert!(x(0) < x(5), "Persian digits keep their left-to-right order inside the RTL paragraph");
}
}
let mut joined = figcraft_doc::TextData::new("بب");
joined.style.font_family = family.into();
let layout = figcraft_text::layout(&joined, None, None);
assert!(layout.glyphs.iter().all(|g| g.gid != g.face.glyph_for('ب')), "adjacent Arabic letters use joined forms");
}
}
+11 -9
View File
@@ -1,6 +1,6 @@
# Localization parity
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-05 · **Change:** minor (a right-to-left UI language (Arabic) mirrors the window: the icon rail and layers panel on the right, the Design panel on the left, popovers beside it over the canvas, egui's scroll bars, submenus and checkboxes mirrored; `FIGCRAFT_EMBED_SCRIPTS` embeds other scripts' craft-fonts faces in a web build, so Arabic and Persian documents draw there (#1902); documents: a paragraph's base direction can be forced with Text ▸ Text direction, as Add right-to-left text says (#1830); Bosnian draft catalog, one/few/other plurals; German terminology corrections (M10): gradient stops, OpenType stylistic sets and the Home-screen preference; partial review, catalog remains a draft; Arabic draft catalog, count-neutral plurals and web font gate; Thai draft catalog and Thai UI fonts; a missing translation fails no check: `cargo xtask i18n-report` lists them; Vietnamese draft catalog; string counts re-measured: 2,352 entries; Russian and Turkish catalogs reviewed by native speakers, Russian one/few/many plurals; Czech and Indonesian drafts; the Japanese draft completed; counts re-measured; Windows UI language from the first preferred language; draft catalogs catch up: every draft translates every string again; Simplified Chinese draft catalog; macOS finds its downloadable CJK system fonts (#406); string counts re-measured: 2,272 entries, the drafts at 95–99%; Swedish command labels and menu wordings; Russian, Swedish, Turkish, Czech and Indonesian listed; a duplicated paragraph removed) · **Target:** Figma Design (desktop app 126.10.7)
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-07 · **Change:** minor (a right-to-left UI language (Arabic) mirrors the window: the icon rail and layers panel on the right, the Design panel on the left, popovers beside it over the canvas, egui's scroll bars, submenus and checkboxes mirrored; web builds with craft-fonts embed Noto Sans Arabic Regular by default, and required web builds reject catalogs without it, so Persian and Arabic documents draw without extra build flags (#1902); other scripts remain opt-in with `FIGCRAFT_EMBED_SCRIPTS`; documents: a paragraph's base direction can be forced with Text ▸ Text direction, as Add right-to-left text says (#1830); Bosnian draft catalog, one/few/other plurals; German terminology corrections (M10): gradient stops, OpenType stylistic sets and the Home-screen preference; partial review, catalog remains a draft; Arabic draft catalog, count-neutral plurals and web font gate; Thai draft catalog and Thai UI fonts; a missing translation fails no check: `cargo xtask i18n-report` lists them; Vietnamese draft catalog; string counts re-measured: 2,352 entries; Russian and Turkish catalogs reviewed by native speakers, Russian one/few/many plurals; Czech and Indonesian drafts; the Japanese draft completed; counts re-measured; Windows UI language from the first preferred language; draft catalogs catch up: every draft translates every string again; Simplified Chinese draft catalog; macOS finds its downloadable CJK system fonts (#406); string counts re-measured: 2,272 entries, the drafts at 95–99%; Swedish command labels and menu wordings; Russian, Swedish, Turkish, Czech and Indonesian listed; a duplicated paragraph removed) · **Target:** Figma Design (desktop app 126.10.7)
FigCraft's interface has a localization layer with an English catalog, a Russian catalog reviewed
by a native speaker, and Spanish (with a Latin American overlay), French, German, Brazilian
@@ -96,11 +96,14 @@ supported by both apps (CJK, Arabic and Devanagari shaping, IME); Figma has no v
embeds Noto Sans CJK SC (+16 MB) and offers Japanese, Korean and Simplified Chinese; without a
Noto Sans CJK TC face built in it leaves Traditional Chinese out too; otherwise the language picker and
System leave them out. No font file is in this repo.
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,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.
- **Arabic and Persian on the web:** builds with craft-fonts embed Noto Sans Arabic Regular by
default, so documents have an Arabic-script fallback and the picker offers the Arabic UI without
extra build flags (#1902). Required web builds reject a catalog without that face. Web fonts are packed
losslessly at build time and restored once at runtime to preserve the WASM size budget; other
scripts remain optional through
`FIGCRAFT_EMBED_SCRIPTS=Hebr,Thai,Deva` (one tag per script wanted, as the manifest lists them).
Noto Sans Arabic is a fallback: matching Iran Sans exactly still needs that installed font via
local font access in a browser that supports it. No font file is added to this repository.
## Languages
@@ -111,10 +114,8 @@ supported by both apps (CJK, Arabic and Devanagari shaping, IME); Figma has no v
| Traditional Chinese (Taiwan) | zh-Hant | 2,647 / 2,647 (100%: 1,975 UI strings, 641 command labels, 31 menu wordings; draft, counted 2026-11-03) | yes | CJK text and IME in documents; UI text in an installed Noto Sans CJK TC, then Microsoft JhengHei, PingFang TC or Heiti TC (web: only with a built-in TC face); zh-TW, zh-HK, zh-MO and zh-Hant read it, an explicit Hans stays Simplified | 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: 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) |
| 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 builds with craft-fonts embed Noto Sans Arabic by default for documents and the Arabic UI (#1902); the window mirrors (panels swap sides), rows inside the panels do not | no | draft | review + mirrored panel rows (not re-estimated) |
| Hindi | hi | 0 (0%) | no | Devanagari shaping works in documents; the desktop UI takes an installed Devanagari face (Nirmala UI, Kohinoor Devanagari, Noto Sans Devanagari, Lohit) for names and values (#2014); no UI catalog | 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 not offered (font budget excludes Arabic); 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 not offered (font budget excludes Arabic); the window mirrors (panels swap sides), rows inside the panels do not | no | draft | review + mirrored panel rows (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) |
@@ -149,6 +150,7 @@ Hindi and Arabic.
| Date | Change | Summary |
|---|---|---|
| 2026-11-07 | patch | M10, #1902: Noto Sans Arabic Regular joins the default web font catalog, so Persian and Arabic documents no longer need `FIGCRAFT_EMBED_SCRIPTS=Arab`. Required web builds fail if the face is missing; web fonts are packed losslessly and restored once at runtime to preserve the WASM size budget. Other script fonts stay optional. Exact Iran Sans rendering requires that installed font through supported browsers' local font access. Existing duplicate Arabic rows and the repeated web-font paragraph are consolidated, preserving the mirrored window and pending panel-row mirroring. Grades and estimates unchanged. |
| 2026-11-03 | minor | Traditional Chinese (Taiwan) (`zh-Hant`, 繁體中文(台灣)) draft catalog: every UI string (1,975), command label (641) and menu wording (31), translated clean-room from the English source and marked as a draft awaiting native review. `zh-TW`, `zh-HK`, `zh-MO` and `zh-Hant` read it; an explicit Hans still reads Simplified Chinese. The desktop UI prefers an installed Noto Sans CJK TC, then Microsoft JhengHei, PingFang TC and Heiti TC; no font is bundled. No plural forms. Localization grade and estimates unchanged |
| 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-11-05 | patch | #2014: the panels drew a String variable's Amharic value as boxes: the UI took a system face for Hebrew and Arabic only. `bidi::script_fallbacks` now samples one letter of each of 16 scripts (Ethiopic, Devanagari, Gurmukhi, Gujarati, Tamil, Telugu, Kannada and Malayalam, Sinhala, Lao, Myanmar, Khmer, Armenian and Georgian as well as Hebrew and Arabic; Bengali and Thai keep `crate::cjk`'s faces) against the system's families for each (Windows, macOS, the common Linux fonts), the first installed one that draws the letter taken once. Desktop only: the web build has no system fonts. Test: `bidi::tests::other_scripts_take_an_installed_system_face` (skips scripts the machine has no face for). |
+17 -14
View File
@@ -87,16 +87,17 @@ Traditional Chinese is left out unless that build has a Noto Sans CJK TC face. A
Chinese UI puts its Chinese face first so Han takes Simplified Chinese shapes, and a Traditional
Chinese UI puts an installed Noto Sans CJK TC first, then the system's Taiwan faces (Microsoft
JhengHei, PingFang TC, Heiti TC), so Han takes Traditional shapes. No font is added to this
repository. Georgian is drawn in
`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,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
it (`crates/text/build.rs`); the commit releases pin doesn't yet (`docs/releasing.md`), so the web
picker leaves Georgian out. A new CJK or other non-Latin language also needs its script in
repository.
Web builds with craft-fonts embed Noto Sans Arabic Regular by default for Persian and Arabic
documents, and the picker offers Arabic without extra build flags (#1902). Required web builds
reject a catalog without that face (`crates/text/build.rs`). Web faces are compressed losslessly
at build time and restored once at runtime to preserve the WASM size budget. Additional script
faces (Noto Sans Hebrew, Thai, Devanagari) join a web build with
`FIGCRAFT_EMBED_SCRIPTS=Hebr,Thai,Deva` (one tag per script wanted, as the manifest lists them).
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. Required web builds also
require Noto Sans Georgian Regular. A new CJK or other non-Latin language needs its script in
`cjk::language`, or a built-in craft-fonts face.
## Arabic draft
@@ -112,10 +113,12 @@ This is deliberate: the current plural `Forms` have no zero/two fields. It is no
of Arabic's six CLDR categories; wording remains valid for 0, 1, 2 and larger integer counts.
Arabic text uses the existing bidi/shaping and Arabic system-font fallback on desktop. Web builds
require an embedded Noto Sans Arabic face to offer Arabic. The current web font budget filters
that face out, so Arabic is not offered on the web yet. No font is added to
this repository. The interface's panels are not mirrored; this catalog does not claim a complete
right-to-left interface. Native review and representative in-app checks remain required.
with craft-fonts include Noto Sans Arabic by default and offer Arabic. This fallback makes Persian
and Arabic text readable; matching Iran Sans exactly still requires that installed font. In a
browser that supports local font access, choose “Use fonts installed on this computer…” in the
Design panel's font menu and grant the browser's permission. No font is added to this repository.
The window mirrors (the panels swap sides), but rows inside the panels keep their left-to-right
order. Native review and representative in-app checks remain required.
## Traditional Chinese (Taiwan) draft