Skip to content

fix(typst): drop CSS generic font families from font-family lists#14592

Draft
cderv wants to merge 1 commit into
mainfrom
fix/typst-strip-generic-font-families
Draft

fix(typst): drop CSS generic font families from font-family lists#14592
cderv wants to merge 1 commit into
mainfrom
fix/typst-strip-generic-font-families

Conversation

@cderv

@cderv cderv commented Jun 15, 2026

Copy link
Copy Markdown
Member

Follow-up to #14580, which filtered unavailable named fonts from CSS font-family lists but whitelisted CSS generic families (serif, sans-serif, monospace, …) on the assumption Typst accepts them as fallback specifiers.

Typst has no concept of generic families and warns unknown font family on each one, so the warning #14580 set out to remove still fired for any list containing a generic — for example a gt table's system stack Segoe UI, Roboto, Arial, sans-serif, …, which warns on sans-serif even though every named font resolves.

Root Cause

The whitelist kept generics precisely because they don't appear in typst fonts output — but a token that isn't a real Typst font is exactly what Typst warns about, so keeping it guaranteed the warning.

Fix

Drop generic families from the translated list instead of whitelisting them. When a real font remains, the generic was dead weight: Typst renders with the real font and covers missing glyphs via its own fallback regardless, so the output is identical minus the warning (verified against the bundled Typst 0.14.2).

The existing all-filtered fallback in translate_font_family_list still re-emits the original list when no real font remains, so an empty (illegal) font tuple is never produced — the generic-only case still warns but compiles. Mapping generics to real fonts (#11918) would close that remaining case and is left as separate work.

Test Plan

  • font-filtering-generics smoke test: generics absent from .typ, no warning
  • feature-format-matrix css-properties/font-family: emits ("Georgia",), no serif
  • Lua unit tests in typst-css.test.lua pass, including 3 new filtering cases
  • Existing typst brand-yaml smoke suite passes (no regression)

Related to #12556

#14580 filtered unavailable named fonts from CSS font-family lists but
whitelisted CSS generic families (sans-serif, serif, ...) on the
assumption Typst accepts them as valid fallback specifiers. Typst has no
concept of generic families and warns "unknown font family" on each one,
so the warning #12556 set out to remove still fired for any list
containing a generic — e.g. a gt table's system-ui stack
(Segoe UI, Roboto, Arial, sans-serif, ...).

Generics are dead weight in Typst output: when a real font remains in
the list, Typst uses it and covers missing glyphs via its own fallback
regardless, so dropping the generic renders identically with no warning.
The existing all-filtered fallback still re-emits the original list when
nothing real remains, avoiding Typst's hard error on an empty font tuple
— the generic-only case still warns but compiles. Mapping generics to
real fonts (#11918) is the complete fix, tracked
separately.
@posit-snyk-bot

posit-snyk-bot commented Jun 15, 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.

2 participants