简体   繁体   English

在 GoogleFonts 中使用粗体

[英]Using bold font with GoogleFonts

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.我现在有点迷茫:我已经通过 GoogleFonts 在我的 R 脚本中添加了一种字体,现在想使用“粗体”版本。 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.我在下面附上了一个小的、可重现的例子,如果有人能给我提示如何使用 Roboto-bold 中的“Text1”例子之一,我将不胜感激。

By the way, here is the GoogleFonts page for Roboto: https://fonts.google.com/specimen/Roboto顺便说一句,这是 Roboto 的 GoogleFonts 页面: 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)

since draw_text is based on geom_text the fontface argument works here as well:由于draw_text是基于geom_text的,因此fontface参数在这里也适用:

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)

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM