load_source_sans_3 {gghdx} | R Documentation |
Simple wrapper for sysfonts::font_add_google()
and
showtext::showtext_auto()
to load the
Source Sans 3 font and
specify all plots to automatically use showtext. Use to load the default
font family for geom_text_hdx()
and geom_label_hdx()
.
load_source_sans_3(family = NULL, regular = NULL)
family |
Character string for the Source Sans 3 family. If |
regular |
Path to the font file for the regular font face. If |
By default, the font is loaded from Google using sysfonts::font_add_google()
.
If an internet connection is unavailable, then attempts to use a locally
installed version of the font using sysfonts::font_add(family, regular)
.
If you have the font installed but still receive an error from this function,
check the family
and regular
arguments match your installed font.
Nothing, run for side effect of loading the font and activating showtext.
gghdx()
for automatically running load_source_sans_3()
,
along with other styling.
library(ggplot2)
p <- ggplot(
data = mtcars,
mapping = aes(
x = mpg,
y = mpg,
label = rownames(mtcars)
)
)
# font not loaded so error will be generated
try(p + geom_label_hdx())
load_source_sans_3()
p + geom_label_hdx()