【问题标题】:"EB Garamond" font in ggplot2ggplot2 中的“EB Garamond”字体
【发布时间】:2020-08-26 15:42:40
【问题描述】:

我正在关注示例here,但它不起作用。如何更改为“EB Garamont 12”字体?

library(showtext)
library(ggplot2)
font_files()
windows()
font_add_google("EB Garamond")
font_families()
a <- ggplot(mtcars, aes(x = wt, y = mpg)) + 
  geom_point() +
  ggtitle("Fuel Efficiency of 32 Cars") +
  xlab("Weight (x1000 lb)") + ylab("Miles per Gallon") +
  theme_set(theme_gray(base_size = 20, base_family = "EB Garamond" )) +
  annotate("text", 1, 11, label = 'GGTT', hjust = 0,
           family = myFont2, size = 10) 
print(a) 

我也使用font_import(paths = NULL, recursive = TRUE, prompt = TRUE,pattern = NULL) 进行了此操作,但我在任何地方都看不到EB Garamond 家族。

font_import(paths = NULL, recursive = TRUE, prompt = TRUE,pattern = NULL)

#Scanning ttf files in C:\WINDOWS\Fonts ...
#Extracting .afm files from .ttf files...
#C:\Windows\Fonts\arial.ttf : ArialMT already registered in fonts database. Skipping.
#...
#...
#C:\Windows\Fonts\ebrima.ttf : Ebrima already registered in fonts database. Skipping.
#C:\Windows\Fonts\ebrimabd.ttf : Ebrima-Bold already registered in fonts database. Skipping.
#C:\Windows\Fonts\euclid.ttf : Euclid already registered in fonts database. Skipping.
#C:\Windows\Fonts\euclidb.ttf : Euclid-Bold already registered in fonts database. Skipping.
#C:\Windows\Fonts\euclidbi.ttf : Euclid-BoldItalic already registered in fonts database. Skipping.
#C:\Windows\Fonts\euclidi.ttf : Euclid-Italic already registered in fonts database. Skipping.
#C:\Windows\Fonts\eucsym.ttf : EuclidSymbol already registered in fonts database. Skipping.
#C:\Windows\Fonts\eucsymb.ttf : EuclidSymbol-Bold already registered in fonts database. Skipping.
#C:\Windows\Fonts\eucsymbi.ttf : EuclidSymbol-BoldItalic already registered in fonts database. Skipping.
#C:\Windows\Fonts\eucsymi.ttf : EuclidSymbol-Italic already registered in fonts database. Skipping.
#C:\Windows\Fonts\euextra.ttf : EuclidExtra already registered in fonts database. Skipping.
#C:\Windows\Fonts\euextrab.ttf : EuclidExtra-Bold already registered in fonts database. Skipping.
#C:\Windows\Fonts\eufrak.ttf : EuclidFraktur already registered in fonts database. Skipping.
#C:\Windows\Fonts\eufrakb.ttf : EuclidFraktur-Bold already registered in fonts database. Skipping.
#C:\Windows\Fonts\eumat1.ttf : EuclidMathOne already registered in fonts database. Skipping.
#C:\Windows\Fonts\eumat1b.ttf : EuclidMathOne-Bold already registered in fonts database. Skipping.
#C:\Windows\Fonts\eumat2.ttf : EuclidMathTwo already registered in fonts database. Skipping.
#C:\Windows\Fonts\eumat2b.ttf : EuclidMathTwo-Bold already registered in fonts database. Skipping.
#C:\Windows\Fonts\fences.ttf : Fences-Plain already registered in fonts database. Skipping.
#C:\Windows\Fonts\framd.ttf : FranklinGothic-Medium already registered in fonts database. Skipping.
#...

extrafont::loadfonts(device="win") #I can't find EB Garamond

【问题讨论】:

    标签: r ggplot2 fonts


    【解决方案1】:

    您需要在绘图前包含showtext_auto()

    library(showtext)
    library(ggplot2)
    
    font_add_google("EB Garamond")
    windows()
    
    showtext_auto()
    
    ggplot(mtcars, aes(x = wt, y = mpg)) + 
      geom_point() +
      ggtitle("Fuel Efficiency of 32 Cars") +
      xlab("Weight (x1000 lb)") + ylab("Miles per Gallon") +
      theme_set(theme_gray(base_size = 20, base_family = "EB Garamond" )) +
      annotate("text", 1, 11, label = 'GGTT', hjust = 0,
               family = "EB Garamond", size = 10) 
    

    windows 设备现在显示:

    【讨论】:

    • 我没有意识到这个功能,谢谢。我怎么能从我的电脑(图片中的那个)加载字体EB Garamond 12 ALL SC?。
    猜你喜欢
    • 1970-01-01
    • 2011-05-04
    • 1970-01-01
    • 2021-12-18
    • 2014-09-12
    • 2016-04-10
    • 1970-01-01
    • 1970-01-01
    • 2013-05-06
    相关资源
    最近更新 更多