ggplot2 图例标题不尊重 Google 字体的粗体

ggplot2 legend title not respecting bold for Google Font

不知道为什么,但是当我用 showtext::font_add_google 导入 "Montserrat" 字体时,图例标题不会加粗 :/

require(showtext);require(ggplot2)

font_add_google(name="Montserrat")
ggplot(mpg,aes(cty,hwy,fill=manufacturer))+geom_point()+
theme(text=element_text(family="Montserrat"),legend.title=element_text(face="bold"))

我认为这(部分)有效(尽管没有加粗),因为我在本地安装了 Montserrat。如果我尝试使用我尚未安装的字体,即:font_add_google(name="Yesteryear")

我收到此错误并且没有情节:

Error in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  : 
  polygon edge not found
In addition: Warning message:
In grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  :
  no font could be found for family "Yesteryear"

正如 Stefan 所指出的,在绘图之前添加 showtext_auto() 有效。它在 R Studio 中无法正确呈现(在 Mac OS Catalina 下),但它会在 ggsave()

上输出粗体图例