[R] plain text in Chinese can not be set

Jinsong Zhao jszhao at mail.hzau.edu.cn
Thu Jul 1 09:24:05 CEST 2010


On 2010-7-1 12:16, Jinsong Zhao wrote:
> Hi there,
>
> The following code can produce the correct type face, however, the Latin
> character are displayed in GB1 font.
>
> pdf("test_1.pdf", family = c("GB1"))
> plot(1:10)
> text(5,1, "\u4F60\u597D", font = 1)
> text(5,2, "\u4F60\u597D", font = 2)
> text(5,3, "\u4F60\u597D", font = 3)
> text(5,4, "\u4F60\u597D", font = 4)
> text(5,5, "is 'hello' in Chinese", font = 1)
> text(5,6, "is 'hello' in Chinese", font = 2)
> text(5,7, "is 'hello' in Chinese", font = 3)
> text(5,8, "is 'hello' in Chinese", font = 4)
> dev.off()
>
> and the following code can reproduce the problem I reported in previous
> post:
>
> pdf("test_2.pdf", font = c("GB1"))
> plot(1:10)
> text(5,1, "\u4F60\u597D", family = "GB1", font = 1)
> text(5,2, "\u4F60\u597D", family = "GB1", font = 2)
> text(5,3, "\u4F60\u597D", family = "GB1", font = 3)
> text(5,4, "\u4F60\u597D", family = "GB1", font = 4)
> text(5,5, "is 'hello' in Chinese", font = 1)
> text(5,6, "is 'hello' in Chinese", font = 2)
> text(5,7, "is 'hello' in Chinese", font = 3)
> text(5,8, "is 'hello' in Chinese", font = 4)
> dev.off()
>
>
> I have read the related source code, i.e., devPS.c, the function
> "PDFfontNumber" seems to write the font number to pdf file. And I think
> it might not consider the coexistence of "family" together with "fonts"
> options in pdf(). But I do not have the ability to give a solution.
>

Read the source again more carefully. I think I get the solution:

Change the following line in PDFfontNumber function in devPS.c:

	    num = 1000 + (cidfontIndex - 1)*5 + 1 + face;
to
	    num = 1000 + (cidfontIndex - 1)*5 + face;

It appears two times in the function.

However, I don't know how to compile the whole R distribution on Windows 
platform. Would anyone here like to give a test? Thanks in advance!

Regards,
Jinsong
-- 
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