I'm trying to import Garamond into R using the extrafont
package. I am able to successfully import other fonts when using the unspecified font_import()
function directed towards the font location folder, but I'm missing out several fonts located in that folder. Any suggestion why only some fonts are imported and others not?
I've tried the
font_import(pattern = "Garamond.ttf")
ttf_import(pattern = "Garamond.ttf")
with the following error message:
Scanning ttf files in /Library/Fonts/, /System/Library/Fonts, ~/Library/Fonts/ ... Extracting .afm files from .ttf files... Error in data.frame(fontfile = ttfiles, FontName = "", stringsAsFactors = FALSE) : arguments imply differing number of rows: 0, 1
The extrafont package makes it easier to use fonts other than the basic PostScript fonts that R uses. Fonts that are imported into extrafont can be used with PDF or PostScript output files. On Windows, extrafont will also make system fonts available for bitmap output.
However, it is possible to add custom fonts in R with the extrafont or the showtext packages. The extrafont package allows adding True Font Type ( .ttf) fonts to R easily. Before loading the package, we recommend you to install all the fonts you want in your system.
Extrafont supports font packages, which contain fonts that are packaged in a particular way so that they can be imported into extrafont. These fonts are installed as R packages; they are not installed for the computer operating system. Fonts that are installed this way will be available only for PDF or PostScript output.
The integrated fonts in R are sans (Arial), serif (Times New Roman), mono (Courier) and symbol (Standard Symbols L). However, it is possible to add custom fonts in R with the extrafont or the showtext packages.
font_import(pattern = 'GARAIT')
In order to know the correct name, right click in your installed TTF font, select properties an use the name showed at the top of the "General" tab.
Just import them all, perhaps? It takes a while to run.
install.packages("extrafont")
library(extrafont)
font_import()
I've used Garamond, one of my favorite fonts, before.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With