Learn R Programming

ggsketch (version 2.0.0)

register_sketch_font: Register a handwriting font for reproducible sketch text

Description

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,
  ...
)

Value

Invisibly, the registered family name.

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().

See Also

Other sketch-theme: CoordSketch, CoordSketchPolar, element_sketch_line(), ggsketch_check_fonts(), ggsketch_save(), scale_pressure_continuous(), scale_roughness_continuous(), scale_sketch, scale_tone_continuous(), sketch_palette(), theme_sketch()

Examples

Run this code
# 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)

Run the code above in your browser using DataLab