我已经安装了“extrafont”包,以便通过 ttf_import() 方法安装外部字体库Duality 。但是,当通过 wordcloud 方法指定字体时,我收到以下错误:
安装命令:
# Assuming the font file, DUALITY_.ttf, is in the working directory (see link to font above)
font_import(".",FALSE,pattern="DUALITY")
词云命令:
wordcloud(ap.d$word, ap.d$freq, scale=c(8,2), min.freq=10, vfont=c("Duality","plain"),
random.order=FALSE, rot.per=0, use.r.layout=FALSE, colors=pal2, fixed.asp=FALSE)
输出:
Error in strwidth(words[i], cex = size[i], ...) :
invalid 'vfont' value [typeface -2147483648]
为了验证确实安装了字体,我发出了以下命令
> choose_font("Duality")
[1] "Duality"
> fonts()
....[49] "Waree" "Duality"
为什么对偶字体对 wordcloud 的 vfont 参数不可见?以及如何使其对 Cairo(默认渲染器)可见。蒂亚!