native icon indicating copy to clipboard operation
native copied to clipboard

Registered CJK fonts render dense glyphs

Open ctate opened this issue 4 months ago • 1 comments

Fixes the reported issue: registered Japanese fonts rendered everyday kanji as notdef blocks — and restores the font registry's own doctrine that validation is loud and registration-time only.

Root cause, measured: the glyph outline budgets were sized from the bundled Latin face's maxp (128 points / 24 contours). Everyday kanji in Noto Sans JP: 鬱 = 237 points/26 contours, 驚 = 185/22, 籠 = 167/22 — every one failed FontGlyphTooComplex per glyph at render time and fell back to blocks.

  • Budgets sized from real CJK faces: maxp read from six production faces (Noto Sans JP/SC/TC/KR, Noto Serif JP, Yuji Mai — table documented at the constants; densest measured: 738 points, 87 contours) → max_glyph_points 1024, max_glyph_contours 128, with the composite budgets unchanged (measured worst is the bundled face's own 3/4). One simpleOutline frame is live at a time (composites recurse only small component-walk frames), so the parse scratch stays ~9.5 KiB stack; the reference glyph path capacity is now derived from the budgets rather than magic.
  • Registration-time maxp gate: Face.parse refuses faces whose declared maxima exceed the budgets, surfaced as a teaching that names the face's numbers against every budget — so a registered id always resolves at render time, and the per-glyph checks remain as commented backstops for under-declaring fonts.
  • Registration byte bound 2 MiB → 24 MiB: the old bound existed precisely to refuse multi-megabyte CJK fonts the pipeline wasn't sized for — a rationale this fix eliminates (Noto Sans SC is 17.8 MB). Cost is reserved address space only, documented in canvas_limits.

Proof: synthetic in-test TrueType builders cover dense simple glyphs at the exact budgets, composites at depth, over-declared refusal (all four maxima), and under-declaring backstops; a /tmp-guarded test registers the real 9.6 MB Noto Sans JP through the runtime and outlines + fills 鬱驚籠鑑 at 16/96 px (self-skips without the OFL download — no font binaries committed). Bundled-face inking is byte-identical: all 263 pinned pixel/hash goldens unchanged. Full battery, validate, examples, ts-core e2e all green.

ctate avatar Jul 17 '26 06:07 ctate

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
native-sdk Ready Ready Preview, Comment Jul 17, 2026 5:59pm

vercel[bot] avatar Jul 17 '26 06:07 vercel[bot]