我正在研究多语言情节,我需要在 R 情节中绘制中文文本,这是粗体。但是当我使用 font.main=4 时,中文文本仍然不是粗体。
pdf(paste("./tmp/population.pdf",sep=""), width=10 , height =11, family="GB1")
plot(x,main="中国的",cex.axis= 1, cex.lab=1.2,font.main=4)
dev.off()
我该如何解决这个问题
我正在研究多语言情节,我需要在 R 情节中绘制中文文本,这是粗体。但是当我使用 font.main=4 时,中文文本仍然不是粗体。
pdf(paste("./tmp/population.pdf",sep=""), width=10 , height =11, family="GB1")
plot(x,main="中国的",cex.axis= 1, cex.lab=1.2,font.main=4)
dev.off()
我该如何解决这个问题
正如@DWin 在评论中所建议的那样,Hei 字体系列比 GB1 更“大胆”,因此可能会奏效。它在 R 中不是默认设置,因此您必须将 Hei 字体映射到名称“Hei”才能在其中使用它,pdf
或者您必须使用cairo_pdf
.
使用cairo_pdf
它很简单,您可以从字面上使用计算机上安装的任何字体库:
cairo_pdf("population.pdf", width=10 , height=11, family="Hei")
否则,要映射 Hei 字体,您需要在计算机上以格式定位字体库afm
(为了练习,假设它是 s ~/Library/Fonts//Hei.afm
)。
hei <- Type1Font("Hei", c("~/Library/Fonts//Hei.afm", "", "", ""))
# the three empty spaces would have been the place for respectively the bold, the italic and the bold italic font libraries
pdfFonts(A=hei)
pdf("population.pdf", width=10 , height=11, family="A")