
Register a handwriting font for reproducible sketch text
Source:R/fonts-sketch.R
register_sketch_font.RdRegisters 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.
Arguments
- family
Family name to register the font under (e.g.
"Caveat"). This is the name you then pass tofamily =orbase_family =.- plain
Path to the regular/plain font file (
.ttfor.otf).- bold, italic, bolditalic
Optional paths to the bold/italic faces; default to
plain.- ...
Passed to
systemfonts::register_font().
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".