小编Hil*_*lde的帖子

导入后在 R 中不可用的字体

我在 R 环境中导入字体时遇到了一些问题。我的最终目标是将我公司的自定义字体(.ttf 文件)R 包含在 ggplot 和 RMarkdown 中。我尝试分解问题并注意到导入常规 Windows 字体时出现同样的问题。导入不会引发任何错误,但字体不可用于绘图。我正在使用在 Windows 10 Pro 1803 上运行的 R 版本 3.5.1。

我已经尝试使用 extrafont 包以及使用 showtext 包导入 Windows 字体。我还尝试将所有 Windows ttf 文件从 C:\WINDOWS\Fonts 手动复制到 C:\Users...\Documents\R\R-3.5.1\library\extrafontdb\metrics ,同样的问题仍然存在。

下面是一些带有抛出错误的 R 基础数据集的代码块:

library(ggplot2)
library(extrafont) 
font_import()

# Only three fonts seem to have been imported...
loadfonts(); windowsFonts()
#$`serif`
#[1] "TT Times New Roman"

#$sans
#[1] "TT Arial"

#$mono
#[1] "TT Courier New"


ggplot(data = esoph) +
  aes(x = agegp, weight = ncases) +
  geom_bar() +
  ggtitle("This is …
Run Code Online (Sandbox Code Playgroud)

fonts r ggplot2

6
推荐指数
2
解决办法
5225
查看次数

标签 统计

fonts ×1

ggplot2 ×1

r ×1