Commit Graph
3 Commits
Author SHA1 Message Date
Behdad Esfahbod c85b453e90 [util/gpu] Web demos: URL ?text= and ?font=; wider default font
Two user-visible features plus a font swap.

### URL parameters

Forwards ?text= and ?font= from the query string into the C main
as --text=... and --font=... via Module.arguments, so the initial
text is applied before the first rendered frame (no flash of
default demo text).  ?font= is still fetched asynchronously on
the JS side; once loaded, the text is re-applied to the new font.

If neither parameter is present, behaviour is unchanged: the
baked-in default text renders in the baked-in default font.

Data URLs (?font=data:font/ttf;base64,...) work naturally via
fetch().  Remote URLs need CORS; raw.githubusercontent.com and
jsdelivr both work, github.com/.../raw/... does not.

### Wider default font

The baked-in default-font.hh was a narrow subset that didn't
include uppercase Latin, so `?text=Hello` shaped to .notdef for
H and W.  Re-subset Parastoo-Regular.ttf via hb-subset with:

    --unicodes='U+0020-007E,U+0600-06FF,U+FB50-FDFF,U+FE70-FEFF'

covering printable ASCII plus the Arabic block and the two
Arabic presentation-forms blocks.

Font size:
    source Parastoo-Regular.ttf     109152
    new subset                       49940

Wasm size impact (webgl build, Oz+lto):
    before  443628  181597 gz
    after   466657  196209 gz
    delta   +23029  +14612 gz

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 17:03:53 -06:00
Behdad EsfahbodandClaude Opus 4.6 62166176c3 [gpu] Subset default font to demo texts; adaptive line count
Replace the embedded default font with Parastoo-Regular subsetted
to just the characters in the English and Persian demo texts (28K).

Adaptive line count: 70 total lines divided equally among
supported scripts.  A Latin-only font gets 70 lines of English;
a Latin+Arabic font gets 35 of each.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 12:29:49 -06:00
Behdad EsfahbodandClaude Opus 4.6 d07b1fbbb2 [gpu] Commit demo generated headers; remove stringize/hexify dependency
Pre-generate demo shader headers, default text, and default font
so the demo builds without stringize or hexify at compile time.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 23:48:28 -06:00