windows 在 R 中导入 xkcd 字体(对于 xkcd 包)
Importing the xkcd fonts in R (for xkcd package) on windows
我不习惯回答我自己的问题。但是,我认为该解决方案将来可能会使某人受益(请参阅答案)。在包的 github(只读镜像)上 post 这个问题是不可能的。
我在 windows 上的 R 中安装 xkcd 字体遇到了很多麻烦,尤其是对于最新版本的 R (4.1.1)。有这个solution on OS, which do not work on windows. It needed this and this answer(两个不相关的问题)能够使用R中的字体。
这是我找到的解决方案。
下载必要的包。
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 及其功能不能正常工作。
我不习惯回答我自己的问题。但是,我认为该解决方案将来可能会使某人受益(请参阅答案)。在包的 github(只读镜像)上 post 这个问题是不可能的。
我在 windows 上的 R 中安装 xkcd 字体遇到了很多麻烦,尤其是对于最新版本的 R (4.1.1)。有这个solution on OS, which do not work on windows. It needed this
这是我找到的解决方案。
下载必要的包。
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 及其功能不能正常工作。