Repository navigation
fix(css): parse the font shorthand - #406
Merged
Merged
Conversation
CSS Fonts 4 section 2.7: [ style || variant || weight || width ]? size [ / line-height ]? family#. The shorthand expands, at declaration parse time, to font-style, font-weight, font-size, line-height and font-family, resetting the first, second and fourth to normal when omitted. font-variant and font-width are accepted and dropped. A value without size and family, a system-font keyword, a CSS-wide keyword or var() expands to nothing, as before. Closes #404 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Refs #398 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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
The
fontshorthand had no handler, sofont: 32px/40px V, serifwas dropped whole (size, line height, weight, style and family, including an@font-facefamily).Spec opened: CSS Fonts 4 section 2.7 (the
fontshorthand): grammar[ [ <font-style> || <font-variant-css2> || <font-weight> || <font-width-css3> ]? <font-size> [ / <line-height> ]? <font-family># ]; longhands are first reset to their initial values; font-size and family are required; system keywords only as the whole value.ParseDeclarationsexpands it to the five longhands the engine models (style, weight and line-height reset tonormalwhen omitted). Variant and width keywords are accepted and dropped (no model). Invalid values, system-font keywords, CSS-wide keywords andvar()expand to nothing, as before. Expansion at parse time keeps the cascade passes (size first, then family/weight/style) untouched, and a later longhand still wins.Evidence
css.TestFontShorthandExpansion,css.TestFontShorthandCascade,engine.TestVariableFontViaFontShorthand. The new file is 100 percent covered.font: 32px V, serifrenders pixel-identical to the longhand version (0 differing pixels) and shows the same per-weight ink progression as Chrome.fonttakes the new branch (one string compare per declaration otherwise). Timings are deferred: 1-minute load was 48.Closes #404
Co-Authored-By: Claude Sonnet 5.5 noreply@anthropic.com
🤖 Generated with Claude Code