我尝试在我的pdfs中使用Arial字体,但当我按照extrafont帮助文件中的说明操作时,每一处的文本都会相互覆盖:
library(extrafont)
library(ggplot2)
my_pdf <- function(file, width, height){
loadfonts()
pdf(file = file, width = width, height = height,
family = "Arial")
}
my_pdf("ArialTester.pdf")
qplot(1:10, 1:10, "point") + ggtitle(paste0(LETTERS,letters, collapse=""))
dev.off()我在pdf里看到了下面的内容。请注意,标题是字母表。
这个问题的上下文是context,所以我需要一个可以设置为块选项(即dev = 'my_pdf')的设备函数。

我做错了什么?
发布于 2015-07-14 07:51:22
您需要使用embed_fonts()。
library(extrafont)
library(ggplot2)
my_pdf <- function(file, width, height){
loadfonts()
pdf(file = file, width = width, height = height,
family = "Arial")
}
my_pdf("ArialTester.pdf")
g <- qplot(1:10, 1:10, "point") + ggtitle(paste0(LETTERS,letters, collapse="")) +
theme(text = element_text(family = "Arial"))
plot(g)
dev.off()
embed_fonts("ArialTester.pdf")https://stackoverflow.com/questions/31395321
复制相似问题