[R] More than two font in a plot

Paul Murrell p.murrell at auckland.ac.nz
Wed Jun 30 01:06:39 CEST 2010


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()

Paul

> Regards,
> Jinsong

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/



More information about the R-help mailing list