Warn when requested font variant is missing and report fallback target
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 56.1k
- Forks
- 1.7k
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 22
Description
Description
Currently, Typst issues a warning if a requested font family name does not exist. In Typst, a specific font file corresponds to a tuple of (family-name, weight, style, stretch), which I refer to here as a "font variant".
I propose that Typst should also allow issuing a warning when a specifically requested font variant does not exist, even if the family name itself is found.
Proposed Behavior
Detection: If a user requests a specific font variant (e.g., specific weight or style) that is not available, the compiler should be able to emit a warning.
Detailed Reporting: The warning should ideally specify
-
The requested variant that was missing
-
The actual variant that Typst fell back to
whenever this infomation is available.
Configuration
Since the importance of strict font variant matching varies between different users and projects, this warning should ideally be configurable (e.g., allowed to be toggled on/off or suppressed by the user).
Use Case
This feature would allow users to explicitly understand when and how font fallback occurs. For example, it can help users resolve potential issues in the following two scenarios:
-
Typst Code Typo: If the user accidentally specified a wrong font weight or font style in the code, the warning makes it obvious that the code needs correction.
-
Missing Font Asset: If the code is correct and the specific variant was intended, the warning informs the user that they need to find the corresponding font file for that variant and ensure it is placed in a location Typst can recognize.
Related issue: #2818
Related PR: #3354
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files or tests are named in the issue. Start by reviewing the font variant resolution and warning configuration paths, then read related issue #2818 and PR #3354 for existing context; done should include configurable missing-variant warnings that report both the requested and selected fallback variants when available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100