Summary of the Problem:
I am following this guide to learn how to make more interesting data visualisations with R: https://www.listendata.com/2019/06/create-infographics-with-r.html
Specifically, I am looking into the "Use Icon in Waffle" section. The guide says you need to use a package called "extrafont", which I have installed and loaded without a problem, but when I check if I have the fonts installed by running fonts() and fonttable(), I just get "NULL" or an empty dataframe. I should be getting a table of fonts to show that the fonts are available to use in R.
What have I tried:
- Ran library("waffle")
- I installed extrafont using
install.packages("extrafont") - Ran
library("extrafont")to load it - Went to this url as specified in the guide: https://github.com/FortAwesome/Font-Awesome/tree/master/webfonts and downloaded the three specified fonts. There are now three .ttf files in my Downloads folder
- Double-clicked each of the .ttf files and clicked "Install" to install the fonts on my computer.
- Ran
font_import(path="/Users/[my-name]/Downloads/", pattern = "fa-", prompt = FALSE)to import the fonts into R. Here is an extract of the output:
/Users/[my-name]/Downloads/fa-brands-400.ttfsh: line 1: 17105 Segmentation fault: 11 '/Users/[my-name]/Library/R/x86_64/4.1/library/Rttf2pt1/exec//ttf2pt1' -a -GfAe '/Users/[my-name]/Downloads/fa-brands-400.ttf' '/var/folders/xw/cv_66y755dzgyqgnn9_jb7wm0000gq/T//RtmpDxvl5L/fonts/fa-brands-400' 2>&1
: No FontName. Skipping.
/Users/[my-name]/Downloads/fa-regular-400.ttfsh: line 1: 17107 Segmentation fault: 11 '/Users/[my-name]/Library/R/x86_64/4.1/library/Rttf2pt1/exec//ttf2pt1' -a -GfAe '/Users/[my-name]/Downloads/fa-regular-400.ttf' '/var/folders/xw/cv_66y755dzgyqgnn9_jb7wm0000gq/T//RtmpDxvl5L/fonts/fa-regular-400' 2>&1
: No FontName. Skipping.
- Ran
loadfonts(device = "win"). This returnedError in windowsFonts() : could not find function "windowsFonts", which I'm guessing is something to do with me being on a Mac, so then I ranloadfonts(device = "pdf")instead. (I'm not completely sure what this part does, but I think it's the part that allows the font to work if you wanted to save the chart as a PDF?) This didn't give any output so I guessed it only did something in the background. - Ran
fonts()and gotNULL, ranfonttable()and gotdata frame with 0 columns and 0 rows
I had a look at this question too: Fonts table remains empty after retrieving windows fonts with extrafont package I don't think it's the same issue though, as I am not getting the same errors as they are.
Any help would be greatly appreciated :)
My R session info is:
R version 4.1.2 (2021-11-01)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] extrafont_0.17 waffle_1.0.1 ggplot2_3.3.5
loaded via a namespace (and not attached):
[1] RColorBrewer_1.1-2 pillar_1.6.4 compiler_4.1.2 tools_4.1.2
[5] digest_0.6.28 lifecycle_1.0.1 tibble_3.1.5 gtable_0.3.0
[9] pkgconfig_2.0.3 rlang_0.4.12 DBI_1.1.1 cli_3.1.0
[13] rstudioapi_0.13 curl_4.3.2 xfun_0.28 fastmap_1.1.0
[17] Rttf2pt1_1.3.9 gridExtra_2.3 withr_2.4.2 dplyr_1.0.7
[21] stringr_1.4.0 generics_0.1.1 vctrs_0.3.8 htmlwidgets_1.5.4
[25] grid_4.1.2 DT_0.19 tidyselect_1.1.1 glue_1.4.2
[29] R6_2.5.1 fansi_0.5.0 extrafontdb_1.0 purrr_0.3.4
[33] magrittr_2.0.1 scales_1.1.1 ellipsis_0.3.2 htmltools_0.5.2
[37] assertthat_0.2.1 colorspace_2.0-2 utf8_1.2.2 tinytex_0.35
[41] stringi_1.7.5 munsell_0.5.0 crayon_1.4.2