font

.font main:{String? = null}
heading:{String? = null}
code:{String? = null}
size:{Size? = null}
-> Void

Updates the global font configuration of the document.

Font families can be loaded from any of the following sources:

  • From file (e.g. path/to/font.ttf)

  • From URL (e.g. https://example.com/font.ttf)

  • From system fonts (e.g. Arial, Times New Roman)

  • From Google Fonts (e.g. GoogleFonts:Roboto).

Local and remote font resources are processed by the media storage. This means, for instance, HTML output will carry local fonts into the output directory for increased portability.

This function can be called multiple times to add multiple font configurations. Latter configurations have higher priority. This can be useful to specify fallback fonts for different glyphs. The following example applies the Inter font for Latin characters, and the Ma Shan Zheng font for Chinese characters. This happens because Inter does not support Chinese glyphs, so the renderer falls back to the next configuration.

.font {GoogleFonts:Ma Shan Zheng}
.font {GoogleFonts:Inter}

The size parameter does not stack instead, and only the last specified size is used among all configurations.

Parameters

main
  • Optional

main font family of content on each page

heading

font family of headings on each page. Overrides main for headings if set

code

font family of code blocks and code spans on each page. Overrides main for code if set

size

main font size of the text on each page. Other elements, such as headings, will scale accordingly

Wiki page

Font configuration