Skip to content

Map the CSS Fonts 4 generic families to core fonts - #2180

Merged
andersonhc merged 3 commits into
py-pdf:masterfrom
RavSinghChandan:css-generic-font-families
Nov 13, 2026
Merged

andersonhc merged 3 commits into
py-pdf:masterfrom
RavSinghChandan:css-generic-font-families

Conversation

@RavSinghChandan

Copy link
Copy Markdown

font-family="system-ui" fails with KeyError: No suitable font for family='system-ui'. The social preview image public/og.svg of react-window uses it, as do bvaughn's other libraries.

sans-serif, serif and monospace are already in FONT_FAMILY_ALIASES. This adds the generic families that CSS Fonts 4 introduced: system-ui, ui-sans-serif and ui-rounded to helvetica, ui-serif to times, and ui-monospace to courier. It applies to SVG text and write_html(), which both use resolve_font_family().

test_resolve_font_family_css_generic_families covers the five families; all fail without the change.

font-family="system-ui", as in react-window's public/og.svg, failed
with KeyError: No suitable font. system-ui, ui-sans-serif and
ui-rounded now map to helvetica, ui-serif to times and ui-monospace to
courier, as sans-serif, serif and monospace already do.
# Conflicts:
#	CHANGELOG.md
@andersonhc
andersonhc merged commit a5e13f2 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