What fonts are available everywhere?

I’ve created a template that I’d like to publish to the typst package repo. The issue is, it uses custom fonts that I downloaded from Google Fonts. It works well but I don’t know how I’d publish the template as is.

I want a user of my template to be able to use it on both the web app and locally (on say macOS) without having to download fonts separately.

This previous question says it’s not ok to add fonts to the package itself so the package remains small. Fair enough, but that means that such a package would feel broken if it’s used in the web app when it switches to a default font. I would much rather make a conscious choice of font based on what’s available.

Alternatively I could rewrite the template to use fonts that are common across all platforms, including the web app. This answer suggests reading the autocomplete UI in the web app for the list of fonts. Problem is, I don’t know how to retrieve the list of fonts offered by the web app so I can compare with the list of fonts I have on my laptop.

So I guess my question is - is there a list of “lowest common denominator” fonts that are available everywhere? For example, I’d be ok with “Noto Sans”, but that’s not available on macOS (“warning: unknown font family: noto sans”). Or “Helvetica”, available on macOS but not the web app.

If such a list doesn’t exist or is too small, is there a way to publish a template with a few custom fonts?

Well, it was already mentioned in answer you mentioned. The only fonts that are guaranteed to be always available are the fonts Typst embeds into itself. Otherwise, I guess, there can always be some crazy Linux distributive with one obscure font available by default.

The list of embed fonts is very short:

Locally, Typst uses your installed system fonts or embedded fonts in the CLI, which are Libertinus Serif , New Computer Modern , New Computer Modern Math , and DejaVu Sans Mono .

(From docs about text function)

I would recommend putting a big link at start of Readme like “First, download the font here for better experience”. That is probably the best option we have for now.

Putting fonts in the package is not possible not because it would bloat its size, but just because the fonts will probably not work. Typst cli reads fonts only from places that are either listed at --font-path variable, installed at system or embedded in Typst itself. It doesn’t look into packages. The same applies to the WebApp, I guess. The font should be either available in the App “out of box” or put into the project by user manually.

Please also note that many fonts have special licenses, and you can’t in legal terms just put it in your package without changing the licence or similar. And maybe some of these licenses would just prohibit people to use the template with this font to create their documents with your template. This may sound absurd, and I’m not a legal expert, but there for sure may be some legal issues for some fonts.

Hope that helps!

3 Likes