Not sure why, but when I import "Montserrat" font with showtext::font_add_google, the legend title will not be bold :/
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"))
I think this (partially) works (though no bolding) because I have Montserrat installed locally. If I try a font I haven't installed, i.e. with: font_add_google(name="Yesteryear")
I get this error and no plot:
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"
As pointed out by Stefan, adding showtext_auto()
before plotting works. It does not render correctly in R Studio (under Mac OS Catalina), but it does output bolded legend upon ggsave()