oficina / docs Public

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>
Paul Campbell pushed by paul@keymail.dev a8a9f3e3dd88e5c1743e086f91133a587eefc19a parent c6f351b
14 files changed, +398 −18
  • AGENTS.md +12 −0
  • fixtures/editor-entry.js +24 −3
  • fixtures/engines/first-reveal.mjs +94 −0
  • fixtures/engines/package-lock.json +71 −0
  • fixtures/engines/package.json +10 −0
  • fixtures/fonts-gate.mjs +3 −1
  • fixtures/fonts.mjs +30 −0
  • fixtures/fonts.test.mjs +9 −0
  • fixtures/vectors/font-stacks.json +23 −0
  • internal/docs/export_test.go +2 −1
  • internal/docs/fonts_browser_test.go +33 −0
  • internal/docs/fonts_engines_browser_test.go +74 −0
  • internal/docs/static/{editor.4219d9105bad1f40.js => editor.03dea77e8c83cf70.js} +12 −12
  • internal/docs/static/{fontsgate.9a16ac7a9212a75b.js => fontsgate.8b2e482789ed960d.js} +1 −1

CI passed — run details

AGENTS.md

Loading diff…

fixtures/editor-entry.js

Loading diff…

fixtures/engines/first-reveal.mjs

Loading diff…

fixtures/engines/package-lock.json

Loading diff…

fixtures/engines/package.json

Loading diff…

fixtures/fonts-gate.mjs

Loading diff…

fixtures/fonts.mjs

Loading diff…

fixtures/fonts.test.mjs

Loading diff…

fixtures/vectors/font-stacks.json

Loading diff…

internal/docs/export_test.go

Loading diff…

internal/docs/fonts_browser_test.go

Loading diff…

internal/docs/fonts_engines_browser_test.go

Loading diff…

internal/docs/static/{editor.4219d9105bad1f40.js => editor.03dea77e8c83cf70.js}

Loading diff…

internal/docs/static/{fontsgate.9a16ac7a9212a75b.js => fontsgate.8b2e482789ed960d.js}

Loading diff…