Skip to content

SVG: read the CSS font-size keywords - #2179

Merged
andersonhc merged 4 commits into
py-pdf:masterfrom
RavSinghChandan:svg-font-size-keywords
Nov 13, 2026
Merged

andersonhc merged 4 commits into
py-pdf:masterfrom
RavSinghChandan:svg-font-size-keywords

Conversation

@RavSinghChandan

Copy link
Copy Markdown

font-size="large", "x-small", "larger" or "smaller" fails with ValueError: Unable to parse 'large' as a length.

The absolute keywords now use the CSS Fonts scale around medium (16px): large is 6/5 of it and x-small 3/4. larger and smaller scale the inherited size by 1.2, as browsers do. This happens in _resolve_relative_font_size(), next to em, ex and %, so descendants inherit the computed size.

test_svg_font_size_keywords covers absolute keywords in an attribute and a style, larger, smaller, and em inside a keyword; all fail without the change.

font-size="large", "x-small", "larger" or "smaller" failed with
ValueError: Unable to parse 'large' as a length. The absolute keywords
now use the CSS Fonts scale around medium (16px), and larger and
smaller scale the inherited size by 1.2, in
_resolve_relative_font_size(), so descendants inherit the result.
# Conflicts:
#	CHANGELOG.md
# Conflicts:
#	CHANGELOG.md
@andersonhc
andersonhc merged commit 9af4eaf into py-pdf:master Nov 13, 2026
23 checks passed
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.

2 participants