【发布时间】:2018-02-12 12:55:39
【问题描述】:
为了将字体名称为 Calibri 的 ggplots 保存为 pdf 文件,我尝试使用 extrafont 包以便能够在 ggplot2 中使用此字体类型。
这些是我采取的步骤:
font_import()
获取所有字体后(在此过程中似乎没有任何问题),我收到此错误:
Scanning afm files in <<library path>>/extrafontdb/metrics
Error in if (grepl("Bold", weight)) { : argument is of length zero
还有这样的错误:
Warning messages:
1: In readLines(srcfile) :
invalid input found on input connection 'C:<<path>>\AppData\Local\Temp\26\RtmpANG4o2/fonts/ahronbd.afm'
2: In readLines(srcfile) :
incomplete final line found on 'C:<<path>>\AppData\Local\Temp\26\RtmpANG4o2/fonts/ahronbd.afm'
etc.
当我运行这段代码时:
loadfonts()
fonts()
输出是NULL
当我尝试使用 ggsave() 将 ggplot 保存为 pdf 时,错误提示:
Error in grid.Call.graphics(L_text, as.graphicsAnnot(x$label), x$x, x$y, :
invalid font type
我想最后一个错误并不奇怪,因为字体表似乎是空的。
这里出了什么问题,如何解决这个问题?
编辑我以为我找到了解决方案。当我使用loadfonts(device="win") 而不是loadfonts() 时,起初似乎一切顺利,但我错了。 fonts() 还是空的。
【问题讨论】:
-
试试
names(pdfFonts()) -
感谢您的提示。它显示了可用的字体。本来应该通过
font_import()出现的字体没有下雪。