Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rendering issue with bgroup from plotmath #132

Closed
benjaminhlina opened this issue Apr 14, 2023 · 4 comments
Closed

rendering issue with bgroup from plotmath #132

benjaminhlina opened this issue Apr 14, 2023 · 4 comments

Comments

@benjaminhlina
Copy link

benjaminhlina commented Apr 14, 2023

bgroup from base R's plotmath should render big parentheses when saved as a png (or other image filetype). However, it renders as a bunch of boxes stacked on top of each other. This issue only seems to occur on Windows machines which this SO post from December 2022 confirms. It originally seemed that this was resolved as of R4.2.3 but it seems to not be the case.

library(ggplot2)
ggplot(data = mtcars, aes(x = wt, y = mpg)) +
  annotate("text", x = 2.5, y = 25, 
           label = "bgroup('(',atop(x,y),')')", 
           parse = TRUE) +
  annotate("text", x = 3.5, y = 25, 
           label = "group('(',atop(x,y),')')", 
           parse = TRUE)
ggsave("test_1.png", plot = last_plot())

test_1

I can also reproduce the issue with a base plot with the following code

ragg::agg_png(filename = "test_2.png")
plot(0, xlim = c(0, 1), ylim = c(0, 1))
text(0.5, 0.5, expression(bgroup('(',atop(x,y),')')))
dev.off()

test_2

Rendering of bgroup should look like the following:

grDevices::png(filename = "test_3.png")
plot(0, xlim = c(0, 1), ylim = c(0, 1))
text(0.5, 0.5, expression(bgroup('(',atop(x,y),')')))
dev.off()

test_3

@benjaminhlina
Copy link
Author

benjaminhlina commented Apr 20, 2023

This seems related to #51 however changing the device used in the plot pane as per the instructions in the ragg readme does not resolve this issue as per @thomasp85 suggests at the end of #51. In RStudio, within the plot pane it renders properly. However it only renders improperly when saving using ggplot2::ggsave() or ragg::agg_png().

@thomasp85
Copy link
Member

This is not really related to #51 which was never about ragg but about the default windows device.

This is a reproducible issue in ragg - interestingly I cannot reproduce it on a Mac using the symbol font from windows

@thomasp85
Copy link
Member

Relevant document from @pmur002

https://developer.r-project.org/Blog/public/2020/04/17/changes-to-symbol-fonts-for-cairo-graphics-devices/index.html

It is the exact same issue as was seen on Fedora. The Windows symbol font does not map the PUA region... I'll see how I can best alleviate this in ragg/systemfonts

@benjaminhlina
Copy link
Author

Thank you for taking a look at this and figuring out how to fix it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants