使用 extrafont 将字体导入 R 时如何解决 "No Font Name" 问题?
How can I resolve the "No Font Name" issue when importing fonts into R using extrafont?
我的 Windows 桌面 (C:\Users\me\Desktop\Fonts
) 上有一个文件夹,其中包含我想使用 extrafont
.
导入 R 的字体
当我尝试使用
导入字体时
library(extrafont)
font_import(paths = "C:/Users/me/Desktop/Fonts", prompt=FALSE)
我收到错误信息
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
基于此我有两个问题:
- 如何解决
No FontName. Skipping.
问题?
- 试图告诉我的警告信息是什么,我是否需要关注这些信息?
如果有任何帮助,我将不胜感激,非常感谢!
我的一个字体文件遇到了完全相同的问题 - 错误总是出现在 Rttf2pt1
可执行文件中。
我创建了一个 issue on the GitHub page for the package - 让我们看看他们是否可以为此提出解决方案。
与此同时,您可以解决此问题:
在我看来,错误的根源来自 .ttf
文件中的故障。导航到 FontForge 并下载开源软件。安装后,打开 .ttf
文件并使用 File[=31] 中的 Generate Fonts... 选项将其重新保存为 .ttf
=] 菜单。您可能会收到一条消息,警告您字体略有错误 - 如果您愿意,可以查看它,但我还是点击了 Generate。
然后为您的 ttf_import()
使用新的 .ttf
文件,一切顺利!! :)
正如@Moritz Schwarz 所提到的,问题是 traced to Rttf2pt1
。
根据提出的解决方案 here,将其降级到 1.3.8 将解决问题:
library(extrafont)
library(remotes)
remotes::install_version("Rttf2pt1", version = "1.3.8")
extrafont::font_import()
(2022 年 3 月在 Windows 10 台机器上写作...)
不使用 extrafont
,而是使用新包 showtext
。
(https://cran.rstudio.com/web/packages/showtext/vignettes/introduction.html).
我的 Windows 桌面 (C:\Users\me\Desktop\Fonts
) 上有一个文件夹,其中包含我想使用 extrafont
.
当我尝试使用
导入字体时library(extrafont)
font_import(paths = "C:/Users/me/Desktop/Fonts", prompt=FALSE)
我收到错误信息
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
基于此我有两个问题:
- 如何解决
No FontName. Skipping.
问题? - 试图告诉我的警告信息是什么,我是否需要关注这些信息?
如果有任何帮助,我将不胜感激,非常感谢!
我的一个字体文件遇到了完全相同的问题 - 错误总是出现在 Rttf2pt1
可执行文件中。
我创建了一个 issue on the GitHub page for the package - 让我们看看他们是否可以为此提出解决方案。
与此同时,您可以解决此问题:
在我看来,错误的根源来自 .ttf
文件中的故障。导航到 FontForge 并下载开源软件。安装后,打开 .ttf
文件并使用 File[=31] 中的 Generate Fonts... 选项将其重新保存为 .ttf
=] 菜单。您可能会收到一条消息,警告您字体略有错误 - 如果您愿意,可以查看它,但我还是点击了 Generate。
然后为您的 ttf_import()
使用新的 .ttf
文件,一切顺利!! :)
正如@Moritz Schwarz 所提到的,问题是 traced to Rttf2pt1
。
根据提出的解决方案 here,将其降级到 1.3.8 将解决问题:
library(extrafont)
library(remotes)
remotes::install_version("Rttf2pt1", version = "1.3.8")
extrafont::font_import()
(2022 年 3 月在 Windows 10 台机器上写作...)
不使用 extrafont
,而是使用新包 showtext
。
(https://cran.rstudio.com/web/packages/showtext/vignettes/introduction.html).