我正在Debian 9.3上使用RStudio。我想使用库showtext
。我运行了这段代码:
library(showtext)
font_add_google("Lobster", "lobster")
showtext_auto()
plot(1, pch = 16, cex = 3)
text(1, 1.1, "A fancy dot", family = "lobster", col = "steelblue", cex = 3)
结果图表应该看起来像这样...
但是在我的计算机上,它看起来像这样...
答案 0 :(得分:1)
sysfonts
使用的showtext
软件包与RStudio的图形设备之间似乎存在一些不兼容。至少我可以在RStudio中重现该问题,但在使用其他图形设备时则不能:
library(showtext)
font_add_google("Lobster", "lobster")
showtext_auto()
plot(1, pch = 16, cex = 3)
# text in some sans-serif font
text(1, 1.1, "A fancy dot", family = "lobster", col = "steelblue", cex = 3)
x11()
plot(1, pch = 16, cex = 3)
text(1, 1.1, "A fancy dot", family = "lobster", col = "steelblue", cex = 3)
# run this line after looking at the graph
dev.off()
pdf(file = "test1.pdf")
plot(1, pch = 16, cex = 3)
text(1, 1.1, "A fancy dot", family = "lobster", col = "steelblue", cex = 3)
dev.off()
browseURL("test1.pdf")