0

When I use embedFonts to embed the fonts in an EPS file, the paper size changes and the graphic of my R plot is in the lower left corner. This question was already asked here embed_fonts() changes paper size on encapsulated postscript (.eps, R) but not solved. So here is the question with a minimal working example. I using R version 4.1.1 on macOS Big Sur and Ghostscript version 9.50 oder 9.54.0.

fileName = 'WithoutFonts.eps'
fileNameEmbed = 'WithEmbeddedFonts.eps'
setEPS()
postscript( file = fileName, height = 5, width = 4 )
plot( rnorm(100), rnorm(100), main = 'Random Values' )
dev.off()
embedFonts( file = fileName, format = 'eps2write', outfile = fileNameEmbed )
Wani
  • 1
  • 2

1 Answers1

0

I have found a solution to the problem. Originally I created an EPS file and then embedded the fonts with embedFonts(). Thereby the paper size was changed. Now I create a PDF file and then use embedFonts() to embed the fonts and change the format to EPS at the same time. Now it crops the border to the visible area. This then makes the paper size too small. But if you draw a white box in the PDF file (see also embedFonts is changing the bounding box of my R plot ) the EPS file with the embedded fonts has exactly the same size as the original PDF file. I suspect this is related to the fact that EPS does not have a paper size, but a bounding box. Hint: This works with eps2write, but not with epswrite.

fileName = 'WithoutFonts.pdf'
fileNameEmbed = 'WithEmbeddedFonts.eps'
pdf( file = fileName, height = 5, width = 4 )
plot( rnorm(100), rnorm(100), main = 'Random Values' )
box( which = 'outer', col = 'white' )
dev.off()
embedFonts( file = fileName, format = 'eps2write', outfile = fileNameEmbed )
Wani
  • 1
  • 2