【问题标题】:Error in font_import while installing xkcd font安装 xkcd 字体时 font_import 出错
【发布时间】:2018-03-11 14:24:07
【问题描述】:

我试图按照vignette("xkcd-intro") 中的说明在我的 Mac 上为 R 安装 xkcd 字体

> download.file("http://simonsoftware.se/other/xkcd.ttf", dest="xkcd.ttf", mode="wb")
essai de l'URL 'http://simonsoftware.se/other/xkcd.ttf'
Content type 'application/x-font-ttf' length 12712 bytes (12 KB)
==================================================
downloaded 12 KB

> system("mkdir ~/.fonts")
> system("cp xkcd.ttf  ~/.fonts")

到这里为止,一切似乎都还好,但我对font import 的以下调用出错了:

> font_import(pattern = "[X/x]kcd", prompt=FALSE)
Scanning ttf files in /Library/Fonts/, /System/Library/Fonts, ~/Library/Fonts/ ...
Extracting .afm files from .ttf files...
Error in data.frame(fontfile = ttfiles, FontName = "", stringsAsFactors = FALSE) : 
  arguments imply differing number of rows: 0, 1

我该如何解决这个问题?还有其他方法可以安装这些字体吗?

我已经在这里查看了有关 R 和 xkcd 字体的问题,例如 Not able to install xkcd fonts 和xkcd style graph - error with registered fonts 但不是同一个问题。

【问题讨论】:

    标签: r


    【解决方案1】:

    这对我有用。我注意到在错误的目录中搜索字体。就我而言,有消息,

        Scanning ttf files in C:\Windows\Fonts ...
    

    所以,我更改了命令以查看我的工作目录...

    旧版本

            font_import(pattern = "[X/x]kcd", prompt=FALSE)
    

    新版本

            font_import(paths = getwd(), pattern = "[X/x]kcd", prompt=FALSE)
    

    成功!希望它也对你有用。

    【讨论】:

      【解决方案2】:

      font_import 中的自动检测路径错误。修复它:

      font_import(path = "~/.fonts", pattern = "[X/x]kcd", prompt=FALSE)
      

      【讨论】:

        猜你喜欢
        • 2014-06-07
        • 2012-12-09
        • 2020-10-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-12-15
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多