原文鏈接:http://tecdat.cn/?p=14987
預期
R語言繪圖中的中文默認字體宋體,希望用其他字體繪圖,保存成PDF格式不能識別中文。
實際
使用“雅黑字體”出現亂碼
重現問題的步驟
Windows7系統,R ×64 3.2.0
-
windowsFonts(
-
+ A=windowsFont("華文彩雲"),
-
+ B=windowsFont("華文仿宋"),
-
+ C=windowsFont("華文行楷"),
-
+ D=windowsFont("華文楷體"),
-
+ E=windowsFont("華文隸書"),
-
+ F=windowsFont("華文中宋"),
-
+ G=windowsFont("華文細黑"),
-
+ H=windowsFont("微軟雅黑"),
-
+ J=windowsFont("華文新魏"),
-
+ K=windowsFont("幼圓")
-
+ )
-
plot(1:10,1:10,type="n")
-
text(2,10,"華文彩雲",family="A");
-
text(2,8,"華文仿宋",family="B");
-
text(2,6,"華文行楷",family="C");
-
text(2,4,"華文楷體",family="D");
-
text(2,2,"幼圓",family="K");
-
text(6,10,"華文隸書",family="E")
-
text(6,8,"華文中宋",family="F")
-
text(6,6,"華文細黑",family="G")
-
text(6,4,"微軟雅黑",family="H")
-
text(6,2,"華文新魏",family="J")