You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A way to avoid font-not-found warning if alternative font is found #6010
diagnosticsImprovements to compiler errorsfeature requestNew feature or requesttextRelated to the text category, which is all about text handling, shaping, etc.
I have written a template that uses the CMU fonts. However, on some systems, there is only the alternative Font "New Computer Modern" available and vice versa. Both Fonts are almost the same (at least for Latin characters), so either is a perfectly valid choice for all use-cases I have. Therefore, in my template I have the following code:
set text(
font: (
"CMU Sans Serif",
"New Computer Modern Sans",
),
size: 12pt,
)
Unfortunately, since #2818 this produces the following warning on systems where only one of these font families is installed:
warning: unknown font family: new computer modern sans
┌─ template/foobar.typ:105:10
│
105 │ font: (
│ ╭───────────^
106 │ │ "CMU Sans Serif",
107 │ │ "New Computer Modern Sans",
108 │ │ ),
│ ╰─────^
Maybe I'm following an antipattern here, but I think it'd be great if the warning is only thrown if no valid font (for actually used character sets) is found.
Use Case
Described above.
Reacted by Janosh Riebesell, nleanba, Alex Muirhead, Trebor Huang, Nathan Jessurun, Panda, Elliot Gould, Jeremie Knuesel, Romain Lamothe, Florian Breit and 5 more
changed the title [-]Disable _font not found_ warning if alternative font is found.[/-][+]Disable *font not found* warning if alternative font is found.[/+]on Mar 5, 2025
changed the title [-]Disable *font not found* warning if alternative font is found.[/-][+]Disable font-not-found warning if alternative font is found.[/+]on Mar 5, 2025
also, would be great if the warning could specify which fallback font is being used instead such that users can change to that one to silence the warning
I have a rough feeling that there are two kinds of font fallback.
Fallback for environments: the same document for different browsers, OS’s , machines, etc.
You want to select one available font in a list of similar fonts.
Fallback for graphemes: different languages (or scripts?) in the same document.
Your document contains Latin, Han, and Emoji characters, and you want to combine several completely different fonts to cover them all.
The font fallback mechanism of CSS is mainly/originally designed for the first kind, while that of typst mainly designed for the second kind?
A (not quite usable) workaround: typst compile … --input HOSTNAME=$(hostname).
A possible interface?
#settext(
font: (
(name: "CMU Sans Serif", if-unknown: "ok"),
"New Computer Modern Sans",
(name: "…", if-unknown: "warning"),
),
)
Hi @gasche! I see your discussion in #3854 (comment) and your PR #7272.
I'm replying here, because I think it's a better place for general discussions.
When template authors…
…we should ensure that the choice of behavior covers the common, easy/natural case…
I agree that the current font warning is very unfriendly for template authors who need to fallback for environment, but I want to argue that falling back for graphemes is equally common.
(The two kinds of font fallback was explained above.)
Han (CJ or CJK — I'm not sure)
It is extremely common to use different fonts for Han and Latin characters.
There are thousands of Han characters and font designers spend their main effort on them. As a result, the Latin parts of most Han fonts are provided only for compatibility and poorly designed. Therefore, these Han fonts have to be combined with specialized Latin fonts. The situation is improving these years, but traditional fonts (they're still widely used) remain the same.
SimSun is a well-known Han font in China. The first page of the GitHub search result for lang:typst SimSun is as the following. You can see that falling back for graphemes is indeed common in this scenario.
11 repos fallback only for graphemes
4 repos fallback for both environments and graphemes
4 repos fallback only for environments
1 repo does not use a fallback list
Math
It looks like that show math.equation: set text(font: (A, B, C, …)) always means to fallback for graphemes? For example, using additional fonts for non-Latin texts in math, or using a special math font to cover ∅.
This is a new feature, though.
Another thing to consider: There are far more document authors than template authors.
Those who need to fallback for environments are mainly template authors, while those who need to fallback for graphemes include both.
The behavior of my PR on this font list is to ignore "Times New Roman" because it has a cover restriction, and then emit a warning if none of "SimSun", "Songti SC" or "STSongti" are available. My understanding is that this is a reasonable behavior for the intended use-case.
However, problems on emoji and math fonts are still not covered.
Can you explain a concrete example of emoji or math font that you have in mind? (What does it become as a FontList passed to check_font_list?) My goal with my PR #7272 is not necessarily to fix all issues related to font warnings, I would be happy with a first step that solves only some of the issues, but we should check that there is no regression on common use-cases. So I would be happy for "no worse than before" behavior in those more advanced cases.
on the emoji example, "Noto Color Emoji" will be ignored as it is restricted to a cover, and there will be a warning if all of "Noto Sans", "Twitter Color Emoji" or "Noto Color Emoji" are missing.
on the Math example, "Computer Modern Symbol" will be ignored and you will only get a warning if "New Computer Modern Math" is missing.
In contrast, with the current behavior you will get a warning for each one of the font that is missing (with or without cover), independently of whether the others are available.
My understanding is that #7272 indeed improves the behavior in both of these examples, and in fact it also seems to "do the right thing", to have the reasonable behavior one would expect given the available information.
My understanding is that #7272 indeed improves the behavior in both of these examples, and in fact it also seems to "do the right thing", to have the reasonable behavior one would expect given the available information.
I think the emoji example as presented by @YDX-2147483647 would regress with #7272 as, if I understand correctly, the goal is to use all of Noto Sans (for text), Twitter Color Emoji (for most emoji), and Noto Color Emoji (for chains and Unicode 14 stuff) in the document.
With #7272, e.g. the mere presence of Noto Sans would silence all warnings even if no emoji font is present at all.
@laurmaedje I understand that I was missing something (due to my own lack of knowlege about Emoji fonts). I assumed that given the font snippet given by @YDX-2147483647
#settext(font: (
"Noto Sans",
(name: "Noto Color Emoji", covers: regex("[🔗⛓💥]")),
"Twitter Color Emoji",
"Noto Color Emoji",
))
then it would be the case that "Noto Sans" will be used unconditionally if it is available, for all characters (because it is first in priority list). But in fact, even though there is no cover estriction for that choice, it may be the case that the font does not support all characters, and the Typst engine will go down in the priority list for characters that are missing for that font. (I suppose that "Noto Sans" does not include any emoji characters, and this is why @YDX-2147483647 and you are writing that this font choice will use of the "Emoji" fonts for emoji characters, even if they are lower in the priority order.)
I had missed this aspect and understand why you find the #7272 behavior suboptimal in this case. In a sense, #7272 over-approximates by assuming that each font that is listed without a cover restriction can in fact display all characters. I am not sure how you would propose to lift this restriction; should I try to access the set of characters supported by each font in check_font_list, and warn as soon as one character is supported by none of the proposed fonts?
@gasche Yeah, exactly that's the struggle. It's not specific to emoji fonts either. Typst will always traverse the font list when it fails to render some text with the first font.
Since at the point where the set rule is defined we don't know which characters will be in use, we can't really make a definitive decision there. I fear that we'll need more information from the user, e.g. some sort of dictionary that marks a font as required or optional (similar to the if-unknown: "ok" proposed above; could also be required: true or optional: true or something like that). I'm not sure what the exact best design there is, but something in this direction is the best I see right now.
Since at the point where the set rule is defined we don't know which characters will be in use, we can't really make a definitive decision there.
I thought about warning dynamically, if the list of available font bottoms out during character shaping, but I worry that the change would be significantly more invasive and performance-sensitive.
On the other hand, maybe it would be acceptable to approximate this by saying that we warn if for some characters none of the proposed fonts are available. (Then we can do this "statically", if we know how to query a font for the set of renderable characters, and manipulate those efficiently.) This may result in spurious warnings for some exotic characters that no one supports nor uses in practice, but I wonder if this default strategy would be good enough. (The warning message could possibly be explicit about which characters are un-renderable, and then it would be possible to add an argument to the font list to exclude certain characters from consideration.)
(I am of course happy to support a richer API where authors provide more precise information on their wishes, but this does not solve the ergonomic problem with font selections as they are provided today, where users see many more warnings than intended.)
This PR is somewhat related: #6989. It warns during runtime as well. Some form of this will probably ship, but it indeed needs more care and is more performance sensitive.
On the other hand, maybe it would be acceptable to approximate this by saying that we warn if for some characters none of the proposed fonts are available.
What exactly do you mean by "for some characters"? For some characters in all of Unicode? Because there are so many characters in Unicode that your font list will pretty much never cover all of it. Maybe I'm misunderstanding.
changed the title [-]Disable font-not-found warning if alternative font is found.[/-][+]A way to avoid font-not-found warning if alternative font is found[/+]on Jan 7, 2026
diagnosticsImprovements to compiler errorsfeature requestNew feature or requesttextRelated to the text category, which is all about text handling, shaping, etc.
Activity
[-]Disable _font not found_ warning if alternative font is found.[/-][+]Disable *font not found* warning if alternative font is found.[/+][-]Disable *font not found* warning if alternative font is found.[/-][+]Disable font-not-found warning if alternative font is found.[/+]janosh commentedon Mar 13, 2025
also, would be great if the warning could specify which fallback font is being used instead such that users can change to that one to silence the warning
YDX-2147483647 commentedon Apr 16, 2025
Previous discussions on the Forum
Is it possible to suppress the warning about Noto CJK / Source Han duality? - Questions - Typst Forum
A (not quite usable) workaround:
typst compile … --input HOSTNAME=$(hostname).A possible interface?
YDX-2147483647 commentedon Nov 12, 2025
Hi @gasche! I see your discussion in #3854 (comment) and your PR #7272.
I'm replying here, because I think it's a better place for general discussions.
I agree that the current font warning is very unfriendly for template authors who need to fallback for environment, but I want to argue that falling back for graphemes is equally common.
(The two kinds of font fallback was explained above.)
Han (CJ or CJK — I'm not sure)
It is extremely common to use different fonts for Han and Latin characters.
There are thousands of Han characters and font designers spend their main effort on them. As a result, the Latin parts of most Han fonts are provided only for compatibility and poorly designed. Therefore, these Han fonts have to be combined with specialized Latin fonts. The situation is improving these years, but traditional fonts (they're still widely used) remain the same.
SimSun is a well-known Han font in China. The first page of the GitHub search result for
lang:typst SimSunis as the following. You can see that falling back for graphemes is indeed common in this scenario.Math
It looks like that
show math.equation: set text(font: (A, B, C, …))always means to fallback for graphemes? For example, using additional fonts for non-Latin texts in math, or using a special math font to cover∅.This is a new feature, though.
Another thing to consider: There are far more document authors than template authors.
Those who need to fallback for environments are mainly template authors, while those who need to fallback for graphemes include both.
gasche commentedon Nov 12, 2025
Thanks for the extra information. If we look at one example of usage in the github search:
The behavior of my PR on this font list is to ignore "Times New Roman" because it has a cover restriction, and then emit a warning if none of "SimSun", "Songti SC" or "STSongti" are available. My understanding is that this is a reasonable behavior for the intended use-case.
YDX-2147483647 commentedon Nov 12, 2025
Sorry I didn't read the code carefully and misunderstood
"latin-in-cjk"as unrestricted, because it's a regex that matches anything but 11 special characters…Indeed.
There are two kinds of configurations. One is what you mentioned, and the other one can be changed as follows after your PR.
However, problems on emoji and math fonts are still not covered.
gasche commentedon Nov 12, 2025
Can you explain a concrete example of emoji or math font that you have in mind? (What does it become as a
FontListpassed tocheck_font_list?) My goal with my PR #7272 is not necessarily to fix all issues related to font warnings, I would be happy with a first step that solves only some of the issues, but we should check that there is no regression on common use-cases. So I would be happy for "no worse than before" behavior in those more advanced cases.YDX-2147483647 commentedon Nov 12, 2025
It looks like that
FontListis isomorphic toset text(font: …). I'll use the latter syntax below.Emoji
This is extracted from Setting fonts repeatedly with different
coversis not effective #6566.I think there should be no warning if either Twitter or Noto Color Emoji is installed, but there should be a warning if neither is installed.
Math
This is for the LaTeX look.
Maybe there should be no warning when Computer Modern Symbol is not installed, because it's just a stylistic choice.
Hmm, I feel that the warning control should be more explicit.
gasche commentedon Nov 12, 2025
With the behavior in #7272:
In contrast, with the current behavior you will get a warning for each one of the font that is missing (with or without cover), independently of whether the others are available.
My understanding is that #7272 indeed improves the behavior in both of these examples, and in fact it also seems to "do the right thing", to have the reasonable behavior one would expect given the available information.
laurmaedje commentedon Nov 17, 2025
I think the emoji example as presented by @YDX-2147483647 would regress with #7272 as, if I understand correctly, the goal is to use all of Noto Sans (for text), Twitter Color Emoji (for most emoji), and Noto Color Emoji (for chains and Unicode 14 stuff) in the document.
With #7272, e.g. the mere presence of Noto Sans would silence all warnings even if no emoji font is present at all.
gasche commentedon Nov 19, 2025
@laurmaedje I understand that I was missing something (due to my own lack of knowlege about Emoji fonts). I assumed that given the font snippet given by @YDX-2147483647
then it would be the case that "Noto Sans" will be used unconditionally if it is available, for all characters (because it is first in priority list). But in fact, even though there is no cover estriction for that choice, it may be the case that the font does not support all characters, and the Typst engine will go down in the priority list for characters that are missing for that font. (I suppose that "Noto Sans" does not include any emoji characters, and this is why @YDX-2147483647 and you are writing that this font choice will use of the "Emoji" fonts for emoji characters, even if they are lower in the priority order.)
I had missed this aspect and understand why you find the #7272 behavior suboptimal in this case. In a sense, #7272 over-approximates by assuming that each font that is listed without a cover restriction can in fact display all characters. I am not sure how you would propose to lift this restriction; should I try to access the set of characters supported by each font in
check_font_list, and warn as soon as one character is supported by none of the proposed fonts?laurmaedje commentedon Nov 20, 2025
@gasche Yeah, exactly that's the struggle. It's not specific to emoji fonts either. Typst will always traverse the font list when it fails to render some text with the first font.
Since at the point where the set rule is defined we don't know which characters will be in use, we can't really make a definitive decision there. I fear that we'll need more information from the user, e.g. some sort of dictionary that marks a font as required or optional (similar to the
if-unknown: "ok"proposed above; could also berequired: trueoroptional: trueor something like that). I'm not sure what the exact best design there is, but something in this direction is the best I see right now.gasche commentedon Nov 20, 2025
I thought about warning dynamically, if the list of available font bottoms out during character shaping, but I worry that the change would be significantly more invasive and performance-sensitive.
On the other hand, maybe it would be acceptable to approximate this by saying that we warn if for some characters none of the proposed fonts are available. (Then we can do this "statically", if we know how to query a font for the set of renderable characters, and manipulate those efficiently.) This may result in spurious warnings for some exotic characters that no one supports nor uses in practice, but I wonder if this default strategy would be good enough. (The warning message could possibly be explicit about which characters are un-renderable, and then it would be possible to add an argument to the font list to exclude certain characters from consideration.)
(I am of course happy to support a richer API where authors provide more precise information on their wishes, but this does not solve the ergonomic problem with font selections as they are provided today, where users see many more warnings than intended.)
laurmaedje commentedon Nov 20, 2025
This PR is somewhat related: #6989. It warns during runtime as well. Some form of this will probably ship, but it indeed needs more care and is more performance sensitive.
What exactly do you mean by "for some characters"? For some characters in all of Unicode? Because there are so many characters in Unicode that your font list will pretty much never cover all of it. Maybe I'm misunderstanding.
[-]Disable font-not-found warning if alternative font is found.[/-][+]A way to avoid font-not-found warning if alternative font is found[/+]feat: add new explicit `use-arial` option
foxyseta commentedon May 12, 2026
Since #7272 has been closed, does it mean that more discussion is needed within this issue before opening a new PR?