【问题标题】:Importing the xkcd fonts in R (for xkcd package) on windows在 Windows 上导入 R(用于 xkcd 包)中的 xkcd 字体
【发布时间】:2021-12-15 08:49:37
【问题描述】:

我不习惯回答自己的问题。但是,我认为该解决方案将来可能会使某人受益(请参阅答案)。无法在包的 github(只读镜像)上发布此问题。

我在 Windows 上的 R 中安装 xkcd 字体时遇到了很多麻烦,尤其是对于最新版本的 R (4.1.1)。操作系统上有这个solution,它在 Windows 上不起作用。它需要 answer 和 answer(两个不相关的问题)才能在 R 中使用字体。

【问题讨论】:

    标签: r fonts


    【解决方案1】:

    这是我得到的解决方案。

    下载必要的包。

    install.packages("extrafont","remotes","xkcd")
    library(extrafont)
    library(remotes)
    

    其中一个问题是错误消息In system2(ttf2pt1, c(args, shQuote(ttfiles[i]), shQuote(tmpfiles[i])), : running command [...] 已通过将Rttf2pt1 降级到版本1.3.8 得到解决

    remotes::install_version("Rttf2pt1", version = "1.3.8")
    

    下载字体并确保它在工作目录中(应该是)。

    download.file("http://simonsoftware.se/other/xkcd.ttf", dest = "xkcd.ttf", mode = "wb")
    

    导入字体的原始说明不起作用(参见vignette("xkcd-intro"),必须将路径重定向到工作目录。

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

    现在应该可以加载字体和 xkcd 包了。

    loadfonts(device = "win")
    library(xkcd)
    

    xkcd 包及其功能不能正常工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-07
      • 1970-01-01
      • 2017-01-29
      • 1970-01-01
      • 1970-01-01
      • 2018-07-11
      • 1970-01-01
      • 2012-12-09
      相关资源
      最近更新 更多