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

if (FALSE) { # \dontrun{
# Download Caveat from Google Fonts, then:
register_sketch_font("Caveat", "fonts/Caveat-Regular.ttf")
library(ggplot2)
ggplot(mtcars, aes(wt, mpg)) +
  geom_sketch_point(seed = 1L) +
  theme_sketch(base_family = "Caveat")
} # }