Closed RobinCoffee closed 6 months ago
Btw this formula "\frac{\sqrt{35x^{15-b^{{{{3}^{a^{b^{c^{d^{e^{f^{g^{h^{i^{j}}}}}}}}}}}}}}}}{2}" albeit very stupid crashes the program. It is valid LaTeX, I checked it several times. This is what it should look like:
Instead I get this error after running ./main:
This is TeX, Version 3.141592653 (INITEX)
**(output.tex
(TeXinputs:plain.tex Preloading the plain format: codes, registers,
parameters, fonts, more fonts, macros, math definitions, output routines,
hyphenation (TeXinputs:hyphen.tex)) [1] )
Output written on output.dvi (1 page, 564 bytes).
Transcript written on output.log.
<nil>
panic: bad command: stack is empty at position 361
goroutine 1 [running, locked to thread]:
main.drawLatex({0x1030595bc?, 0x10304b268?}, 0x14000529e00)
/Users/24ayden.zinter/GOSTUDY-Shared/gui-playground/fyne/main.go:24 +0x130
main.main()
/Users/24ayden.zinter/GOSTUDY-Shared/gui-playground/fyne/main.go:42 +0x200
I just checked what would happen if I removed an exponent ("\frac{\sqrt{35x^{15-b^{{{{3}^{a^{b^{c^{d^{e^{f^{g^{h^{i}}}}}}}}}}}}}}}{2}") and it ran. It looks like this tho:
I'm actually so confused, if you remove another exponent you get a similar error. For some reason rendering this exact amount of exponents doesn't crash. It doesn't start working again until the formula "\frac{\sqrt{35x^{15-b^{3^{a}}}}}{2}" it still fails to render the higher exponents:
This stuff may be related to the scaling issues, idk.
Yes, I've noticed similar issues as reported by https://github.com/tdewolff/canvas/issues/231. The problem is with the star-tex.org/x/tex
library however, and I've actively looked for an improvement but there is no other library it seems. Improving the library is also difficult, it seems to be a non-trivial amount of work and the author(s) and I don't have a lot of time to fix it.
There are two options: implement font parsers for the LaTeX font formats (quite some work), or port the same library for XeTex which has unicode support (quite some work too). Rewriting a formula parser and parsing the GSUB etc tables for fonts would be even more work.
I'm happy if you can find a good alternative, but unfortunately I don't have time for such a large project right now.
No worries, appreciate the fast reply tho. Building with -latex is annoying but I'm willing to deal with it for the time being. I figured star-tex would be the problem.
Works fine with -tags latex. Somewhat annoying, but better than the original solution I came up with of running a KaTeX or Mathjax server locally and integrating it into my application. Maybe once I am a better programmer I can work on a parser or something. For now I will just pretend like the problem doesn't exist. Thanks for all of your help anyway :D
Yes, using the system's LaTeX binary will work if you control the target machine. Great to hear you have that option, and you're always welcome to try and submit PRs if you wish! Thank a lot for all the feedback and I hope this library can help you build something useful ;-)
I am using fyne.io as the renderer, I can't see how anything in my implementation could be influencing the pathing. (It should be noted that this is far better than not rendering at all! Thanks for fixing that part :D ) Here is my implementation:
This works great aside from a few strange rendering bugs: This formula '\int_{2}^{5} \frac{\sqrt{35x^{15-b^{3}}}}{2}' should look like this (shown in Obsidian (which uses MathJax iirc))
In my program it looks like this:
Other similar issues occur with square roots and parenthesis: (these formulas: "\sqrt{\frac{\sqrt{35x^{15-b^{3}}}}{2}}" and "\left({\frac{\sqrt{35x^{15-b^{3}}}}{2}}\right)^2") Obsidian:
My program:
Again, if there are other more pressing bugs tackle those first, just wanted to make you aware about this in case it is an easy fix or you are bored and looking for something to do :P