【问题标题】:Fonts table remains empty after retrieving windows fonts with extrafont package使用 extrafont 包检索 windows 字体后,字体表仍然为空
【发布时间】: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() 出现的字体没有下雪。

标签: r pdf fonts


【解决方案1】:

对于任何激怒的搜索,我在 Windows 上遇到了同样的问题,并通过以下方式解决了它:

font_import(paths = "C:/Path_to_font")

现在应该填充fonts()。我在字体预览和相关设置中找到了字体路径,然后点击了相关字体。大概你的大部分字体都在同一个地方。

【讨论】:

    猜你喜欢
    • 2017-05-15
    • 2016-07-25
    • 2020-12-15
    • 2021-12-21
    • 2021-11-17
    • 2021-12-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多