News for hackers. Stuff that matters.
Re:SVG: The Good, the Bad and the Ugly by thangalin on Friday February 12, 2021 @12:37PM (#26116222)
> If you need to generate basic shapes it's fairly straightforward.

You'd think so. While integrating TeX into my editor[0], using JMathTeX[1] as a starting point, I wanted to convert font glyphs to vector paths. At the time, every Java-based SVG renderer (Batik, JFreeSVG, SVG Salamander) suffered from the exact same performance problem: they all used Java's DecimalFormat class to convert floating point numbers to strings. These strings were then concatenated as paths into the output document. Sometimes the strings were re-copied numerous times because of buffer re-allocations and other reasons. (Part 5 of my series[2] on developing a TeX-oriented text editor covers this in depth.)

To get great performance---in Java, at least---even for basic shapes requires a sufficiently large, reusable buffer that doesn't incur memory re-allocations and an efficient algorithm to convert floats to strings---such as Ryu[3]. See my implementation that converts glyph paths to vector paths for details[4]. With these two changes I was able to improve upon JFreeSVG's implementation four-fold.

[0]: https://github.com/DaveJarvis/keenwrite (my editor)

[1]: https://github.com/DaveJarvis/JMathTeX/ (my fork)

[2]: https://bell-sw.com/announcements/2020/11/02/TeXnical-Writin... (my blog series)

[3]: https://github.com/ulfjack/ryu

[4]: https://github.com/DaveJarvis/JMathTeX/blob/d2d678717505765b...

There are no comments on this comment yet.