robert_gonzalez
robert_gonzalez

Reputation: 53

R showtext font_add issue "cannot open resource, error code 1"

Trying to do some isotype charts in Rstudio, I've encountered some issues when adding the founts which are required to include icons in the final plots.

I've followed the steps from this guide, which is quoted as a reference by many for such charts. I've been able to install the fonts in my system, as the following command:

extrafont::fonttable() %>% 
  dplyr::as_tibble() %>% 
  dplyr::filter(grepl("Awesom", FamilyName)) %>% 
  select(FamilyName, FontName, fontfile)

yields:

FamilyName  FontName    fontfile
Font Awesome 5 Brands Regular   FontAwesome5Brands-Regular  C:\\Users\\me\\downloads\\fa-brands-400.ttf
Font Awesome 5 Free Regular FontAwesome5Free-Regular    C:\\Users\\me\\downloads\\fa-regular-400.ttf
Font Awesome 5 Free Solid   FontAwesome5Free-Solid  C:\\Users\\me\\downloads\\fa-solid-900.ttf
FontAwesome  FontAwesome   C:\\Windows\\Fonts\\fontawesome-webfont.ttf

But when trying to use showtext to add the fonts, as the guide does, this command (tried it for the 3 fonts, just showing the first one):

font_add(family = "FontAwesome5Free-Solid", regular = "C:\\Users\\me\\downloads\\fa-brands-400.ttf")

gives an error:

Error in font_add(family = "FontAwesome5Free-Solid", regular = "C:\\Users\\me\\downloads\\fa-brands-400.ttf") : 
  freetype: cannot open resource, error code 1

Has anyone encountered the same issue and been able to get around it?

Upvotes: 0

Views: 281

Answers (0)

Related Questions