Import font into R using extrafont package

extrafonts r
rstudio fonts
font family 'arial' not found in postscript font database
font family not found in windows font database
showtext r
extrafont github
failed to find or load pdf cid font
ggplot fonts

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


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.

How to use your favorite fonts in R charts (Revolutions), font_import(pattern = 'GARAIT'). In order to know the correct name, right click in your installed TTF font, select properties an use the name  To use extrafont in making graphs, you'll need to do the following: Import fonts into the extrafont database. (Needs to be done once) Register the fonts from the extrafont database with R's PDF (or PostScript) output device. (Needs to be done once per R Create the graphics that use the fonts.


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.

Import font into R using extrafont package, There are two main packages for managing fonts – extrafont , and showtext You can add custom fonts with extrafont() , however I've only had  To use extrafont in making graphs, you'll need to do the following: Import fonts into the extrafont database. (Needs to be done once) Register the fonts from the extrafont database with R's PDF (or PostScript) output device. (Needs to be done once per R Create the graphics that use the fonts.


You can also import fonts in a specific folder with extrafont:

library(extrafont)
font_import(paths = c("c:/path/to/folder/with/fonts/", prompt = F)

This way if you have a copy of Garamond (or any other font) that's not installed in the system font library, you can still use it.

Adding Custom Fonts to ggplot in R, Registering fonts with R Importing fonts may take a few minutes, depending on the number of fonts and the speed of the system. Continue? [y/n] Exiting. choose_font: Choose an installed font from a list; embed_fonts: Embeds fonts that are listed in the local Fontmap; extrafont: extrafont package; font_addpackage: Add font from an installed package to fonts database; font_import: Import system fonts; font_install: Install a font package and register it in the fonts database


I had this same error message and this is why. If the font.ttf file is not in the ~Library/Fonts directory, then font_import(pattern="font.ttf") will not work. Look in the ~Library/Fonts directory and see that the file is actually there in the format you expect. If not then just download it and put it there. Be sure to call the file exactly as it appears in the ~Library/Fonts directory. Cheers

font_import: Import system fonts in extrafont: Tools for using fonts, In many cases, using non-standard fonts in R graphs is not an easy task, especially for PDF devices. The extrafont package developed by Winston Chang is one nice The easy way to load font into showtext is by calling. font_import. From extrafont v0.17 by Winston Chang. 0th. Percentile. Documentation reproduced from package extrafont, version 0.17, License: GPL-2


showtext: Using Fonts More Easily in R Graphs - CRAN, In many cases, using non-standard fonts in R graphs is not an easy task, The extrafont package developed by Winston Chang is one nice solution to this In this example we first load fonts that are available online through  To use extrafont in making graphs, you'll need to do the following: Import fonts into the extrafont database. (Needs to be done once) Register the fonts from the extrafont database with R's PDF (or PostScript) output device. (Needs to be done once per R Create the graphics that use the fonts.


showtext: Using Fonts More Easily in R Graphs, Import fonts (and some quick data setup). For the extrafont package you'll need to make sure that you have GhostScript on your system in order to  font_install ("fontcm") It will ask you to download the fontcm package from CRAN, and then it will import the font into the extrafont database. Once that's done, run loadfonts () to register the fonts with R's PDF device. If you run fonts (), they will be listed as “CM Roman”, “CM Sans”, and “CM Typewriter”.


Tired of using Helvetica in your R graphics? Here's how to use the , font_addpackage, Add font from an installed package to fonts database. font_import loadfonts, Reads the fonttable database and registers those fonts with R. Note: Using the extrafont package, you can also embed these fonts in PDF and EPS files (make plots in R and export to PDF/EPS). You can also directly create math symbols (see math equation in plot below), usually created using TeX. More information here and here. Also look at the github project page.