Skip to content

test: measure the multi-mode font preload instead of arguing it - #169

Merged
awdr74100 merged 1 commit into
mainfrom
docs/preload-measured-multimode
Aug 22, 2026
Merged

test: measure the multi-mode font preload instead of arguing it#169
awdr74100 merged 1 commit into
mainfrom
docs/preload-measured-multimode

Conversation

@awdr74100

Copy link
Copy Markdown
Owner

Follow-up to #168, which shipped the text-style font preload with a hole in its evidence: the
account it was built on caps a variable collection at one mode (in addMode: Limited to 1 modes only), so the multi-mode reasoning was argued rather than observed. The PR said as much. A
multi-mode account is available now, so it was measured.

What the measurement says

tried on a two-mode collection result
fontFamily bound to a variable with Roboto / Lato per mode binds, style resolves to Roboto
same, but the non-default mode names a font nobody has installed still binds
fontFamily and fontStyle both bound, both multi-mode binds, composes to Roboto Bold

The middle row is the useful one: only the face the style actually resolves to has to be
loadable. That makes swallowing a failed preload load-bearing rather than defensive — letting
that failure through would reject a binding Figma accepts. #168's comment offered that as a
plausible reason ("a face this guesses at may simply not exist"); it is now a measured one.

The third row confirms what the family → style chain exists for: the two bindings compose into a
single face, so the intermediate face has to be loaded for the family swap to land before the
style swap runs.

What changed

  • The comment says what was measured instead of what was reasoned.
  • Three tests pin it. Worth noting how the first attempt failed: the multi-mode test asserted a
    family that happened to sit in the first mode, so a mutation narrowing the preload to a
    single mode passed it. Rewritten with a second-mode family that must also be loaded, the
    mutation is caught.
  • The faces are keyed while passing through: with a family binding and no style binding, the
    intermediate and final face are identical, and asking twice was pointless even against a cached
    loadFontAsync.

No behaviour change — the implementation was already right. This replaces an argument with
evidence, and closes the gap the tests had.

… measured

#168 shipped this preload with a hole in its evidence: the account it was built
on caps a collection at one mode, so the multi-mode reasoning was argued rather
than observed, and its comment said so.

Measured now, on a two-mode collection: only the face the style actually
RESOLVES to has to be loadable. A variable whose non-default mode names a font
nobody has installed binds fine — which makes swallowing a failed preload
load-bearing rather than defensive, since letting that failure through would
reject a binding Figma accepts. Also confirmed live: a family and a style
binding compose into one face (Roboto + Bold -> Roboto Bold), which is what the
chain exists to keep loadable at each step.

Three tests pin what was previously only argued. The multi-mode one is written
so narrowing the preload to a single mode fails it — the first attempt asserted
a family that happened to be in the first mode, and a mutation that read only
that mode survived it.

The faces are keyed now too: with a family binding and no style binding the
intermediate and final face are the same, and asking twice was pointless even
against a cached loadFontAsync.
@awdr74100
awdr74100 merged commit 70f2af2 into main Aug 22, 2026
4 checks passed
@awdr74100
awdr74100 deleted the docs/preload-measured-multimode branch August 22, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant