r - 在 Windows 上导入 R(用于 xkcd 包)中的 xkcd 字体
问题描述
我不习惯回答自己的问题。但是,我认为该解决方案将来可能会使某人受益(请参阅答案)。无法在包的 github(只读镜像)上发布此问题。
我在 Windows 上的 R 中安装 xkcd 字体时遇到了很多麻烦,尤其是对于最新版本的 R (4.1.1)。操作系统上有这个解决方案,它不适用于 Windows。它需要这个答案和这个答案(两个不相关的问题)才能在 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 及其功能不应正常工作。
推荐阅读
- kubernetes - K8 使用大写镜像名称创建 pod
- java - 为什么Java中的最后一个地图元素不断重复
- python - filenotfound 错误 - chromedriver(网页抓取)
- python - 我们如何在python中使列表中的重复值唯一?
- c# - 如何在没有“if statement”的情况下检查 CheckBox 是否被选中?
- vue.js - 如何用 jest 测试 nuxt?
- coq - 如何使用 VST/coq 为 switch 语句编写证明?
- python - 如何根据另一个列名聚合熊猫中的文本
- reactjs - 如何使用 React 函数组件获取图像显示
- python - Django ValueError:字段 'id' 需要一个数字,但得到了 'myuser'