With the release of R 4.0.0, the default x11(), png(), jpeg(), tiff(), bmp(), svg(), cairo_pdf(), and cairo_ps() devices accept a symbolfamily argument to let the user change the font used for symbols in an image (source).
With Base R png():
library(ggplot2)
library(ragg)
library(scales)
greek <- as.data.frame(c("alpha", "beta", "gamma"))
names(greek) <- "greek"
p <- ggplot(greek, aes(x = greek, y = 1)) +
theme(
plot.title = element_blank(),
axis.title = element_blank(),
axis.ticks = element_blank(),
axis.text.x = element_text(family = "Fira Sans", size = 16),
axis.text.y = element_blank()
) +
scale_x_discrete(name = NULL, labels = label_parse())
ggsave(
"greek_base.png",
plot = p,
device = png,
width = 3, height = 1, dpi = 600,
type = "cairo", symbolfamily = cairoSymbolFont("Fira Sans")
)
Created on 2021-08-27 by the reprex package (v2.0.1)
This gives this plot, withe the "Fira Sans" font used:

With ragg::agg_png():
library(ggplot2)
library(ragg)
library(scales)
greek <- as.data.frame(c("alpha", "beta", "gamma"))
names(greek) <- "greek"
p <- ggplot(greek, aes(x = greek, y = 1)) +
theme(
plot.title = element_blank(),
axis.title = element_blank(),
axis.ticks = element_blank(),
axis.text.x = element_text(family = "Fira Sans", size = 16),
axis.text.y = element_blank()
) +
scale_x_discrete(name = NULL, labels = label_parse())
ggsave(
"greek_ragg.png",
plot = p,
device = ragg::agg_png,
width = 3, height = 1, dpi = 600
)
Created on 2021-08-27 by the reprex package (v2.0.1)
Which gives this plot, using the system default "Symbol" font:

Session Info
> sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 11.5.2
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] scales_1.1.1 ragg_1.1.3 ggplot2_3.3.5
loaded via a namespace (and not attached):
[1] highr_0.9 pillar_1.6.2 compiler_4.1.1 tools_4.1.1
[5] digest_0.6.27 evaluate_0.14 lifecycle_1.0.0 tibble_3.1.4
[9] gtable_0.3.0 pkgconfig_2.0.3 rlang_0.4.11 reprex_2.0.1
[13] rstudioapi_0.13 cli_3.0.1 DBI_1.1.1 yaml_2.2.1
[17] xfun_0.25 fastmap_1.1.0 withr_2.4.2 dplyr_1.0.7
[21] knitr_1.33 fs_1.5.0 generics_0.1.0 vctrs_0.3.8
[25] systemfonts_1.0.2 grid_4.1.1 tidyselect_1.1.1 glue_1.4.2
[29] R6_2.5.1 textshaping_0.3.5 processx_3.5.2 fansi_0.5.0
[33] rmarkdown_2.10 clipr_0.7.1 callr_3.7.0 purrr_0.3.4
[37] magrittr_2.0.1 ps_1.6.0 ellipsis_0.3.2 htmltools_0.5.2
[41] assertthat_0.2.1 colorspace_2.0-2 labeling_0.4.2 utf8_1.2.2
[45] munsell_0.5.0 crayon_1.4.1
As far as I can tell, there isn't currently a way to specify the font to use for symbols with the ragg package. It would be helpful if there were because the default font does not match stylistically with many sans serif fonts.
With the release of R 4.0.0, the default
x11(),png(),jpeg(),tiff(),bmp(),svg(),cairo_pdf(), andcairo_ps()devices accept asymbolfamilyargument to let the user change the font used for symbols in an image (source).With Base R
png():Created on 2021-08-27 by the reprex package (v2.0.1)
This gives this plot, withe the "Fira Sans" font used:

With
ragg::agg_png():Created on 2021-08-27 by the reprex package (v2.0.1)
Which gives this plot, using the system default "Symbol" font:

Session Info
As far as I can tell, there isn't currently a way to specify the font to use for symbols with the
raggpackage. It would be helpful if there were because the default font does not match stylistically with many sans serif fonts.