fix(typst): drop CSS generic font families from font-family lists#14592
Draft
cderv wants to merge 1 commit into
Draft
fix(typst): drop CSS generic font families from font-family lists#14592cderv wants to merge 1 commit into
cderv wants to merge 1 commit into
Conversation
#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.
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
4 tasks
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.
Follow-up to #14580, which filtered unavailable named fonts from CSS
font-familylists 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 familyon 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 stackSegoe UI, Roboto, Arial, sans-serif, …, which warns onsans-serifeven though every named font resolves.Root Cause
The whitelist kept generics precisely because they don't appear in
typst fontsoutput — 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_liststill 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-genericssmoke test: generics absent from.typ, no warningcss-properties/font-family: emits("Georgia",), noseriftypst-css.test.luapass, including 3 new filtering casesRelated to #12556