[R] Placing eps files from R into Adobe InDesign documents: specifying fontfamily

S Devriese sdmaillist at gmail.com
Wed Jan 13 08:11:12 CET 2010

On 01/12/2010 04:36 PM, dwalcerz wrote:
> This is a solution I am posting for a problem that others may have.
> If you want to:
> 1.  Place lattice graphics from R into an Adobe InDesign document, and
> 2.  Use the export as eps function in R to maximize resolution (it is much
> better than exporting as a metafile or bitmap), and
> 3.  Use long strings of text in your titles or captions or to label your
> axes.
> Then you will have problems because:
> 1.  Adobe InDesign doesn't recognize R fontfamilies in eps files, and
> 2.  Adobe InDesing replaces the default R font, Helvetica, with a fontfamily
> that looks like Courier, which significantly changes the physical length of
> each character string and disrupts the spacing and justification of titles,
> captions, and axis labels.
> The way I solved this problem is:
> 1.  When you execute a graph in R, use the Hershey family of fonts.  I
> particulary like HersheySans.  You can specify the fontfamily for axes and
> strips and titles as shown in the example below.
> 2.  Export the file in eps by right-clicking the on-screen display and
> selecting 'save as postscript'.
> 3.  Place the file in InDesign using the usual command (ctrl-D) and
> selecting the file.  You will still get the Adobe error about unrecognized
> fonts, but the automatic replacement that Adobe uses for the Hershey
> fontfamily is much better than the one they use for Helvetica, your spacing
> and justification will be almost perfect, and you get the excellent
> resolution and small size of vector-graphics.
> In the following example the fontfamily is specified for strips, axes, and
> titles with these lines:
> par.strip.text=list(fontfamily="HersheySans") #for strips
> scales=list(alternating=1, tck=c(1,0), fontfamily="HersheySans") #for axes
> xlab=list("Combined Score", fontfamily="HersheySans") #for titles such as
> 'main', 'sub', 'xlab' and 'ylab'
> Here is the example:
> bwplot(school.name~score|assessment+course_code, data=temp2.stack,
> 	plot.points=FALSE, drop.unused.levels=TRUE,
> 	panel=function(..., box.ratio, varwidth) {
> 		panel.violin(..., col="cornsilk", varwidth=FALSE, box.ratio=box.ratio)
> 		panel.bwplot(..., box.ratio=0.1)
> 	},
> 	layout=c(2,3,1),
> 	par.strip.text=list(fontfamily="HersheySans"),
> 	scales=list(alternating=1, tck=c(1,0),
> 		fontfamily="HersheySans",
> 		x=list(relation="same", cex=0.7, rot=90),
> 		y=list(relation="same", cex=0.7, rot=0)),
> 	xlab=list("Combined Score", fontfamily="HersheySans"),
> 	ylab=list("School(State)(students)", fontfamily="HersheySans")
> )

You might also have a look at the embedFonts function of the grDevices


More information about the R-help mailing list