Browse documentation
Documentation

Fontsource families

Edit this guide on GitHub

Creates a Font from the Fontsource catalog. The font contains a face for each requested combination of weight, style, and character subset.

fontsource_font!(ROBOTO)

With only a family name, the font includes every available weight and style in the default subset. Use named arguments to select the combinations you need:

fontsource_font!(
    ROBOTO,
    weight: [400, 700],
    style: Normal,
    subset: [Latin, Cyrillic],
)

Each combination is checked against the bundled catalog at compile time.

Arguments

The family comes first, as the name of its families constant (e.g. ROBOTO).

The weight, style, and subset arguments accept one value or a bracketed list:

weight is a number in 100..=900. Omit it for every weight the family ships.

style is Normal or Italic. Omit it for every style the family ships.

subset selects characters such as Latin or Cyrillic and sets each face's unicode-range. Omitting it includes only the family's default subset.

host selects where font files are loaded from. It takes one value and defaults to JsDelivr. Use Asset to bundle the files as Hearth assets and serve them yourself. This requires the asset feature.

display sets how text appears while the font loads. It takes one FontDisplay value, applies to every face, and defaults to Swap.

fontsource_font!(ROBOTO, display: Optional)
fontsource_font!(ROBOTO, host: Asset)

Single faces

Use fontsource_font_face! to create a single FontFace.