test: measure the multi-mode font preload instead of arguing it - #169
Merged
Conversation
… 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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. Amulti-mode account is available now, so it was measured.
What the measurement says
fontFamilybound to a variable withRoboto/Latoper modeRobotofontFamilyandfontStyleboth bound, both multi-modeRoboto BoldThe 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
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.
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.