r-lib / ragg

Graphic Devices Based on AGG
https://ragg.r-lib.org
Other
172 stars 24 forks source link

ggplot theme font not getting mapped properly #168

Closed RoyalTS closed 3 months ago

RoyalTS commented 3 months ago

I'm not sure if this is a ragg bug, a systemfonts bug, or even whether it is a bug at all or just unexpected behavior. Here goes:

I've been using hrbrthemes forever, always without issue. theme_ipsum_ps() from that package (docs) uses IBM Plex Sans as its font, and using the default Rstudio device the code

mtcars |> 
  ggplot(aes(mpg, wt)) +
  geom_point() +
  hrbrthemes::theme_ipsum_ps() +
  labs(title='This is a title')

produces this plot:

Screenshot 2024-06-09 at 19 36 19

All as it should be. If I switch to the AGG device, however, the font no longer seems to be getting rendered correctly:

Screenshot 2024-06-09 at 19 36 39

This despite the relevant section of systemfonts::system_fonts() looking – at least to me – relatively innocuous:

Screenshot 2024-06-09 at 19 39 15

Possibly related?

thomasp85 commented 3 months ago

The root issue is that systemfonts matches based on the family name, not the post script name. I'll look into if this is possible to add, but I'm not sure if this is doable on all systems

RoyalTS commented 3 months ago

Is there a way to hack around this in the meantime?

thomasp85 commented 3 months ago

try with dev systemfonts. I just pushed a potential fix

RoyalTS commented 3 months ago

Problem solved, it seems like. Thank you much!