我试图从R导出一个简单的图表到PDF,用一个希腊字母写成这样:
cairo_pdf("test.pdf")
barplot(1, main = "\u03C1")
dev.off()
我是在一个OpenSUSE LEAP 15.1系统与R3.5预装-这工作很好。因此,必须安装必要的字体。
但是,在R4.0.3(我自己编译的)中,相同的命令生成一个框,而不是希腊字母:
(有趣的是,复制和粘贴这个盒子会插入正确的希腊字母。)
这是R v3和v4之间的根本区别(如果是,哪一个?),或者在编译过程中我能影响到这一点吗?我在Windows上没有同样的问题,但这是一个发布版本,我没有自己编译,并且具有ICU功能。
查看PDF文件,v3文件使用Cantarell-正则和SourceCodePro。v4 one使用Cantarell-正则和Cantarell.所有字体都是嵌入子集的。因此,R v4似乎无法切换到SourceCodePro
字体,尽管它已安装:
> fc-list | grep SourceCodePro
/usr/share/fonts/truetype/SourceCodePro-Medium.otf: Source Code Pro,Source Code Pro Medium:style=Medium,Regular
/usr/share/fonts/truetype/SourceCodePro-Regular.otf: Source Code Pro:style=Regular
/usr/share/fonts/truetype/SourceCodePro-Bold.otf: Source Code Pro:style=Bold
/usr/share/fonts/truetype/SourceCodePro-Black.otf: Source Code Pro,Source Code Pro Black:style=Black,Regular
/usr/share/fonts/truetype/SourceCodePro-BoldIt.otf: Source Code Pro:style=Bold Italic
/usr/share/fonts/truetype/SourceCodePro-Semibold.otf: Source Code Pro,Source Code Pro Semibold:style=Semibold,Regular
/usr/share/fonts/truetype/SourceCodePro-ExtraLightIt.otf: Source Code Pro,Source Code Pro ExtraLight:style=ExtraLight Italic,Italic
/usr/share/fonts/truetype/SourceCodePro-BlackIt.otf: Source Code Pro,Source Code Pro Black:style=Black Italic,Italic
/usr/share/fonts/truetype/SourceCodePro-LightIt.otf: Source Code Pro,Source Code Pro Light:style=Light Italic,Italic
/usr/share/fonts/truetype/SourceCodePro-MediumIt.otf: Source Code Pro,Source Code Pro Medium:style=Medium Italic,Italic
/usr/share/fonts/truetype/SourceCodePro-It.otf: Source Code Pro:style=Italic
/usr/share/fonts/truetype/SourceCodePro-SemiboldIt.otf: Source Code Pro,Source Code Pro Semibold:style=Semibold Italic,Italic
/usr/share/fonts/truetype/SourceCodePro-Light.otf: Source Code Pro,Source Code Pro Light:style=Light,Regular
/usr/share/fonts/truetype/SourceCodePro-ExtraLight.otf: Source Code Pro,Source Code Pro ExtraLight:style=ExtraLight,Regular
在R configure
命令中,我看到
跳过的功能: ICU
其中ICU = Unicode的国际组件。另外:
检查pkg-config是否知道cairo和pango的事.不是 检查pkg-config是否知道开罗的事.是
这两者中有一个是有关联的吗?
编辑:我已经找到并阅读了更改Cairo图形设备的符号字体
cairo_pdf("test.pdf", symbolfamily = cairoSymbolFont("Courier", usePUA = FALSE))
barplot(1, main = "\u03C1")
dev.off()
以及
cairo_pdf("test.pdf", symbolfamily = cairoSymbolFont("Courier", usePUA = TRUE))
barplot(1, main = "\u03C1")
dev.off()
产生与上面相同的输出,尽管
cairo_pdf("test.pdf", family = "Courier")
barplot(1, main = "\u03C1")
dev.off()
成功地更改标准字体,指示已安装并可用的信使。
发布于 2020-12-05 20:21:48
用ICU的支持重新编译没有修复这个问题--用cairo重新编译,而pango做了。
为了实现这两个目标,安装程序包的尝试和错误都有很多。总之,我做了zypper in libicu-devel freetype-devel freetype pango-devel pango-tools libpango-1_0-0 harfbuzz-devel fribidi-devel fribidi
。其中大部分可能已经安装,但在此过程中,我注意到了libharfbuzz0
和libharfbuzz-icu0
被打破并修复的安装。
然后重新配置和重新编译R,问题就解决了。
https://stackoverflow.com/questions/65150098
复制相似问题