nx10 / httpgd

Asynchronous http server graphics device for R.
https://nx10.github.io/httpgd
GNU General Public License v2.0
368 stars 19 forks source link

Missing spaces in LaTeX expressions when plotting using `latex2exp` #124

Open colinbousige opened 1 year ago

colinbousige commented 1 year ago

Hello,

See original post here where the author of latex2exp tracked the issue to arise from the httpgd plot renderer.

When plotting using httpgd and latex2exp, LaTeX expressions are missing spaces and are distorted. Doing the same plot in the normal R png renderer yields the expected result.

image

To reproduce in a vanilla R terminal:

library(httpgd)
library(latex2exp)
hgd()
plot(TeX(r'($\alpha$ and also $\beta$)'))

yields this: image

instead of this :

library(latex2exp)
plot(TeX(r'($\alpha$ and also $\beta$)'))

image

nx10 commented 1 year ago

Hi!

Thanks for opening the issue. I am very busy currently due to moving, but could you try to replicate the plot with svglite ( https://github.com/r-lib/svglite )? Most of the font rendering code in httpgd is based on it.

colinbousige commented 1 year ago

Hi

And thanks for your answer ! It doesn't seem like I can reproduce the problem with svglite, though:

library(svglite)
library(latex2exp)

svglite("test.svg")
plot(TeX(r'($\alpha$ and also $\beta$)'), cex=4)
dev.off()

The result is OK: test

nx10 commented 1 year ago

Thanks! Definitely a bug in httpgd then. I will investigate as soon as I have a bit of free time.