Skip to content

Typst: resolve CSS generic font families to an installed font - #14986

Open
gordonwoodhull wants to merge 1 commit into
mainfrom
feature/typst-generic-font-stacks
Open

gordonwoodhull wants to merge 1 commit into
mainfrom
feature/typst-generic-font-stacks

Conversation

@gordonwoodhull

Copy link
Copy Markdown
Member

Typst has no generic font families, but typst_css.lua passed serif, sans-serif, monospace and the rest straight through. Any font-family list or brand typography that used one made Typst warn unknown font family: sans-serif on every compile, and Typst then fell back to whatever it liked. system-ui and the ui-* keywords weren't recognized at all, so they were treated as font names. This is the system-ui stack that gt tables emit (#11683).

Each generic keyword is now replaced, at its position in the list, by the first installed font from an ordered candidate list. The lists are built from Chromium's per-OS defaults, fontconfig's 60-latin.conf, Modern Font Stacks and Bootstrap's stacks, with Typst's bundled fonts last so serif, monospace and math always resolve. The keyword itself is never emitted: font-family: Roboto, sans-serif becomes Roboto if it's installed, and otherwise the first installed sans-serif candidate. The candidate lists live in typst_css.lua, with their sources cited. No fonts are bundled.

When nothing in a generic's list is installed (realistically sans-serif on a bare Linux box), the keyword is dropped. If that leaves the list empty, we use Typst's default text font, because Typst rejects an empty font: (). generic(...) is dropped, since Typst has no equivalent.

The winning font differs per machine, so the smoke-all fixtures assert only that a concrete family is emitted and that no generic keyword reaches the .typ. font-filtering-generics previously asserted that the keyword was preserved, which is the behavior this changes.

This is a backport of quarto-dev/q2#788.

This replaces #11918, which mapped each generic to one fixed font and bundled Noto Sans, and #14592, which dropped generics from the list but still warned when a list contained only generics.

Fixes #11683.

Typst has no generic font families, but typst_css.lua passed `serif`,
`sans-serif`, `monospace` and friends straight through, so every compile
warned `unknown font family`. `system-ui` and the `ui-*` keywords were not
recognized at all.

Replace each generic keyword, at its position in the list, with the first
available font from an ordered candidate list built from Chromium's per-OS
defaults, fontconfig's 60-latin.conf, Modern Font Stacks and Bootstrap's
stacks, ending in Typst's bundled fonts so serif, monospace and math always
resolve. The keyword is never emitted. If nothing resolves, the keyword is
dropped, and an otherwise empty list falls back to Typst's default text
font, since Typst rejects an empty font list. No fonts are bundled.

Fixes #11683.

Replaces #11918 and #14592.
@posit-snyk-bot

posit-snyk-bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

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.

font issue in typst tables with gt with strings containing numbers and letters

2 participants