Files
texturecraft/crates
ff18396f78 Keep the web build under its size gate by subsetting CJK fonts (#803)
* web: cut the CJK interface face to the catalogs' characters

The scheduled Release dry run's Web (wasm) job has failed since 23 Nov 2026:
the wasm is 27,128,780 bytes against the 25,165,824-byte gate in
packaging/web/package.sh, and against Cloudflare's 25 MiB per-file cap.

Parsing the last green artifact puts 7.4 MB of the 24.8 MB module in embedded
fonts, of which the whole Japanese face is 4.67 MB. WordCraft already cuts its
web interface faces to the embedded catalogs (craft-libs' craft-fonts-build
`Embed::subset_to`, with `Embed::for_ui`); this app still embedded the whole
face.

A web build now subsets every face whose manifest script is Hans/Hant/Jpan/Kore
to the characters of the embedded catalogs, plus ASCII, Latin-1 and general
punctuation, and keeps the CJK punctuation block (U+3000-303F) and the kana
blocks (U+3040-30FF) whatever the catalogs say, so Japanese a user types in a
layer or file name still draws. That is craft-libs' precedent minus the
katakana phonetic extensions and the full-width forms, which cost a further
5 KB and are not in the cut. The subsetter is the skera/skrifa pair the Inter
cut already uses. The cut Japanese face is 650,268 bytes instead of 4,669,688,
so the wasm comes back to about 23.1 MB, under the gate with about 2.0 MB to
spare. The desktop build is unchanged and keeps its CJK faces whole.

Trade-off, as in WordCraft: CJK characters outside the catalogs and those
ranges (kanji, full-width forms) fall back to the interface font in the
browser build only.

* ui: drop the catalog builder's unused source-only entry point

cargo xtask ci's clippy leg (--all-targets -- -D warnings) fails the
ui-egui build script on `i18n_build::generate`: since the web font cut,
the build script only calls `embed`, so the wrapper is dead code in that
compilation unit and `-D dead-code` rejects it.

The integration test was its only caller, and it drives `collect`
directly elsewhere, so the tests keep a local `generate` wrapper over
`i18n_build::collect` and the production module stops carrying a function
nothing builds.

* docs: state the web CJK subset's coverage accurately

Han ideographs that are not in the shipped catalogs are omitted from the
web face and render as missing glyphs. Desktop still embeds the full faces.

* style: let cargo fmt order the skera import

The earlier rustfmt pass put the function before the types; cargo fmt
(with this repo's rustfmt.toml) wants Plan and SubsetFlags first.

---------

Co-authored-by: skylartaylor <skylartaylor@users.noreply.github.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
2026-11-28 01:57:32 +01:00
..