-
Hi everyone, this is my first time starting a discussion on GitHub - if there is anything I can improve in how I report issues, please let me know :) I’m encountering a rendering issue in the plot viewer when embedding custom fonts using the However, when I execute the same code in RStudio, the plot renders correctly and the spacing is fine — which leads me to believe this is not an issue with Additional context: Currently I'm using:
Here is the example code I used:
Thanks in advance for any ideas or suggestions, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
@thomasp85 it looks like this might be a ragg issue? With ragg ![]() With ![]() # Restart R and run this as your first command for it to work
# options(ark.ragg = FALSE)
library(tidyverse)
library(showtext)
font_add_google("Roboto Condensed", "roboto")
showtext_opts(dpi = 400)
showtext_auto()
ggplot(mtcars, aes(mpg, wt)) +
geom_point() +
labs(
x = "Miles per gallon",
y = "Weight"
) +
theme(text = element_text(family = "roboto", size = 12)) |
Beta Was this translation helpful? Give feedback.
-
showtext works by hacking into the graphics device, hijacking it's text rendering routines and inserting it's own. So any issue with showtext is it's own fault, not that of the graphics device, unless you can show that the device has issues without showtext. There is no upside to using showtext here - ragg has access to all fonts on the system and systemfonts provide easy download and installation from google fonts and other repositories. If you really want to use showtext then you can switch to the default graphics device as Davis has shown |
Beta Was this translation helpful? Give feedback.
-
My guess at what's going on is that showtext correctly hijacks the shadow device, resulting in correct spacing calculations, but doesn't correctly hijacks the playback device giving the discrepancy we observe. When not using ragg these two are the same devices ( |
Beta Was this translation helpful? Give feedback.
showtext works by hacking into the graphics device, hijacking it's text rendering routines and inserting it's own. So any issue with showtext is it's own fault, not that of the graphics device, unless you can show that the device has issues without showtext.
There is no upside to using showtext here - ragg has access to all fonts on the system and systemfonts provide easy download and installation from google fonts and other repositories. If you really want to use showtext then you can switch to the default graphics device as Davis has shown