I am running R 4.3.1 in a docker (rocker/tidyverse), with RStudio Server 2023.06.0
Having some issues getting ggplot outputs with the correct font.
I have installed google fonts and loaded them via
extrafont but I do not get the same outputs as I do from my windows pc.
Using the 'Alata' font as an example, and
"Alata" %in% fonts() returns
TRUE across both instances.
library(tidyverse) library(extrafont) library(ragg) as_tibble(mtcars, rownames = "car") %>% slice(1:10) %>% ggplot(aes(x = mpg, y = car)) + geom_col(alpha = 0.4) + geom_text(aes(x = 1, label = car), hjust = 0, family = "Alata") + theme(axis.text.y = element_blank()) ggsave("test.png", height = 12, width = 9, dpi = 300, device = agg_png)
The desired image (as I get on windows) is:
But in the plot viewer on RStudio Server I get:
ggsave output from RStudio Server is:
extrafont can see the correct font is installed, but it doesn't get used properly by
ggsave in my docker instance?