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
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. Regards, Jinsong On 2010-7-1 7:14, Jinsong Zhao wrote:> 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
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