Skip to contents

Registers the Ubuntu fonts bundled with fmutils and turns on showtext so graphs can use them.

Usage

load_fm_fonts(dpi = 96)

Arguments

dpi

The resolution showtext uses to size text outside knitr. It must match the graphics device resolution (res), or text is drawn at the wrong size. Defaults to 96 (the showtext default).

Value

The registered family names, invisibly.

Details

The function registers three families with sysfonts::font_add(): "Ubuntu" (regular, bold, italic, bold italic), "Ubuntu Light", and "Ubuntu Medium".

Inside a knitr or Quarto render, it sets the fig.showtext chunk option instead of calling showtext::showtext_auto(). knitr then sets the showtext resolution from each chunk's dpi (times fig.retina), so text keeps its size at any figure resolution. Outside knitr, it calls showtext::showtext_opts(dpi = dpi) and showtext::showtext_auto().

Examples

load_fm_fonts()
"Ubuntu" %in% sysfonts::font_families()
#> [1] TRUE