[R] pdf() device uses fonts to represent points - data alteration?

jiho jo.irisson at gmail.com
Thu Oct 4 10:21:28 CEST 2007


Hello all,

I discovered that the pdf device uses fonts to represent "points"  
symbols (as in plot(...,type="p",...) ). Namely it uses ZapfDingbats  
with symbol U+25cf. This can lead to problems when the font is not  
available, or available in another version (such as points being  
replaced by other symbols, or worst: slightly displaced).  
Furthermore, it also causes problems when opening the pdf files for  
editing in other programs. I know that for reproducibility one should  
avoid doing this but there are cases where R is simply not suited to  
produce the end result graphic directly using code (Ex: replace some  
colors by CMYK versions for color consistency in print). In addition,  
publishers also often like being able to retouch graphics to ensure  
fonts consistency or such, and this will be destructive in the case  
of these pdfs. For example, Inkscape interprets points as squares  
(more like U+2751 in ZapfDingbats) and Adobe Illustrator does not  
even recognize the font (substituting AdobePiStd).
I tried to embed fonts with embedFonts() but his does not solves the  
issue with editing (Inkscape produces a kind of star and AI still  
chokes on the font) and worst, it modifies how the original graphic  
renders in pdf viewers: the circles are now filled (I believe this is  
because this is the default state of the ZapfDingbats character).

So my questions are:
- does anyone have a work around this?
- why can't the pdf device use shapes instead of fonts to represent  
data point? It would appear as a much more robust approach and would  
ensure that the points are rendered the same everywhere. Font  
substitution in axes labels is not as bad since it does not modify  
the data itself (at worst the labels are offset a little bit) but  
font substitution on the data points can really harm the graphic.

Examples of code:
	pdf("test.pdf")
	plot(0,0,xlab="",ylab="",bty="n",xaxt="n",yaxt="n"); grid(lty=1);
	dev.off()
	embedFonts("test.pdf","pdfwrite","test_embed.pdf")

visualize the fonts:
	pdffonts test.pdf

and a package with the two pdf files and bitmaps of how they render  
or are interpreted in various programs:
	http://jo.irisson.free.fr/dropbox/test_R_pdf_fonts.zip

Thank you in advance for your attention and help.

JiHO
---
http://jo.irisson.free.fr/



More information about the R-help mailing list