[R] Arial font in eps figures in R

Sharon Kuhlmann-B sharon.kuhlmann-b at smi.se
Thu Feb 9 11:53:24 CET 2012


Hi,

I am trying to create a graph using Arial font (as required by PLoS One). I have read probably all posts in R-help on this topic, as wells as R-news 2006.

The code I have been trying is following:

Arial <- Type1Font(family="Arial",
                metrics=c("ArialMT.afm", "arial-BoldMT.afm", "Arial-ItalicMT.afm", "Arial-BoldItalicMT.afm"))
postscriptFonts(Arial=Arial)
postscript("testArial.eps", horizontal=F, onefile=F, width=4, height=4)
par(family="Arial")
plot(1:10, 1:10)
dev.off()

but getting the following error message:

Error in axis(side = side, at = at, labels = labels, ...) : 
  family 'Arial' not included in PostScript device


Alternatively I've also tried:

Arial <- Type1Font(family="Arial",
                metrics=c("ArialMT.afm", "arial-BoldMT.afm", "Arial-ItalicMT.afm", "Arial-BoldItalicMT.afm"))
postscriptFonts(Arial=Arial)
postscript("testArial.eps", horizontal=F, onefile=F, width=4, height=4, family="Arial")
plot(1:10, 1:10)
dev.off()

which resulted in:

Error in postscript("testArial.eps", horizontal = F, onefile = F, width = 4,  : 
  Failed to initialise default PostScript font


The *.afm files were downloaded from http://www.koders.com/, since I wasn't able to run ttf2afm or ttf2pt1 on my computer. The files are saved under ../R/library/grDevices/afm.  I have also tried saving the files with LF line endings (instead of CRLF) as indicated in README under /grDevices/afm, and zipping them. That didn't make a difference.

I am currently running R-2.14.1 on Windows7. If I run postscriptFonts(), the Arial font is included in the list, very much as other types of fonts.

I've seen that some R packages are now using arial as default (e.g. googleVis and R2PPT) but I cannot see how it is done.

Thanks in advance for any suggestions.

/Sharon



More information about the R-help mailing list