r - Roboto Condensed 和 PDF 设备
问题描述
我一直在尝试使用pdf()
R 中的 pdf 设备(即 )来导出我正在使用hrbrthemes
包的绘图,但没有成功。我知道我可以cairo_pdf
毫无问题地使用,但我对 pdf 支持的一些功能感兴趣,例如colormodel
和paper
. 我曾尝试删除并重新安装 extrafont 以及删除和重新安装 Roboto Condensed,但均未成功。我正在 Windows 系统中尝试此操作。
library(extrafont)
library(ggplot2)
library(hrbrthemes)
fonts()
fonts()[grep("Roboto", fonts())]
#[1] "Roboto"
import_roboto_condensed()
fonts()[grep("Roboto", fonts())]
# [1] "Roboto" "Roboto Condensed"
ggplot(mtcars, aes(mpg, hp)) +
geom_point() +
theme_ipsum_rc() +
labs(
x = "Miles per gallon",
y = "Horsepower",
title = "Using so much gas",
subtitle = "A bunch of cars"
)
ggsave("mypdf.pdf")
# This create a pdf with no text and also gives the following error:
# Error in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
# invalid font type
ggsave("mypdf_cairo.pdf", device = cairo_pdf)
# This works but cairo does not seem to support some features like colormodel (i.e., cmyk) and paper.
loadfonts()
# More than one version of regular/bold/italic found for Roboto Condensed. Skipping setup for this font.
解决方案
推荐阅读
- javascript - 在文本框事件中传递的javascript函数中传递标签的id
- ios - 无法获取具有 SQL 等条件的核心数据
- javascript - 从中获取值
- python-3.x - 如何使用 python 访问 local.setting.json 数据库连接字符串
- c# - 如何强制使 WPF 窗口无效?
- cordova - Ionic 在部署过程中删除 json/i18n 文件中的代码行
- c++ - 未调用赋值运算符
- django - 使用 apache 和 mod_wsgi 在 DigitalOcean 上部署 django 项目并获取错误,因为目标 WSGI 脚本无法作为 Python 模块加载
- .htaccess - 当某些子文件夹后跟从 URL 中删除文件夹时需要 URL 重写帮助
- c# - 为什么流读取器声明的新对象中的缓冲区参数