Alex
Alex

Reputation: 19823

ggplot2 embed all used fonts in pdf, R

I am plotting some figures using qplot and ggplot. Prior to the plot I call pdf() and save the plot with dev.off(). I would have to embed all the fonts in the pdf. How can I do this? Either at the time of the plot or post-process the pdf's to embed the fonts?

Upvotes: 3

Views: 1479

Answers (2)

lodebari
lodebari

Reputation: 252

You need to post-process the pdf file to embed the fonts. After closing the device with dev.off(), you can embed the fonts with

embedFonts(file=filepath_fonts_not_embedded, outfile=filepath_fonts_embedded)

Upvotes: 0

IRTFM
IRTFM

Reputation: 263382

This succeeded:

embedFonts( path.expand("~/Rplots.pdf") )

This did not, (so by experiment I have determined that embedFonts requires a full path and will not do "tilde expansion"):

embedFonts("~/Rplots.pdf")
... snipped a bunch of inscrutable error messages
GPL Ghostscript 9.16: Unrecoverable error, exit code 1
Error in sprintf(gettext(fmt, domain = domain), ...) : 
  object 'cmd' not found

although it did demonstrate that I had a functional installation of Ghostscript which is a requirement for embedFonts. (My copy of Ghostscript was probably from my installation of Tex.)

Upvotes: 4

Related Questions