0

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"))

enter image description here

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"
mattador
  • 421
  • 4
  • 12
  • 1
    On my machine no error pops up. But I got the same warnings which can be solved by adding `showtext_auto() options("device" = "windows") win.graph(10,10,12)`. See https://stackoverflow.com/questions/53219980/fonts-not-loading-in-showtext-font-add-google – stefan Jun 08 '20 at 22:31
  • hmm...I am a Mac user. I've tried using quartz(), with inconsistent results. Sometimes it renders a font as expected. Mostly it renders nothing. But I've never gotten it to bold the legend title, as desired. – mattador Jun 09 '20 at 02:18

1 Answers1

0

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()enter image description here

mattador
  • 421
  • 4
  • 12