fix: preserve resolved text weights through a typography token - #42
Merged
Conversation
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.
A text node whose segments share a typography token can still override the weight per run. Both text emitters suppressed
fontWeightwhenever a token was present, so alternating 400/700 runs came out uniform - and since missing bold changes glyph advances, a lost weight became a layout defect: one 36px line wrapped where the design does not wrap, and every section below inherited the displacement.Measured on
aboutagainst Figma's reference PNG, paired against a baseline built frommain, identical theme hash67d6de70e679on both sides:The 37px overshoot at both wider widths collapses to 1px.
landing,popup,gridandkeyframesare unchanged. Mobile's +0.02pp is the cost of correct bold runs and is left in the record rather than smoothed away.Segment-sourced weights are attributed to
styledTextSegmentsin the source map; explicit node weights keep their node-property mapping, so the provenance says which one supplied the number.Korean keeps
word-break: keep-allThe worker also implemented removing the Korean
keep-allheuristic. Figma breaks Korean within words, so deleting it measurably narrows the gap - 7.46% to 7.25% at 360, 4.06% to 3.98% at 992.It is not shipped, by the owner's decision. It buys 0.21pp on one screen by chopping every Korean word in every generated screen, and it breaks 38 attributes across 17 plugin byte-parity goldens. Figma's Korean line breaking is a limitation to compensate for, not a specification to reproduce - the same call the plugin makes deliberately in its own text renderer:
korean_characters_keep_words_wholelocks it so a later fidelity pass cannot quietly reverse it, with the reasoning recorded onsegments_contain_korean. Keeping it is also what holds 16 of the 17 goldens at parity: one golden changes here, for a segment that explicitly carries weight 400.On the numbers
thresholds.jsonis deliberately unchanged. The harness does not reproduce absolute figures across sessions - the same commit and binary producedaboutthemed3137cabf5a5/11.24% in one session and67d6de70e679/7.44% in another, and isolating each group into a fresh acquisition process does not fix it. Only the paired delta is trustworthy, so lowering an entry would assert a reproducibility that does not exist yet. Harness determinism is tracked separately;docs/about-vertical-geometry.mdrecords the evidence.Both the worker and I measured this independently and reached identical figures to the decimal.
Gates:
fmt0,clippy --locked --workspace --all-targets --all-features -D warnings0,cargo test --workspace1059 passed / 0 failed / 2 ignored,insta --checkno drift,stdio_smoke2 passed.