Repository navigation
Description
Since 0.8.122 (#4980) composition scripts start only after web fonts are ready, which fixed measure-after-build layouts for fonts that static markup uses. The gate does not cover a face that only script-built text uses: it forces one layout, then awaits document.fonts.ready, and a face starts loading only when some text already in the DOM requests it. Text created by the composition script requests its face afterwards, so a getBoundingClientRect() taken at script time still sees the fallback font for that face. Which faces are loaded when a script runs therefore depends on what other scenes in the assembled page happen to show statically.
Repro (two files, attached): a local @font-face ("LocalFace", font-display: block, embedded by the compiler as a data URI) that no static text uses. The script sets a title in that face, measures it, centres it from the measurement, registers the timeline, then measures again inside document.fonts.load() and writes both numbers into the frame.
- v0.8.135,
render --workers 1:script-time width 1378.1 status unloaded/after fonts.load width 1056.5 status loaded. The title is centred from the first number, so it sits 161 px off centre in the final frame. - Control: uncomment the one static
<span>in the face and both widths are 1056.5 with statusloadedat script time.
Same mechanism with the compiler-fetched Google face: in a nine-scene project, a script-built block measured correctly only because an unrelated scene's static label happened to use the same weight; a second script-built block whose rows use a different weight measured 4 px short and was centred 2 px off. A handwritten title whose underline is drawn to the measured width rendered the underline 253 px too long and the title 114 px off centre in every render.
Two fixes look possible from the outside:
- Before releasing the scripts, call
load()on every declaredFontFace(Array.from(document.fonts).map((f) => f.load())) under the existing 5 s cap, so the stated guarantee holds for script-built text too. - A lint finding when a composition script calls
getBoundingClientRect/offsetWidth/offsetHeightoutside adocument.fonts.load()/document.fonts.readycallback, with the fix hint to measure inside it and register the timeline at the end (the documented async-build path).
Repro project (index.html, assets/fonts/local-face-700.woff2, package.json, hyperframes.json) and the rendered frame attached. Render log lines come from the page console as surfaced by the CLI.
Attachments: repro-bundle.zip (the four repro files)

Activity
jbernard077 commentedon Oct 6, 2026
A related case from the same project, posted here rather than as a new issue because it is the same shape: an audit that silently skips content under a condition the author cannot see.
contrast-audit.browser.jsprobes text inside adata-layout-allow-occlusionelement withdocument.elementFromPointat a few points of its box and skips the element as intentionally occluded when something else answers. A sub-composition host is a full-frame box, so any host that comes later in the DOM and is visible at the sample time answers the probe for every allow-occlusion text block beneath it, even though the host paints nothing there. In the project this removed all eight contrast findings of a block the moment an unrelated small overlay scene was moved into a sub-composition with an overlapping time window. Neitheroverflownorpointer-events: noneon the sub-composition root changes it, because the host element itself takes the hit.Two possible fixes from the outside: probe with
elementsFromPointand ignore hits that are composition hosts or roots with no painted background at that point, so only painted content counts as cover; or treat allow-occlusion as a declaration (skip only the layout occlusion finding) and still measure contrast against the pixels that are actually behind the text. A lint note thatdata-layout-allow-occlusionbelongs on the covering element, not on the text that may be covered, would help too.fix(registry): keep only the flex centring in mk-callout-highlight
fix(registry): centre mk-callout-highlight with flex instead of a scr…
miguel-heygen commentedon Oct 24, 2026
Thanks for the repro bundle. I reproduced it on 0.8.193 with a snapshot at 1.5 s: script time measures 1378.1 px with the face
unloaded,fonts.load()gives 1056.5 px, and the title is centred from the first number. With your static<span>uncommented, both readings are 1056.5 px.The cause is as you describe. Before releasing composition scripts, the runtime forces one layout and waits for
document.fonts.ready(waitForFontsinpackages/core/src/runtime/afterFonts.ts). A face no laid-out text uses yet hasn't started loading, soreadydoesn't wait for it.Until the gate changes, the documented workaround is to measure inside
document.fonts.load()and register the timeline at the end of that callback (added to the docs in #5203). The contrast-audit case from your follow-up comment was fixed separately in #5202.jbernard077 commentedon Oct 24, 2026
Thanks for confirming. The project this came from already measures inside
document.fonts.load()everywhere it needs a width, so the workaround is in use here.For the gate itself, one design that keeps the current behaviour for static text and closes this case: after the forced layout, call
load()on every entry indocument.fontswhose status is stillunloaded, then awaitreadyunder the existing timeout. Faces a page declares but never uses would load once at startup, bounded by the same timeout and warning path. If that is the direction you want, I can open a PR with a core test for the script-only-face case from the repro.miguel-heygen commentedon Oct 25, 2026
Yes, please open that PR; the direction you describe fits. A few pointers so it lands in one round:
waitForFontsinpackages/core/src/runtime/afterFonts.ts. It is the one place every caller of the gate goes through. After the forced layout (void document.body?.offsetHeight), callload()for each entry indocument.fontswhose status is stillunloaded, then keep awaitingfonts.readyunder the existingFONT_WAIT_TIMEOUT_MSrace, so a face that never loads still ends in the existing timeout warning and theruntime_font_wait_timeoutdiagnostic.load()(a missing font file) by letting it fall through to that same timeout path instead of throwing, so one broken face can't stop composition scripts from running.packages/core/src/runtime/entry.afterFonts.test.ts. Please add the script-only-face case from your repro there (a face declared but not used by any laid-out text, measured at script time), and a case where the face fails to load.fix(core): the fonts gate starts loading declared faces no laid-out t…