There are quite a few systems for font management in R. A key part of our work is trying to make graphs and tables cross platform reproducible, and consistent. This means dealing with fonts across different platforms.
knitr::opts_chunk$set(echo = TRUE) library(ggrrr)
Instead of specifying a font family as a character in a call to ggplot, we can
use a check_font()
call which tries to find the font on your system and if not
available downloads it from Google fonts or Brick and registers it with systemfonts
,
returning the family name.
ggplot rendering uses systemfonts
and attempts
to make the output portable for use by embedding webfonts into the svg outputs.
if the sub
option is TRUE
, check_font()
will guess an alternative.
check_font("Helvetica")
Find out what fonts ggrrr
can find on this system.
# list all available fonts tmp = fonts_available() # Check if specific fonts are available. Returns fonts_available(c("Roboto","Arial","Helvetica"))
Checks if a local font is available. If not downloads and installs the font and
registers in the systemfonts
packages. Currently supported are google
and
brick
# clears any registered fonts reset_fonts() # if the fonts is named the names are used for the family on this system check_font(c("Roboto","Arial","Kings","EB Garamond")) systemfonts::registry_fonts()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.