::system_fonts()
systemfonts
# if not install.packages("systemfonts")
font notes
I have been getting brave with fonts in my ggplots and running into problems with fonts not appearing the same in my quarto doc and exported png files. BlueSky advice was check out posts from data viz queen Cara Thompson.
Here are my notes from Cara’s post re getting fonts to work for the next time fonts are misbehaving.
1. check you have systemfonts()
2. check you have the font you want
View() will bring up a dataframe and you can search it to check the font you want is installed
::system_fonts() |>
systemfontsView()
If the font you want doesn’t appear when you use the search bar in the View(), install it from Google Fonts, restart RStudio, and check again.
3. set graphics device to AGG
Tools > Global options > General-Graphics
4. make a plot, check that your font shows up
+
p theme_minimal() +
theme(text = element_text(family = "Karla"),
legend.position = "none")
5. test ggsave to make sure the fonts show up there too
ggsave(filename = "test_plot.png",
dpi = 400,
height = 5, width = 8,
bg = "#FFFFFF")
6. set graphics in your quarto set up chunk
::opts_chunk$set(echo = TRUE,
knitrdev = "ragg_png",
dpi = 400)