6
votes

I downloaded the otf files from this website. My IT dept installed "Font Awesome 5 Free Regular" and I used

library(extrafont)
font_import()
loadfonts(device = "win")

I can see Font Awesome as "Font Awesome 5 Free Regular" is registered. When I tried to use it with this test code:

waffle(c(50, 30, 15, 5), rows = 5, use_glyph = "music", glyph_size = 6)

I get

Error: FontAwesome not found. Install via: https://github.com/FortAwesome/Font-Awesome/tree/master/fonts

but that link doesn't go anywhere.

I would like to use Font Awesome (or a good alternative) to make interesting waffle charts. Did I load the font incorrectly? Is there a better alternative I am missing? I have been using this article as a guide. I have also read a related question here on stackoverflow, but it did not help. I have restarted Rstudio (and the computer) several times and no luck.

Update

Still not working. I have removed and reinstalled the waffle and emojifont packages. I Still get the error code : "Error: FontAwesome not found. Install via: https://github.com/FortAwesome/Font-Awesome/tree/master/fonts"

4

4 Answers

2
votes

You may want to try using FontAwesome v. 4.7 I had the same issue as you but it resolved itself immediately when I installed the .ttf version.

2
votes

I know this question was asked and answered quite a while ago, but the answer didn't help me with my code, and I found something that did from this source: https://www.listendata.com/2019/06/create-infographics-with-r.html They have a step-by-step directions for downloading fontawesome using the extrafont library. Really easy. Hope this helps someone! Basically, download the fontawesome-webfont.ttf, then:

library(extrafont)
extrafont::font_import (path="C:/Users/insert/your/own/path", pattern = "awesome", prompt = FALSE)
loadfonts(device = "win")
# check to see if it works:
fonts()[grep("Awesome", fonts())]
#returns fontawesome

Then use use_glyph = argument in making your waffle chart.

2
votes

For anyone who ends up here in 2021 and fails to get it working with extrafont, here is an alternative approach:

  1. Use the legacy FontAwesome ttf, that Silviculturalist linked to: https://github.com/FortAwesome/Font-Awesome/releases/tag/v4.7.0
  2. Extract fontawesome-webfont.ttf to your work directory (or some directory you can access)
  3. Use the waffle, emojifont and showtext packages to create the chart, sample code below
install.packages(c("waffle", "emojifont", "showtext"))
 
library(waffle)
library(emojifont)
library(showtext)

font_add(family = "FontAwesome", 
         regular = "fontawesome-webfont.ttf")

waffle(c(5,12,18), rows = 5, use_glyph = "subway", glyph_size = 10, 
title = "Subways!", legend_pos="right")
1
votes

If you are going to use the font-awesome glyphs in ggplot2 plots then you can use the wonderful emojifont package. No need to add the font manually yourself.

library("emojifont")
library("waffle")
waffle(c(50, 30, 15, 5), rows = 5, use_glyph = "music", glyph_size = 4)

That produces the graph you are after:

enter image description here

Update: Since you have installed the otf fonts and not the ttf fonts that might be the cause of your problems. The load.fontawesome() function in the emojifontpackage has a default argument:

load.fontawesome(font = "fontawesome-webfont.ttf")

You could try to 1) either install the ttf version of the fonts or 2) call

load.fontawesome(font = "fontawesome-webfont.otf")

before plotting (although I'm not sure the latter will work). Worth a try though.