Using bold font with GoogleFonts

219 views Asked by At

I'm a bit lost at the moment: I have added a font to my R script via GoogleFonts and would now like to use the "bold" version. However, I can't find a way!

I've already tried various things and it doesn't work - I'm expecting a simple solution, but I just can't figure it out!

I have attached a small, reproducible example below and would be grateful if someone could give me a tip on how to use one of the "Text1" examples in Roboto-bold.

By the way, here is the GoogleFonts page for Roboto: https://fonts.google.com/specimen/Roboto

Thank you and best regards!


Current Code:

library(showtext)
font_add_google(name = "roboto", family = "roboto") 
showtext_auto()


ggdraw() +
  draw_text("__Text1__", x = 0.82, y = 0.69, color = "black", size = 35, family = "roboto")+
  draw_text("Text1", x = 0.4, y = 0.69, color = "black", size = 35, family = "roboto")+
  draw_text("Text1", x = 0.1, y = 0.69, color = "black", size = 35)
1

There are 1 answers

1
Julian_Hn On BEST ANSWER

since draw_text is based on geom_text the fontface argument works here as well:

ggdraw() +
  draw_text("Bold&\nItalic", x = 0.82, y = 0.69, color = "black", size = 35, family = "roboto",fontface="bold.italic")+
  draw_text("Italic", x = 0.62, y = 0.69, color = "black", size = 35, family = "roboto",fontface="italic")+
  draw_text("Bold", x = 0.4, y = 0.69, color = "black", size = 35, family = "roboto",fontface="bold")+
  draw_text("Normal", x = 0.15, y = 0.69, color = "black", size = 35)

enter image description here