fonts: embed craft-fonts' Indian-script faces; the web build draws Indian text

ui-egui's build.rs reads the optional craft-fonts input (CRAFT_FONTS_DIR,
per craft-fonts' docs/integration.md) and embeds the Noto Sans faces for
the nine Indian scripts (Deva, Beng, Guru, Gujr, Orya, Taml, Telu, Knda,
Mlym; ~5 MB) on every target. The theme appends them after the system
faces, so desktop rendering is unchanged where a system face exists and
the web build, which has no system fonts, draws and shapes Indian text.
Language::script() names each interface's script; the web build follows
the browser's language when the build can render it.

CI checks the embedded faces against a pinned craft-fonts commit (the
Noto Sans Indian faces, storytold/craft-fonts#21): they draw and shape
every script with no system face, and the web build compiles with them.
FreeBSD and release workflows pin the same commit. A plain build is
unchanged (empty table, same tests pass).
This commit is contained in:
kulveersingh committed 2026-10-12 02:08:04 -04:00
1 parent fd63fe1bed
commit bc3aab900f
12 files changed
+221 -31

No files matched your search

+18
View File
@@ -46,3 +46,21 @@ jobs:
- name: Quality gate
run: cargo xtask ci
# The optional craft-fonts build input (CRAFT_FONTS_DIR): the Indian-script faces the web build
# embeds. The gate above runs without it; this checks the embedded faces draw and shape Indian
# text with no system faces, and that the web build compiles with them.
- name: Check out craft-fonts
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: storytold/craft-fonts
ref: d47f68570a43b364afcd832d00c297a9edea6932
path: craft-fonts
- name: Embedded craft-fonts faces
env:
CRAFT_FONTS_DIR: ${{ github.workspace }}/craft-fonts
CRAFT_FONTS_REQUIRED: "1"
run: |
cargo test -p gridcraft-ui-egui --lib theme::
cargo check --target wasm32-unknown-unknown -p gridcraft-web
+1 -1
View File
@@ -56,7 +56,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: storytold/craft-fonts
ref: abb83316d96aa59c1cf64784289e378fe9fa5695
ref: d47f68570a43b364afcd832d00c297a9edea6932
path: craft-fonts
- name: Build in a FreeBSD VM
uses: vmactions/freebsd-vm@c46abacb49f09938ca4e1702d15d836285d694cc # v1.5.9
+1 -1
View File
@@ -24,7 +24,7 @@ jobs:
with:
app-name: gridcraft
app-title: GridCraft
craft-fonts-ref: abb83316d96aa59c1cf64784289e378fe9fa5695
craft-fonts-ref: d47f68570a43b364afcd832d00c297a9edea6932
version: ${{ inputs.version }}
secrets:
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
+3 -1
View File
@@ -2,7 +2,7 @@
**Stage: alpha** · next: beta, ~25 points of "ready for real work" and ~160–240 h away
> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-10-11 · **Change:** minor (ten Indian languages and Indian-script fonts) · **Target:** Microsoft Excel (Microsoft 365)
> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-10-12 · **Change:** minor (web build: Indian-script faces from craft-fonts; French fix) · **Target:** Microsoft Excel (Microsoft 365)
GridCraft aims at full Microsoft Excel parity, and at being better in places: faster, open (XLSX
is the native format), fully scriptable by agents (MCP, control channel, CLI), and on the web.
@@ -132,6 +132,7 @@ Ranked; estimates in Opus 5.5 agent-hours. Detail and the full beta-gate list in
| Date | What landed |
|---|---|
| 2026-10-12 | Indian-script text in the web build: Noto Sans faces from craft-fonts are embedded when built with `CRAFT_FONTS_DIR`; the French interface's labels are back on the right buttons |
| 2026-10-11 | Ten Indian interface languages (Hindi, Bengali, Marathi, Telugu, Tamil, Gujarati, Kannada, Malayalam, Odia, Punjabi) and system Indian-script fonts on Windows, macOS, Linux and BSD, shaped correctly |
| 2026-10-11 | Command-sequence fuzzing: random command sequences checked against undo/redo, XLSX round-trip and full recalculation; fixes for the table, legacy-array, spill, AutoSum, Watch Window and sheet-copy bugs it found |
| 2026-10-11 | Password-protected workbooks open: GridCraft asks for the password and decrypts Agile and Standard encryption (#11) |
@@ -178,6 +179,7 @@ Ranked; estimates in Opus 5.5 agent-hours. Detail and the full beta-gate list in
| Date | Change | Summary |
|---|---|---|
| 2026-10-12 | minor | Web build embeds Indian-script faces from craft-fonts; French catalog fix; progress log row |
| 2026-10-11 | minor | Ten Indian languages, Indian-script fonts; language counts and table updated; progress log row |
| 2026-10-11 | minor | Password-encrypted workbooks open (#11); progress log row |
| 2026-10-11 | minor | Forecast Sheet (#322); progress log row |
+4 -4
View File
@@ -40,11 +40,11 @@ pub fn start() {
}
let mut app = SheetApp::new(session, services(inbox.clone(), cc.egui_ctx.clone()));
app.ui.system_theme = true;
// Follow the browser's language, except one needing script fonts (CJK, Indian
// scripts): the web build has no system fonts (none are bundled), so that
// interface would render as tofu.
// Follow the browser's language, except one needing a script face this build
// lacks: the web has no system fonts, only the Indian-script faces embedded from
// craft-fonts (CRAFT_FONTS_DIR), so a CJK interface would render as tofu.
let browser = gridcraft_ui_egui::i18n::Language::system();
if !browser.needs_script_fonts() {
if browser.renders_without_system_fonts() {
app.ui.language = browser;
}
SheetApp::setup_context_for_language(&cc.egui_ctx, false, app.ui.language);
+57
View File
@@ -24,6 +24,63 @@ fn main() {
if let Err(e) = std::fs::write(&out, generate(&json, &people)) {
println!("cargo::warning=writing {}: {e}", out.display());
}
craft_fonts_main();
}
/// The craft-fonts scripts GridCraft embeds: the Indian scripts, which the web build has no other
/// face for (~5 MB together). Desktop systems ship faces for every script, so nothing else is
/// embedded; the system faces stay first and these are the last resort.
const CRAFT_SCRIPTS: &[&str] = &["Deva", "Beng", "Guru", "Gujr", "Orya", "Taml", "Telu", "Knda", "Mlym"];
/// Writes `$OUT_DIR/craft_fonts.rs`: the optional craft-fonts build input (`CRAFT_FONTS_DIR`, see
/// craft-fonts' docs/integration.md). Unset means an empty table and no change; set but unusable is
/// a warning, or an error with `CRAFT_FONTS_REQUIRED`.
fn craft_fonts_main() {
println!("cargo::rerun-if-env-changed=CRAFT_FONTS_DIR");
println!("cargo::rerun-if-env-changed=CRAFT_FONTS_REQUIRED");
let mut src = String::from("pub static CRAFT_FONTS: &[CraftFont] = &[\n");
if let Some(dir) = std::env::var_os("CRAFT_FONTS_DIR").map(std::path::PathBuf::from) {
match craft_fonts(&dir) {
Ok(entries) => src.push_str(&entries),
Err(e) if std::env::var_os("CRAFT_FONTS_REQUIRED").is_some() => {
println!("cargo::error=CRAFT_FONTS_DIR={}: {e}", dir.display());
}
Err(e) => println!("cargo::warning=building without craft-fonts: CRAFT_FONTS_DIR={}: {e}", dir.display()),
}
}
src.push_str("];\n");
let out = std::path::PathBuf::from(std::env::var_os("OUT_DIR").unwrap_or_default()).join("craft_fonts.rs");
if let Err(e) = std::fs::write(&out, src) {
println!("cargo::error=writing {}: {e}", out.display());
}
}
/// One `CraftFont { .. }` initialiser per manifest line whose scripts include a [`CRAFT_SCRIPTS`] one.
fn craft_fonts(dir: &std::path::Path) -> Result<String, String> {
let manifest = dir.join("fonts/manifest.txt");
println!("cargo::rerun-if-changed={}", manifest.display());
let text = std::fs::read_to_string(&manifest).map_err(|e| format!("{}: {e}", manifest.display()))?;
let mut out = String::new();
for line in text.lines().map(str::trim).filter(|l| !l.is_empty() && !l.starts_with('#')) {
let f: Vec<&str> = line.split(" | ").map(str::trim).collect();
let [family, style, file, scripts, ..] = f.as_slice() else {
return Err(format!("malformed manifest line: {line}"));
};
let scripts: Vec<&str> = scripts.split(',').map(str::trim).collect();
if !scripts.iter().any(|s| CRAFT_SCRIPTS.contains(s)) {
continue;
}
let path = dir.join(file).canonicalize().map_err(|e| format!("{file}: {e}"))?;
println!("cargo::rerun-if-changed={}", path.display());
let scripts: Vec<String> = scripts.iter().map(|s| format!("{s:?}")).collect();
let _ = writeln!(
out,
" CraftFont {{ family: {family:?}, style: {style:?}, scripts: &[{}], bytes: include_bytes!({:?}) }},",
scripts.join(", "),
path.display().to_string(),
);
}
Ok(out)
}
fn read<T>(path: &std::path::Path, fallback: &str, parse: impl Fn(&str) -> Result<T, String>) -> Option<T> {
+19
View File
@@ -0,0 +1,19 @@
//! Fonts from the optional craft-fonts build input (`CRAFT_FONTS_DIR`; see `build.rs`). Only the
//! Indian-script faces are embedded. The table is empty in a build without craft-fonts, and every
//! user of it works when it is.
/// One embedded craft-fonts face.
pub struct CraftFont {
pub family: &'static str,
pub style: &'static str,
/// ISO 15924 scripts the font is for, e.g. `"Deva"`.
pub scripts: &'static [&'static str],
pub bytes: &'static [u8],
}
include!(concat!(env!("OUT_DIR"), "/craft_fonts.rs"));
/// Whether an embedded face covers `script` (ISO 15924).
pub fn covers(script: &str) -> bool {
CRAFT_FONTS.iter().any(|f| f.scripts.contains(&script))
}
+35 -17
View File
@@ -180,25 +180,37 @@ impl Language {
}
}
/// The ISO 15924 script of an interface that needs a face egui's bundled fonts lack (CJK, the
/// Indian scripts); `None` for Latin, Cyrillic and the other scripts they cover.
pub fn script(self) -> Option<&'static str> {
Some(match self {
Self::Zh => "Hans",
Self::Ja => "Jpan",
Self::Ko => "Kore",
Self::Hi | Self::Mr => "Deva",
Self::Bn => "Beng",
Self::Pa => "Guru",
Self::Gu => "Gujr",
Self::Or => "Orya",
Self::Ta => "Taml",
Self::Te => "Telu",
Self::Kn => "Knda",
Self::Ml => "Mlym",
Self::En | Self::Es | Self::Ru | Self::PtBr | Self::De | Self::Cs | Self::Fr => return None,
})
}
/// Whether the interface needs a script face that egui's bundled fonts lack (CJK, Indian
/// scripts). The desktop apps find one among the system fonts; the web build has none to load.
/// scripts). The desktop apps find one among the system fonts; the web build only has the
/// faces embedded from craft-fonts ([`crate::craft_fonts`]).
pub fn needs_script_fonts(self) -> bool {
matches!(
self,
Self::Zh
| Self::Ja
| Self::Ko
| Self::Hi
| Self::Bn
| Self::Mr
| Self::Te
| Self::Ta
| Self::Gu
| Self::Kn
| Self::Ml
| Self::Or
| Self::Pa
)
self.script().is_some()
}
/// Whether this build can draw the interface without system fonts: no script face is needed,
/// or craft-fonts embedded one. The web build follows the browser's language only then.
pub fn renders_without_system_fonts(self) -> bool {
self.script().is_none_or(crate::craft_fonts::covers)
}
pub fn formula_locale(self) -> gridcraft_engine::formula::FormulaLocale {
@@ -762,6 +774,12 @@ mod tests {
assert_eq!(Language::parse("xx"), None);
assert!(Language::Hi.needs_script_fonts() && Language::Ja.needs_script_fonts());
assert!(!Language::Fr.needs_script_fonts() && !Language::Ru.needs_script_fonts());
assert_eq!(Language::Mr.script(), Some("Deva"), "Marathi is written in Devanagari");
assert_eq!(Language::Pa.script(), Some("Guru"));
assert!(Language::En.renders_without_system_fonts() && Language::Ru.renders_without_system_fonts());
for l in Language::ALL.into_iter().filter(|l| l.needs_script_fonts()) {
assert_eq!(l.renders_without_system_fonts(), l.script().is_some_and(crate::craft_fonts::covers), "{l:?}");
}
}
#[test]
+1
View File
@@ -11,6 +11,7 @@ mod border_preview;
mod cell_pictures;
pub mod chartview;
pub mod control;
pub mod craft_fonts;
pub mod credits;
pub mod dialogs;
pub mod editor;
+65 -3
View File
@@ -392,7 +392,10 @@ pub fn font_definitions_with(language: crate::i18n::Language, used: &[String]) -
let mut bound: Vec<String> = Vec::new();
// The non-Latin fallback faces have to sit at the end of each chain: a Latin font owns Latin,
// and epaint picks the first face that has the glyph, so they only catch their own scripts.
let fallback = load_fallback(&mut fonts, HanOrder::of(language));
let mut fallback = load_fallback(&mut fonts, HanOrder::of(language));
// craft-fonts faces go last: system faces win where they exist, these catch the rest (the web
// build, a desktop without a face for the script).
fallback.extend(add_craft_faces(&mut fonts));
for role in [UI, UI_BOLD, CELL, CELL_BOLD, CELL_ITALIC, CELL_BOLD_ITALIC, SERIF, MONO] {
let paths = candidates(role);
let refs: Vec<(&str, u32)> = paths.iter().map(|(p, i)| (p.as_str(), *i)).collect();
@@ -474,6 +477,18 @@ fn load_fallback(_fonts: &mut FontDefinitions, _han: HanOrder) -> Vec<String> {
Vec::new()
}
/// Adds the embedded craft-fonts faces ([`crate::craft_fonts`]) and returns their keys; none in a
/// build without craft-fonts.
fn add_craft_faces(fonts: &mut FontDefinitions) -> Vec<String> {
let mut keys = Vec::new();
for f in crate::craft_fonts::CRAFT_FONTS {
let key = format!("craft-{} {}", f.family, f.style);
fonts.font_data.insert(key.clone(), Arc::new(FontData::from_static(f.bytes)));
keys.push(key);
}
keys
}
/// Every fallback face we look for, in chain order: `(key, candidate files)`. One file per script
/// family is enough — epaint picks the first face with the glyph, and a script's glyphs live in one
/// file. Order only matters between faces that both cover a glyph (Japanese vs Chinese kanji), so
@@ -860,12 +875,14 @@ mod tests {
#[test]
fn fallback_faces_are_appended_to_every_family() {
// Structural: whatever loaded, the non-Latin fallback keys must sit at the end of each chain
// (after the Latin/default fonts) so Latin still wins for Latin text, in the language's order.
// (after the Latin/default fonts) so Latin still wins for Latin text, in the language's order,
// followed only by the embedded craft-fonts faces (the last resort).
for han in [HanOrder::Chinese, HanOrder::Japanese] {
let language = if han == HanOrder::Japanese { Language::Ja } else { Language::Zh };
let fonts = font_definitions_for_language(language);
let craft = crate::craft_fonts::CRAFT_FONTS.iter().map(|f| format!("craft-{} {}", f.family, f.style));
let fb_keys: Vec<String> =
fallback_faces(han).into_iter().map(|(k, _)| k.to_string()).filter(|k| fonts.font_data.contains_key(k)).collect();
fallback_faces(han).into_iter().map(|(k, _)| k.to_string()).chain(craft).filter(|k| fonts.font_data.contains_key(k)).collect();
if fb_keys.is_empty() {
return; // no fallback face on this machine (minimal Linux)
}
@@ -986,6 +1003,51 @@ mod tests {
}
}
#[test]
fn craft_fonts_draw_and_shape_indian_text_without_system_faces() {
// What the web build sees: egui's bundled fonts plus the embedded craft-fonts faces, no
// system faces. Runs only in a build with CRAFT_FONTS_DIR set (CI sets it).
if crate::craft_fonts::CRAFT_FONTS.is_empty() {
return;
}
let mut fonts = FontDefinitions::default();
let craft = add_craft_faces(&mut fonts);
if let Some(chain) = fonts.families.get_mut(&FontFamily::Proportional) {
chain.extend(craft);
}
drop_unparseable_fonts(&mut fonts);
let ctx = egui::Context::default();
ctx.set_fonts(fonts);
let mut out = ctx.run_ui(egui::RawInput::default(), |_ui| {});
out.textures_delta.clear(); // nothing consumes the atlas in a headless test
let glyphs = |text: &str| {
let galley = ctx.fonts_mut(|f| f.layout_no_wrap(text.to_owned(), FontId::proportional(14.0), Color32::BLACK));
galley.rows.iter().flat_map(|r| r.glyphs.iter()).filter(|g| g.uv_rect.size.x > 0.0).map(|g| g.uv_rect).collect::<Vec<_>>()
};
let tofu = glyphs("\u{25FB}");
let samples = [
("Deva", "हिन्दी"),
("Beng", "বাংলা"),
("Guru", "ਪੰਜਾਬੀ"),
("Gujr", "ગુજરાતી"),
("Orya", "ଓଡ଼ିଆ"),
("Taml", "தமிழ்"),
("Telu", "తెలుగు"),
("Knda", "ಕನ್ನಡ"),
("Mlym", "മലയാളം"),
];
for (script, sample) in samples {
if !crate::craft_fonts::covers(script) {
continue;
}
let drawn = glyphs(sample);
assert!(!drawn.is_empty() && drawn.iter().all(|g| !tofu.contains(g)), "{script}: {sample:?} renders as tofu");
}
if crate::craft_fonts::covers("Deva") {
assert_eq!(glyphs("क्ष").len(), 1, "क + virama + ष forms the conjunct क्ष");
}
}
#[test]
fn indic_faces_are_regular_weight() {
// A family collection's face order is not alphabetical by weight (macOS's Kohinoor Gujarati
+7 -4
View File
@@ -1,6 +1,6 @@
# Localization parity
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-11 · **Change:** minor (ten Indian languages, Indian-script fonts, shaping re-checked) · **Target:** Microsoft Excel (Microsoft 365), Excel for Mac 16.113.4
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-12 · **Change:** minor (web build: Indian-script faces from craft-fonts; French catalog rebuilt) · **Target:** Microsoft Excel (Microsoft 365), Excel for Mac 16.113.4
Per-language status against Excel, which ships its UI in dozens of languages (Windows language
packs cover 100+), with localized function names, argument separators, number and date formats,
@@ -35,8 +35,10 @@ right-to-left sheets and full complex-script support. Part of
the BSDs. **Text is shaped**: epaint 0.36 runs every run through harfrust (OpenType GSUB/GPOS),
so conjuncts, reordered and split vowel signs render correctly wherever a face is present
(tested: `theme::tests::indic_text_is_shaped_not_drawn_letter_by_letter`). The web build has no
system fonts, so CJK and Indian-script interfaces are not auto-selected there and Indian text
shows as boxes until craft-fonts ships Noto faces for these scripts. There is no bidirectional
system fonts: builds made with craft-fonts (`CRAFT_FONTS_DIR`) embed Noto Sans for the nine
Indian scripts (~5 MB, storytold/craft-fonts#21) as the last face in every chain, so Indian text
renders there too, and the web build follows a browser in an Indian language only when those
faces are embedded. CJK interfaces are still not auto-selected on the web (no CJK face). There is no bidirectional
layout: Arabic and Hebrew runs shape but don't reorder. **Sheet Right-to-Left**
(`view.rightToLeft`, Page Layout › Sheet Options, XLSX `rightToLeft`) mirrors the grid (#146):
column A and the row headers on the right, the vertical scrollbar on the left; hit-testing,
@@ -100,12 +102,13 @@ language (none so far) and of localized function names.
separators in CSV.
3. Script support: shaping is done (epaint/harfrust) and system faces cover CJK, Thai, Hebrew and
the Indian scripts. Left: bidirectional runs, right-to-left sheet tabs and printing, script
faces for the web build (craft-fonts), embedded subset fonts in PDF.
CJK faces for the web build, embedded subset fonts in PDF.
## Revision history
| Date | Change | Summary |
|---|---|---|
| 2026-10-12 | minor | Web build: Indian-script faces from craft-fonts (`CRAFT_FONTS_DIR`); French catalog rebuilt (labels had shifted onto the wrong keys) |
| 2026-10-11 | minor | Ten Indian languages (hi, bn, mr, te, ta, gu, kn, ml, or, pa; 381 labels each), Indian-script system faces on Windows/macOS/Linux/BSD; corrected "no shaping": epaint 0.36 shapes with harfrust. Hindi 12–18 h → 6–10 h; total 95–155 h |
| 2026-10-11 | minor | German ribbon catalog (`i18n/de.rs`, 266 labels, ~12%); `de` locale tags (de-DE, de-AT, de-CH…) resolve to German. PR #163 (localized German formulas/numbers) still open |
| 2026-10-11 | minor | Sheet Right-to-Left mirrors the grid (#146) |
+10
View File
@@ -12,6 +12,16 @@ static site in `gridcraft-web-<version>/`:
There is no server-side code. Upload the folder's contents anywhere that serves static files.
## Fonts
Browsers don't give the app system fonts, so the web build draws only what it embeds: egui's Latin,
Greek and Cyrillic faces, plus, in builds made with craft-fonts (`CRAFT_FONTS_DIR`, set by the
release workflow), Noto Sans for the nine Indian scripts used by the Hindi, Bengali, Marathi,
Telugu, Tamil, Gujarati, Kannada, Malayalam, Odia and Punjabi interfaces. Those faces add about
5 MB to the `.wasm` (31.7 MB instead of 26.6 MB before optimisation; 10.4 MB gzipped). Chinese,
Japanese and Korean text has no face on the web yet, so the app doesn't switch to those interfaces
from the browser's language.
## Any path works
All URLs in `index.html` are relative (`public_url = "./"` in `apps/gridcraft-web/Trunk.toml`),