R ggplot2字体问题

5

我正在尝试在使用ggplot2的R中使用xkcd字体。然而,我遇到了一些问题。 以下是我目前所做的: 1)从xkcd网站上安装了“Humor Sans”字体,并将其放置在目录~ / .fonts中。 2)安装了“extrafont”包。这个安装很顺利。 3)加载库。

library(extrafont)

然而,当我尝试导入字体时,出现了以下错误。
> font_import(pattern="Humor Sans")
 Importing fonts may take a few minutes, depending on the number of fonts and the speed of the system.
 Continue? [y/n] y
 Scanning ttf files in /usr/share/fonts/, ~/.fonts/ ...
 Extracting .afm files from .ttf files...
 Error in data.frame(fontfile = ttfiles, FontName = "", stringsAsFactors = FALSE) : 
 arguments imply differing number of rows: 0, 1

有没有什么建议,我可能做错了什么或者还需要做什么? 提前感谢您的帮助。
编辑:运行ubuntu 12.04
1个回答

1
你尝试过吗:

font_import(paths = "~/.fonts", pattern="Humor Sans")

在我看来,"~/.fonts" 不是 Mac 的默认字体文件夹,所以如果你的操作系统是(或不是)Mac,当你编辑原始问题时,应包含更多细节。


运行Ubuntu 12.04。那并没有解决问题。此外,根据错误消息,它已经在扫描该目录了。 - broccoli
1
然后,您应该显示该目录上的ls结果。错误消息还表示没有匹配模式。 - IRTFM
目录~/.fonts 只有Humor-Sans.ttf文件。 - broccoli
3
如果拼写是“Humor-Sans”,那么这就解释了为什么“Humor Sans”的模式找不到它。 - IRTFM

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接