[R] plain text in Chinese can not be set

Jinsong Zhao jszhao at mail.hzau.edu.cn
Thu Jul 1 01:14:19 CEST 2010


Hi there,

According to ?par, 'font' is an integer which specifies which font to
use for text, that 1 corresponds to plain text (the default), 2 to bold
face, 3 to italic and 4 to bold italic.

When I test Chinese character in pdf(), I found that 1 to bold face, 2 
to italic, 3 to bold italic, 4 to symbol. and I don't find how to set 
plain text. In the following code, the font to use for Latin text is 
correct.

I also tested postscript(), and it did as what was expected.

Any suggestions? Thanks in advance!

Regards,
Jinsong


### the code to reproduce my question ###

pdf("test_0.pdf", fonts = c("GB1"))
plot(1:10)
text(5,4, "\u4F60\u597D", family="GB1", font = 0) ## bold
text(5,5, "is 'hello' in Chinese", font = 0) ## normal
dev.off()

pdf("test_1.pdf", fonts = c("GB1"))
plot(1:10)
text(5,4, "\u4F60\u597D", family="GB1", font = 1) ## bold
text(5,5, "is 'hello' in Chinese", font = 1) # normal
dev.off()

pdf("test_2.pdf", fonts = c("GB1"))
plot(1:10)
text(5,4, "\u4F60\u597D", family="GB1", font = 2) ## italic
text(5,5, "is 'hello' in Chinese", font = 2) # bold
dev.off()

pdf("test_3.pdf", fonts = c("GB1"))
plot(1:10)
text(5,4, "\u4F60\u597D", family="GB1", font = 3) ## bold italic
text(5,5, "is 'hello' in Chinese", font = 3) # italic
dev.off()

pdf("test_4.pdf", fonts = c("GB1"))
plot(1:10)
text(5,4, "\u4F60\u597D", family="GB1", font = 4) ## symbol
text(5,5, "is 'hello' in Chinese", font = 4) # bold italic
dev.off()

-- 
Jinsong Zhao, Ph.D.
College of Resources and Environment
Huazhong Agricultural University
Wuhan 430070, P.R. China
E-mail: jszhao at mail.hzau.edu.cn



More information about the R-help mailing list