r - pdf with extrafont creates overlapping text -
i'm trying use arial typeface in pdfs, when follow instructions in extrafont file, text @ each point written on each other:
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()
i below in pdf. note title meant alphabet.
the context of question knitr, need device function can set chunk option (i.e. dev = 'my_pdf'
)
what have done incorrectly?
you need use 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")
Comments
Post a Comment