Is it possible to suppress the warning about Noto CJK / Source Han duality?

Source Han and Noto CJK are the same typeface released separately by Adobe and Google.

My friend and I are collaborating on a document. I installed Source Han, and my friend installed Noto CJK. We use the following configuration.

let font = ("Noto Serif CJK SC", "Source Han Serif")
set text(font: font, lang: "zh", region: "CN")

Although it generates the expected PDF, both of us get either of the following warnings.

warning: unknown font family: noto serif cjk sc
warning: unknown font family: source han serif

Is it possible to suppress the warning or circumvent it in typst v0.12.0?

OK, I will just let the warning go…

Is it a possibility for your friend to modify the source, or the environment? You can use, for example,

let force-noto = false  // if you need to modify the source code instead

let font = if force-noto or lower(sys.inputs.at("USE_NOTO", default: "0")) in ("1", "true") {
   ("Noto Serif CJK SC",)
} else {
   ("Source Han Serif",)
}

set text(font: font, lang: "zh", region: "CN")

then, by default, Typst will try to use Source Han Serif, but if you compile with

typst c file.typ --input USE_NOTO=1

(or if you change force-noto to true in the source code), then it will use Noto Serif CJK SC.

This would be an ideal use case for warning suppression, but unfortunately that feature had to be de-prioritized as it will need further design discussion.

In addition, I recommend you open an issue with your case to see if anything could be changed in the compiler for that matter. You can do so in the compiler’s repository: GitHub - typst/typst: A new markup-based typesetting system that is powerful and easy to learn.

1 Like

Thank you! That is a feasible solution. I will try to use --input ZH_CN_FONT="Source Han Serif".

(I don’t think the problem is clear enough to be created as an issue, and that is why I posted it here.)

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.
  • Fallback for graphemes: different languages (or scripts?) in the same document.

The font fallback mechanism of CSS is mainly/originally designed for the first kind, while that of typst mainly designed for the second kind?

1 Like

Could it not perhaps be made dependent on the hostname or the username?

It looks like that typst will never let the document access any system info directly? I think currently the only way is to pass them through --input.

The maintainer laurmaedje once answered my question on security:

…we take the safety of just compiling a Typst file very seriously. Features that would compromise safety (like writing files, shell escape, even reading files outside of the working/project directory, etc.) won’t be accepted into the Typst compiler.

Sorry, I was not clear enough. You pass something like

–input HOSTNAME=$(hostname)

and then inside the document you select the font depending on what the variable has. So you can use the same document with the same call on both computers.

1 Like