fix(codegen): keep a percentage line advance when the font size is bound to a variable - #58
Merged
owjs3901 merged 1 commit intoSep 14, 2026
Conversation
…und to a variable A pixel advance derived from a resolved size is only true in the mode that resolved it, so the guard refused a PERCENT line height whose font size was variable-bound. The value was representable all along: a Figma PERCENT line height and a CSS percentage line-height both scale with the applied font size, so the ratio is exact under every mode. Unbound sizes keep the pixel conversion and every golden is unchanged. The refusal now fires only when the percentage itself is missing. The theme path is untouched: a typography token records one pair of numbers for all of its uses and still refuses a bound size.
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.
What
validate_line_metricsrefused any TEXT whoselineHeightisPERCENTwhile itsfontSizeis bound to a variable:The guard is right about the danger and wrong about the representation.
Right: a pixel advance derived from a resolved size is only true in the mode that resolved it. Emitting
lineHeight="27px"for a size that a variable can change publishes a number that silently stops matching.Wrong: the value was representable all along. A Figma
PERCENTline height and a CSS percentageline-heightmean the same thing — both scale with whatever font size applies. Leaving the ratio alone is exact under every mode, not approximate under one.So
line_heightnow keeps the ratio when the size is bound, andline_height_font_sizeis what decides that: a bound size is withheld from the conversion rather than being trusted as a constant.Scope of the change
generate_devup_jsonstill refuses a bound size, andvariable_font_size_cannot_publish_a_fixed_percentage_advancestill passes: a typography token records one pair of numbers for all of its uses and cannot carry a ratio the way an element can.Evidence
A 1920-wide screen from a design system that binds every type size to a variable. Before: no code at all — the export failed at
projection-and-writewithDEVUP_CODEGEN_FAILED, and so did all three of its separately addressable siblings. After:lineHeight="150%"lineHeight="21px")Tests
integer_line_advance::variable_font_size_keeps_the_percentage_advance_instead_of_a_pixel_one— new; asserts the ratio is emitted and the pixel form is not. Fails before the change.Gates
cargo fmt --all -- --checkcargo clippy --locked --workspace --all-targets --all-features -- -D warningscargo test --workspace --releasevisual_compare::symlink_escape_refused_before_read, which fails identically on an unmodified tree (Windows symlink privilege)