Kolaru / MathTeXEngine.jl

A latex math mode engine in pure Julia.
MIT License
96 stars 20 forks source link

`\langle` and `\rangle` missplaced, `\dagger` renders box #46

Closed ffreyer closed 2 years ago

ffreyer commented 2 years ago

With Makie master text(L"a \langle c^\dagger \rangle b") renders as Screenshot from 2021-12-29 12-27-13

davibarreira commented 2 years ago

The same issue is happening on Luxor, where we just implemented a rendering of LaTeX.

davibarreira commented 2 years ago

@ffreyer , you might try this solution here https://github.com/JuliaGraphics/Luxor.jl/issues/198#issuecomment-1023227129 I have no idea why the solution in the link worked. BTW, it did not work for me.

ffreyer commented 2 years ago

So this had been fine for a while with MathTeXEngine v2.1 for me, but with https://github.com/JuliaPlots/Makie.jl/pull/1785 it's broken again.

I messed around a bit and now I have the suspicion that https://github.com/Kolaru/MathTeXEngine.jl/blob/b3a224f9b4a7380f91ebb7c8f931bd13c387c45a/src/engine/layout.jl#L202 or something similar needs to apply to \langle and \rangle, or maybe even cmex10 symbols in general. Because with that applied \langle and \rangle they look well placed to me.

jbisits commented 2 years ago

@ffreyer did you have any luck with getting \langle and \rangle to render correctly with what you mention above? I am just at the last step of getting some plots ready and have not had any luck. I was hoping to have a look around in MathTeXEngine.jl over the weekend but if you have a good place to start I might be able to save some time!

ffreyer commented 2 years ago

As far as I remember I tried to catch \langle and \rangle in https://github.com/Kolaru/MathTeXEngine.jl/blob/33ef1a0903bfb643a1a9688099737bf6d0c49126/src/engine/layout.jl#L20 and centered vertically.

If you look at the glyphs in cmex10.ttf (e.g. on https://ehubsoft.herokuapp.com/fontviewer/, the font is in MathTexEngine/assets) most of the glyphs are below the baseline. That's why I thought they may all need vertical centering, but there are few exceptions. (\hat, maybe some others?)

jbisits commented 2 years ago

Ah ok! With a bit of post-figure-making editing I managed to get everything looking ok but made no progress on fixing this issue. As you mention above it was all working fine with a previous version of MathTexEngine.jl so I was going to trawl back and see if there were any obvious differences with the layout for the files in cmex10.ttf.

Kolaru commented 2 years ago

Fixed by #67