I downloaded the latest RStudio the other day and I've started running into problems with the font when I use ggsave()
.
I specify the font as I always have (after loading fonts with extrafont
, and it shows up correctly in the RStudio viewer), but when I save the output through ggsave()
it appears to give me a different style of that font family (Myriad Pro). This didn't happen before downloading the latest RStudio.
Here's a example:
library(tidyverse)
extrafont::loadfonts(device = "win")
n <- 6
dat <- data.frame(id=1:n,
date=seq.Date(as.Date("2020-12-26"), as.Date("2020-12-31"), "day"),
group=rep(LETTERS[1:2], n/2),
age=sample(18:30, n, replace=TRUE),
type=factor(paste("type", 1:n)),
x=rnorm(n))
dat %>%
ggplot(aes(age, x)) +
labs(x = "Here is a label for my x axis",
y = "Here is a slightly different one for my y axis",
title = "This is an example title") +
theme(text = element_text(family = "Myriad Pro"))
ggsave("test_output.png")
In RStudio, I'm seeing this (font is correct):
but ggsave()
is giving me this (font is incorrect) and I have no idea why:
I'm using the same code that's worked previously, but it seems like I'm now getting the condensed style of Myriad Pro?
Does anyone have any ideas about what might be happening?
Thanks!