Hi there,
I try to plot with custom fonts, which have good shape Latin and CJK
characters. I set up all the fonts correctly. However, when I plot the
same code on png() and postscript(), I get different result. The main
problem is the space between characters is narrower in postscript() than
that in png(), and some character also overlap in postscript(). You can
see the differences from the attached png files.
Is there any way to get the same plot using postscript() and png()?
Thanks in advance.
Best,
Jinsong
The code I used is here:
windowsFonts(song = windowsFont("SourceHanSerifSC-Regular"),
hei = windowsFont("SourceHanSansSC-Regular"),
hwhei = windowsFont("SourceHanSansHWSC-Regular"),
fzsong = windowsFont("FZShuSong-Z01"),
fzhei = windowsFont("FZHei-B01"))
postscriptFonts(song = CIDFont("SourceHanSerifSC-Regular",
"UniSourceHanSerifCN-UTF8-H", "UTF-8", ""),
hei = CIDFont("SourceHanSansSC-Regular",
"UniSourceHanSansCN-UTF8-H", "UTF-8", ""),
hwhei = CIDFont("SourceHanSansHWSC-Regular",
"UniSourceHanSansHWCN-UTF8-H", "UTF-8", ""),
fzsong = CIDFont("FZShuSong-Z01", "GBK-EUC-H",
"GBK", ""),
fzhei = CIDFont("FZHei-B01", "GBK-EUC-H", "GBK", ""))
fa <- c("sans", "serif", "song", "hei", "hwhei", "fzsong", "fzhei")
postscript("font.eps", fonts = fa, onefile = FALSE, width = 4, height =
4, horizontal = FALSE)
#png("font.png", width=4*300, height=4*300, res =300)
plot(0,xlab="",ylab="",type="n")
text(1, -0.75, expression(CO[2]-Hei), family = "hei")
text(1, -0.5, expression(CO[2]-HWHei), family = "hwhei")
text(1, -0.25, expression(CO[2]-FZHei), family = "fzhei")
text(1, 0.0, expression(CO[2]-Sans), family = "sans")
text(1, 0.25, expression(CO[2]-FZSong), family = "fzsong")
text(1, 0.5, expression(CO[2]-Song), family = "song")
text(1, 0.75, expression(CO[2]-Serif), family = "serif")
dev.off()