[R] More than two font in a plot

Patrick Connolly p_connolly at slingshot.co.nz
Wed Jun 30 10:24:26 CEST 2010


On Wed, 30-Jun-2010 at 11:06AM +1200, Paul Murrell wrote:

> Hi
>
> On 6/30/2010 2:17 AM, Jinsong Zhao wrote:
>> Hi there,
>>
>> I am a Chinese R user. I hope to display Chinese character in a plot,
>> and than save it in PostScript format. I have read the article titled
>> "Non-Standard Fonts in PostScript and PDF Graphics", especially the
>> section about CJK fonts. I also tried the code:
>>
>>> pdf("chinese.pdf", width=3, height=1)
>>> grid.text("\u4F60\u597D", y=2/3, gp=gpar(fontfamily="CNS1"))
>>> grid.text("is 'hello' in (Traditional) Chinese", y=1/3)
>>> dev.off()
>>
>> however, it's not valid with postscript(). It seems that postscript()
>> need to set family in postscirpt(..., family = "CNS1"). Then all the
>> characters are in CJK font, and it's not what I hope to get. I hope the
>> Latin character is displayed in Helvetica.
>>
>> Any suggestions? Thanks in advance!
>
> Try this ...
>
> # Use "Helvetica" as default, but include "CNS1" as a font that
> # will be used somewhere within the file
> postscript("chinese.pdf", width=3, height=1, fonts="CNS1")
> grid.text("\u4F60\u597D", y=2/3, gp=gpar(fontfamily="CNS1"))
> grid.text("is 'hello' in (Traditional) Chinese", y=1/3)
> dev.off()
>


That doesn't work for me using the ancient version of R (a year old)
on this box.  It produces a file that looks like a postscript file,
but which is slightly smaller than the one that a call to pdf() makes
but cannot be displayed by any file viewer I have.

However, it kind of works if I convert the pdf file into a postscript
file using pdftops, but I doubt that's what Jinsong wanted.  It's
35Mb!

Perhaps it really does work using a more up to date version.



-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___    Patrick Connolly   
 {~._.~}                   Great minds discuss ideas    
 _( Y )_  	         Average minds discuss events 
(:_~*~_:)                  Small minds discuss people  
 (_)-(_)  	                      ..... Eleanor Roosevelt
	  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.



More information about the R-help mailing list