4  Fonts

4.1 ttf fonts

4.1.1 Install Packages

install.packages("extrafont")
remotes::install_version("Rttf2pt1", version = "1.3.8")

As of August 2022, if you just install {extrafont} as is, you will have a problem with importing fonts on Windows and there will be an error saying ‘No Font Name’. To solve this, install version 1.3.8 of {Rttf2pt1}.

4.1.2 Download All .ttf Fonts in C:\Windows\Fonts Folder

#will import ALL fonts, takes 5-10 min
extrafont::font_import() 

4.1.3 Download Other Fonts by File

extrafont::font_import(paths = "C:/PATH/TO/FOLDER/WITH/TTF", prompt = FALSE) 

4.1.4 Use

Prior to using fonts in R, need to load fonts in each session (this is like using library() or box::use() for a specific package)

#quiet = FALSE to remove listing of of fonts 
extrafont::Loadfonts(devide = "win", quite = TRUE) 

4.2 otf fonts

4.2.1 Install Packages

  • issues with {showtext} package when in use
  • other ggplot2 fonts are affect when actively using this package, making the fonts smaller and making line breaks much larger
install.packages("showtext")
library(showtext)
showtext_auto() 
font_add("NewFont", regular = "C://PATH//TO//NewFont.otf")
font_families()