0

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?

camille
  • 16,432
  • 18
  • 38
  • 60
  • 1
    Unless you have your fonts installed somewhere unusual, you shouldn't need the entire path as the `regular` argument. I'm not on Windows, so I'm not sure where that would be. Is this not a font you want to install? – camille Nov 10 '21 at 19:09
  • It is a font I want to install. What would be a usual directory to install the fonts? Maybe I could try installing the fonts somewhere else. But in the [guide](https://www.listendata.com/2019/06/create-infographics-with-r.html) I mentioned before, they type the fontfile path as `regular`, that's what I was doing that. – robert_gonzalez Nov 10 '21 at 19:17
  • 1
    I don't generally use Windows but install it however you would normally install fonts on your computer. I'm not sure why that guide is mixing extrafont and showtext; `font_add` is from sysfonts, which showtext loads. Not sure about how extrafont would factor into that. Look at the docs for `font_add` with the examples there of loading fonts – camille Nov 10 '21 at 19:20
  • Does this answer your question? [Font Awesome in R, loaded but not found by waffle](https://stackoverflow.com/questions/51311536/font-awesome-in-r-loaded-but-not-found-by-waffle) – manro Nov 10 '21 at 20:12
  • Unfortunately none of the solutions worked for me, plotted the charts following a different approach. – robert_gonzalez Nov 11 '21 at 11:22

0 Answers0