Keep the first layout when nothing held the page; paste font stacks as native does
Re-review of c6f351b (#83), P1: with fontshold.js missing, the sheet was visible from the first paint, and an editor arriving three seconds later drew six page boundaries over text a reader was already looking at. This happened in Chromium and WebKit alike. The editor now freezes pagination if the sheet is already in view when it could first paginate, and so does the gate when it finds no hold. A view the person chooses still unfreezes it. TestFontEnginesFirstRevealIsTheFinalLayout runs four cases through Playwright, in Chromium and in WebKit, against the production middleware, using fixtures/engines with pinned playwright and pngjs: nothing missing; no hold and a late editor (the reviewer's exact case); no gate and a late editor; and an editor past the layout deadline. Each loads a long paged document and captures the sheet about every 50 ms. From the first capture with text on it, the pixels, page gaps and sheet height must never change. On c6f351b it failed in both engines on the no-hold case: WebKit went from 0 gaps and 5566px to 6 gaps and 5998px. The native branch review asked the web to paste font names as the native app does. fonts.mjs familyForStack reads a pasted font-family stack in order, and the first name that maps wins. A name maps by Docs' private name, then the Word name (Calibri is Carlito, Cambria is Caladea), then the family's own name, then a name in a family's fallback stack, in picker order. Georgia, "Times New Roman", serif is Caladea. Anything else is the default, Carlito, with no mark. The rule reads fonts.json's existing fields, the ones the native resolver reads, so the shared files do not change. The cases both sides can test are in fixtures/vectors/font-stacks.json. The schema reads each pasted run's font-family through the rule. TestFontAPastedFontStackMapsLikeTheNativeApp and the fonts.test.mjs case failed first, the latter under the native app's earlier two-pass rule.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
14 files changed,
+398
−18
AGENTS.md+12 −0fixtures/editor-entry.js+24 −3fixtures/engines/first-reveal.mjs+94 −0fixtures/engines/package-lock.json+71 −0fixtures/engines/package.json+10 −0fixtures/fonts-gate.mjs+3 −1fixtures/fonts.mjs+30 −0fixtures/fonts.test.mjs+9 −0fixtures/vectors/font-stacks.json+23 −0internal/docs/export_test.go+2 −1internal/docs/fonts_browser_test.go+33 −0internal/docs/fonts_engines_browser_test.go+74 −0internal/docs/static/{editor.4219d9105bad1f40.js => editor.03dea77e8c83cf70.js}+12 −12internal/docs/static/{fontsgate.9a16ac7a9212a75b.js => fontsgate.8b2e482789ed960d.js}+1 −1
CI passed — run details
Intent
AGENTS.mdLoading diff…
fixtures/editor-entry.jsLoading diff…
fixtures/engines/first-reveal.mjsLoading diff…
fixtures/engines/package-lock.jsonLoading diff…
fixtures/engines/package.jsonLoading diff…
fixtures/fonts-gate.mjsLoading diff…
fixtures/fonts.mjsLoading diff…
fixtures/fonts.test.mjsLoading diff…
fixtures/vectors/font-stacks.jsonLoading diff…
internal/docs/export_test.goLoading diff…
internal/docs/fonts_browser_test.goLoading diff…
internal/docs/fonts_engines_browser_test.goLoading diff…
internal/docs/static/{editor.4219d9105bad1f40.js => editor.03dea77e8c83cf70.js}Loading diff…
internal/docs/static/{fontsgate.9a16ac7a9212a75b.js => fontsgate.8b2e482789ed960d.js}Loading diff…