Skip to contents

Returns the font family that geom_sketch_text() and geom_sketch_label() use when no family is given, and that theme_sketch(base_family = "auto") uses: the first installed handwriting face from the list ggsketch_check_fonts() checks. Pass it to your own text layers, theme elements or grid text so they match the sketch layers.

Usage

sketch_font()

Value

A single font family name, or "" (the device default) when no handwriting font is installed or systemfonts is not available. It never errors.

Details

Some installed faces (notably variable fonts such as Caveat) can't be drawn by name on ragg or svglite, so ggsketch registers a drawable copy with systemfonts under the family name plus " (ggsketch)" and returns that name instead. Either way the family needs a font-aware device (ragg, svglite or cairo); the base pdf() and postscript() devices can't draw it.

Examples

sketch_font()
#> [1] ""

# Match your own text to the sketch layers:
library(ggplot2)
p <- ggplot(mtcars, aes(wt, mpg)) +
  geom_sketch_point(seed = 1L) +
  annotate("text", x = 4.5, y = 30, label = "a note in the same hand",
           family = sketch_font()) +
  theme_sketch()
# Draw `p` on a font-aware device, such as ragg::agg_png() or
# svglite::svglite().