Skip to contents

Registers a font file under a family name with systemfonts, so font-aware devices (ragg, svglite, cairo) can draw it by that name without the font being installed system-wide. Pass the name to family = or base_family =. Registered under one of the handwriting names ggsketch looks for (such as "Caveat", the first it tries; see ggsketch_check_fonts()), it is found like an installed face, so it can become the default face of geom_sketch_text() and theme_sketch(base_family = "auto"), the one sketch_font() returns. 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".