Gate on families, not faces
Branch review 4 on #83 found a fourth face the gate's list missed. A bold Caveat run is drawn in Caveat Bold, but its <span class="docs-font-caveat"> is an inline box in Caveat Regular, and that box sets the line's height. With Caveat Regular eight seconds late, visible text moved in Chromium and WebKit, with the editor present and without it. After a space-only run and a block's strut, the class is the bug: the gate guessed which faces would draw. It no longer guesses. export.FamiliesUsed is every family the document references anywhere: the default, a font mark on any run, wrapper or line break, and code's if any run is code. The page gate waits for every style of each before the reveal. The faces that draw the most text are still preloaded first, up to the cap. The editor waits for every style of every family in its log, and pastes and collaborators' changes wait for every style of every family in use. Code is added when a change or paste carries a code mark. A family still missing at the deadline is committed before anything is shown. After the reveal, a family on screen is never committed. Cost, measured on the committed woff2: a plain Carlito page waits for 796,164 bytes before its first reveal, all four styles, instead of 190,256 (Regular only), so 605,908 more. That is once, since the files are cached as immutable. A page in Carlito, Caladea and code waits for 1.41 MB. Tests, each failing first: - The engines check gains review 4's case, bold Caveat with Caveat Regular eight seconds late, with the editor and without. It failed in both engines with the reviewer's numbers (Chromium 1667.5 to 1607.5px, WebKit 1719 to 1618.75px) and passes now. - TestFontTheGateCoversEveryFaceTheDocumentUses generates 40 random documents from every mark, wrapper and block the schema allows (fixtures/generate-random-docs.mjs, seeded). It holds the gate's families equal to those the DOM computes on every element and text node, and every face the DOM draws in to one the gate waited for. It found 144 uncovered faces on 66662d3 and none now. - TestFamiliesUsedCountsEveryFamilyReferenced covers the Go side. Three older checks moved to the new rule. A Bold that misses the deadline now commits its family before the reveal, so nothing on screen ever changes face. Two slowdowns are shortened, because this test server is HTTP/1.1 and twelve held files would take all six of its connections, the gate's own script included. Production serves HTTP/2. fixtures/vectors/font-stacks.json is now the native branch's version (4acce21), checked out file-only rather than merged, which adds its eight "nested" cases. The nested-paste browser test pastes each case through the real paste handler, and removing the clearMark rule fails four of them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
16 files changed,
+498
−127
AGENTS.md+16 −5fixtures/editor-entry.js+19 −35fixtures/engines/first-reveal.mjs+4 −0fixtures/font-session.mjs+9 −24fixtures/generate-fragment.mjs+14 −1fixtures/generate-random-docs.mjs+100 −0fixtures/vectors/font-stacks.json+43 −0fixtures/vectors/fragment/inline.binbinaryinternal/docs/fontgate.go+13 −11internal/docs/fontgate_test.go+36 −20internal/docs/fonts_browser_test.go+178 −18internal/docs/fonts_engines_browser_test.go+1 −1internal/docs/static/{editor.34b4e027d49157cc.js => editor.2ef9718cfc019d1b.js}+11 −11internal/docs/static/{fontsgate.8b2e482789ed960d.js => fontsgate.6c5e7562118191ca.js}+1 −1internal/export/pdf.go+31 −0internal/export/pdf_test.go+22 −0
CI passed — run details
Intent
AGENTS.mdLoading diff…
fixtures/editor-entry.jsLoading diff…
fixtures/engines/first-reveal.mjsLoading diff…
fixtures/font-session.mjsLoading diff…
fixtures/generate-fragment.mjsLoading diff…
fixtures/generate-random-docs.mjsLoading diff…
fixtures/vectors/font-stacks.jsonLoading diff…
fixtures/vectors/fragment/inline.binLoading diff…
internal/docs/fontgate.goLoading diff…
internal/docs/fontgate_test.goLoading diff…
internal/docs/fonts_browser_test.goLoading diff…
internal/docs/fonts_engines_browser_test.goLoading diff…
internal/docs/static/{editor.34b4e027d49157cc.js => editor.2ef9718cfc019d1b.js}Loading diff…
internal/docs/static/{fontsgate.8b2e482789ed960d.js => fontsgate.6c5e7562118191ca.js}Loading diff…
internal/export/pdf.goLoading diff…
internal/export/pdf_test.goLoading diff…