Skip to contents

Registers a font file under a family name with systemfonts so that geom_sketch_text(), theme_sketch() (base_family = "auto"), and the font resolver can find it on font-aware devices (ragg, svglite, cairo) without installing the font system-wide. Call it once per session (e.g. in a script or .Rprofile); ship the .ttf/.otf alongside your project for fully reproducible output.

Usage

register_sketch_font(
  family,
  plain,
  bold = plain,
  italic = plain,
  bolditalic = plain,
  ...
)

Arguments

family

Family name to register the font under (e.g. "Caveat"). This is the name you then pass to family = or base_family =.

plain

Path to the regular/plain font file (.ttf or .otf).

bold, italic, bolditalic

Optional paths to the bold/italic faces; default to plain.

...

Passed to systemfonts::register_font().

Value

Invisibly, the registered family name.

Examples

# Register any font file under a family name you choose. Here we reuse a font
# already on the system; in practice point `plain` at a handwriting .ttf/.otf
# (e.g. Caveat from Google Fonts).
f <- systemfonts::system_fonts()$path[1]
register_sketch_font("MySketchFont", f)
#>  Registered font family "MySketchFont".