r wordcloud外部ttf vfont无法识别

Pau*_*gor 6 r truetype word-cloud

我已经安装了'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")
Run Code Online (Sandbox Code Playgroud)

Wordcloud命令:

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)
Run Code Online (Sandbox Code Playgroud)

输出:

Error in strwidth(words[i], cex = size[i], ...) : 
  invalid 'vfont' value [typeface -2147483648]
Run Code Online (Sandbox Code Playgroud)

为了验证确实安装了字体,我发出了以下命令

> choose_font("Duality")
[1] "Duality"
> fonts()
....[49] "Waree"                    "Duality"    
Run Code Online (Sandbox Code Playgroud)

为什么wordcloud的vfont参数看不到Duality字体?如何让它对开罗(默认渲染器)可见.TIA!

ein*_*dzl 4

我已经能够使用传递给 textfamilyfont中的参数来克服相同的问题?par,而不是vfont. 我还需要先加载字体。事情是这样的:

导入字体(抱歉,OP中提供的 Duality 链接不再可用,我使用 Lucida Handwriting 代替,在 Windows 中可用):

library(extrafont)
font_import(pattern="LHANDW")
Run Code Online (Sandbox Code Playgroud)

加载(详细信息请参阅此博客):

loadfonts() # loadfonts(device = "win") if you are working in windows
Run Code Online (Sandbox Code Playgroud)

词云:

wordcloud(ap.d$word, ap.d$freq, scale=c(8,2), min.freq=10, family="Lucida Handwriting", font=1,
  random.order=FALSE, rot.per=0, use.r.layout=FALSE, colors=pal2, fixed.asp=FALSE)
Run Code Online (Sandbox Code Playgroud)