作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经安装了“extrafont”包以安装外部字体库 Duality通过 ttf_import() 方法。但是,当通过 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 参数看不到 Duality 字体?以及如何使其对开罗(默认渲染器)可见。 TIA!
最佳答案
我已经能够使用传递给文本 family
和 font
并在 ?par
中描述的参数来克服相同的问题,而不是vfont
。我还需要先加载字体。事情是这样的:
导入字体(抱歉,OP中提供的 Duality 链接不再可用,我使用 Lucida Handwriting 代替,在 Windows 中可用):
library(extrafont)
font_import(pattern="LHANDW")
加载(有关详细信息,请参阅此 blog):
loadfonts() # loadfonts(device = "win") if you are working in windows
词云:
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)
关于r wordcloud 外部 ttf vfont 无法识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18108512/
我已经安装了“extrafont”包以安装外部字体库 Duality通过 ttf_import() 方法。但是,当通过 wordcloud 方法指定字体时,我收到以下错误: 安装命令: # Assum
我是一名优秀的程序员,十分优秀!