46

I have a folder on my Windows desktop (C:\Users\me\Desktop\Fonts) which contains fonts that I would like to import into R using extrafont.

When I try to import the fonts using

library(extrafont)
font_import(paths = "C:/Users/me/Desktop/Fonts", prompt=FALSE)

I receive the error message

Scanning ttf files in C:/Users/me/Desktop/Fonts ...
Extracting .afm files from .ttf files...
C:\Users\me\Desktop\Fonts\arista-light.ttf : No FontName. Skipping.
C:\Users\me\Desktop\Fonts\facebook-letter-faces.ttf : No FontName. Skipping.
C:\Users\me\Desktop\Fonts\Guardian-EgypTT-Text-Regular.ttf : No FontName. Skipping.
C:\Users\me\Desktop\Fonts\pico-black.ttf : No FontName. Skipping.
C:\Users\me\Desktop\Fonts\product-sans.ttf : No FontName. Skipping.
Found FontName for 0 fonts.
Scanning afm files in C:/Users/me/Documents/R/R-3.6.3/library/extrafontdb/metrics
Warning messages:
1: In system2(ttf2pt1, c(args, shQuote(ttfiles[i]), shQuote(tmpfiles[i])),  :
  running command '"C:/Users/me/Documents/R/R-3.6.3/library/Rttf2pt1/exec/ttf2pt1.exe" -a -G fAe "C:\Users\me\Desktop\Fonts\arista-light.ttf" "C:\Users\me\AppData\Local\Temp\RtmpOgbdTh/fonts/arista-light"' had status 1
2: In system2(ttf2pt1, c(args, shQuote(ttfiles[i]), shQuote(tmpfiles[i])),  :
  running command '"C:/Users/me/Documents/R/R-3.6.3/library/Rttf2pt1/exec/ttf2pt1.exe" -a -G fAe "C:\Users\me\Desktop\Fonts\facebook-letter-faces.ttf" "C:\Users\me\AppData\Local\Temp\RtmpOgbdTh/fonts/facebook-letter-faces"' had status 1
3: In system2(ttf2pt1, c(args, shQuote(ttfiles[i]), shQuote(tmpfiles[i])),  :
  running command '"C:/Users/me/Documents/R/R-3.6.3/library/Rttf2pt1/exec/ttf2pt1.exe" -a -G fAe "C:\Users\me\Desktop\Fonts\Guardian-EgypTT-Text-Regular.ttf" "C:\Users\me\AppData\Local\Temp\RtmpOgbdTh/fonts/Guardian-EgypTT-Text-Regular"' had status 1
4: In system2(ttf2pt1, c(args, shQuote(ttfiles[i]), shQuote(tmpfiles[i])),  :
  running command '"C:/Users/me/Documents/R/R-3.6.3/library/Rttf2pt1/exec/ttf2pt1.exe" -a -G fAe "C:\Users\me\Desktop\Fonts\pico-black.ttf" "C:\Users\me\AppData\Local\Temp\RtmpOgbdTh/fonts/pico-black"' had status 1
5: In system2(ttf2pt1, c(args, shQuote(ttfiles[i]), shQuote(tmpfiles[i])),  :
  running command '"C:/Users/me/Documents/R/R-3.6.3/library/Rttf2pt1/exec/ttf2pt1.exe" -a -G fAe "C:\Users\me\Desktop\Fonts\product-sans.ttf" "C:\Users\me\AppData\Local\Temp\RtmpOgbdTh/fonts/product-sans"' had status 1

Based on this I have two questions:

  1. How can I overcome the No FontName. Skipping. issue?
  2. What are the warning messages trying to tell me and do I need to be concerned about this?

I would appreciate any help, many thanks in advance!

David Metcalf
  • 664
  • 1
  • 7
  • 13
  • Does [this](https://github.com/wch/extrafont/issues/32) resolve your issue? Not sure since seems to be for Macs. – caldwellst Apr 14 '20 at 09:26
  • @caldwellst Thanks for pointing that out. I came across that thread but given that it is for Macs I didn't find anything useful apart from the link to the Rttf2pt1 package. Also that thread is 7 years old, so I reckon that something might have happened since then. – David Metcalf Apr 14 '20 at 09:48

3 Answers3

105

As it was mentioned by @Moritz Schwarz, the problem is traced to Rttf2pt1.

According to a solution proposed here, downgrading it to 1.3.8 will fix the problem:

library(extrafont)
library(remotes)
remotes::install_version("Rttf2pt1", version = "1.3.8")
extrafont::font_import()
cartoonist
  • 5,991
  • 6
  • 37
  • 40
  • 2
    Amazing!! This solved the problem! Thank you so much! I am really angry at them that they release such a damn beta. Damn new versions! And my GIS scripts also totally failing under R 4.x.x... – Tomas Aug 13 '21 at 12:23
  • 1
    So much faster to import than getting the No font name message too! – Jayden Nov 23 '21 at 02:28
  • 1
    This doesn't work for me. are there any other methods? – Melanie Baker Mar 22 '22 at 12:53
  • 1
    @MelanieBaker You might want to follow the corresponding issues at extrafont's GitHub repository; e.g. https://github.com/wch/extrafont/issues/88 and https://github.com/wch/extrafont/issues/32 – cartoonist Mar 22 '22 at 14:59
  • 1
    This worked for me, but I had to make some modifications. I had to install the latest version of rtools. Then after installing Rttf2pt1, I had to restart R. Finally, I had to specify a path in the last step: `font_import(paths="C:/Windows/Fonts")` – Alex C. Dec 20 '22 at 19:46
12

I had the exact same problem with one of my font files - the error always occurs in the Rttf2pt1 executable.

I created an issue on the GitHub page for the package - let's see if they can come up with a fix for this.

In the meantime, you can fix the issue though:

It seems to me that the origin of the error comes from a failure in the .ttf file. Navigate over to FontForge and download the open-source software. When installed, open your .ttf file and resave it as a .ttf using the Generate Fonts... option in the File menu. You might get a message that warns you that there is something slightly wrong with the font - you can review it if you like, but I went ahead and clicked Generate anyway.

Then you use the new .ttf file for your ttf_import() and you are good to go!! :)

Moritz Schwarz
  • 2,019
  • 2
  • 15
  • 33
  • 3
    Thanks for the answer, Moritz! I no longer have the need to use custom fonts in R but I trust that other users will find it useful. Hopefully they can find a fix for this! – David Metcalf Mar 08 '21 at 16:11
  • 1
    nothing except this solved my long-lasting problem! – Our May 24 '22 at 14:02
4

(Writing in March 2022 from a Windows 10 machine...)

Instead of using extrafont, use the new package showtext. (https://cran.rstudio.com/web/packages/showtext/vignettes/introduction.html).

ap21
  • 2,372
  • 3
  • 16
  • 32
  • How do you download fonts with this? Like just standard ones. – Melanie Baker Apr 14 '22 at 14:48
  • Yes. Look at the documentation. It's quite concise. – ap21 Apr 16 '22 at 10:13
  • 1
    Big caveat with using `showtext`: This will convert text to polygons which means you will lose the ability to edit any text in post-processing (e.g. in Illustrator, Inkscape, etc.). Here are the details on [how `showtext` works](https://cran.rstudio.com/web/packages/showtext/vignettes/introduction.html#how-showtext-works). – Maurits Evers Jun 20 '22 at 23:32