Commit Graph
4 Commits
Author SHA1 Message Date
dotCooCoo 1f64044f1c Web: Korean and Hindi interface text draws with real glyphs
The web build had no face for Hangul or Devanagari, so a Korean or Hindi
interface, and a layer or file name in either script, drew as
missing-glyph boxes.

- crates/text/web-fonts.txt gains a `demand` kind: NanumGothic Regular
  and Noto Sans Devanagari Regular are served beside the wasm like the
  other web faces, and fetched only when the interface language or the
  interface's own text needs their script. They are not fetched at
  startup or in the background queue.
- The interface reports the characters no loaded font covers
  (`on_missing_glyphs`), and keeps them so that they are looked for again
  when the font database changes. The frame after a face arrives adds it
  to the interface fonts, and the frame after that draws the characters
  painted before it with that face.
- After a failed fetch the next try comes about 30 seconds later, and the
  wait doubles after each further failure, for at most five tries.
- A new test checks that the two faces cover every Hangul and Devanagari
  character the catalogs use, where craft-fonts has them.

Docs: gaps.md, localization-hi.md, localization-parity.md,
target-app-parity.md.
2026-11-13 05:45:25 -08:00
Dylan M. Taylor c9d73ece85 fix(fonts): confine craft-fonts manifest paths and publish licences as text 2026-11-03 23:29:43 +07:00
Ahmed Moussa 3e20c2cf29 build(web): copy web fonts with cargo xtask, not sh
Replace the Trunk post_build hook packaging/web/copy-fonts.sh with `cargo xtask web-fonts` (xtask/src/web_fonts.rs), so the web build only needs trunk, the wasm32 target and cargo, with no POSIX shell, and works the same on Windows.

The new task reuses crates/text/build/web_fonts.rs for list parsing and URLs, so build.rs and the copier can't disagree on fonts/<sha16>/<file>. It still does nothing without CRAFT_FONTS_DIR, checks each file's SHA-256 against the manifest, and copies the licence next to each face. A listed face that an older craft-fonts checkout lacks is now skipped with a warning, as build.rs does, instead of failing the build. A relative CRAFT_FONTS_DIR is resolved from the workspace root.

Update the references in Trunk.toml, fonts.rs, build.rs, craft_fonts.rs and web-fonts.txt, and document the web build's requirements in docs/development.md. Add tests for the copy, a hash mismatch and the no-op case.

Signed-off-by: Ahmed Moussa <moussa.ahmed95@gmail.com>
2026-10-09 17:18:54 +03:00
Ahmed Moussa 3c85f3f9e3 feat(text): load craft-fonts' Arabic families, fetch them on web
Desktop builds made with CRAFT_FONTS_DIR now load craft-fonts' 12 Arabic families into the document font database. Noto Sans Arabic comes first and is the fallback for Arabic text. Cairo, Tajawal, Almarai, IBM Plex Sans Arabic, Noto Kufi Arabic, Amiri, Alexandria, Fustat, Reem Kufi, Aref Ruqaa and Gulzar can be picked by name from the font menus.

The web build doesn't embed these fonts because they would make the wasm too large. It fetches them from beside the wasm instead:
- crates/text/web-fonts.txt lists each face as startup or background.
- build.rs turns that list into vectorcraft_text::WEB_FONTS, with each face's URL (fonts/<sha16>/<file>) and SRI hash taken from the craft-fonts manifest.
- packaging/web/copy-fonts.sh, a Trunk post_build hook, copies the font files and their OFL licences there.
- apps/vectorcraft-web/src/fonts.rs fetches Noto Sans Arabic before the app starts, so Arabic text never shows as boxes. It loads the other faces in the background and logs `web font …` for any that fail.

Because fonts can now arrive after startup, the Type tool's layout cache also checks the font database's generation, so text lays out again when new fonts arrive.

_headers and .htaccess serve fonts/* as font/ttf and cache it as immutable. packaging/web/README.md and docs/development.md explain the fonts folder, and ROADMAP.md lists the Arabic typefaces under Type. Also adds Ahmed Moussa to contributors/people.toml.

Signed-off-by: Ahmed Moussa <moussa.ahmed95@gmail.com>
2026-10-09 16:09:34 +03:00