Using custom OTF fonts in ggplot2

后端 未结 2 1192
野趣味
野趣味 2021-02-02 16:23

I need to use a custom font, namely \"Archer\", with ggplot2 in R. Archer is an otf typeface installed on my system (Mac OSX Yosemite).

This script (found here: Modifyin

2条回答
  •  鱼传尺愫
    2021-02-02 17:09

    You can try the showtext package, which directly works on OTF fonts.

    library(showtext)
    font.add("Archer", "Archer.otf")
    showtext.auto()
    library(ggplot2)
    qplot(1:10)+theme(text=element_text(family="Archer"))
    

    Please replace "Archer.otf" by the real filename of your Archer font in the system.

    Using showtext does not require embedding the fonts.

提交回复
热议问题