Open edemaine opened 11 months ago
Thanks for this bug report. I think the issue is not that the dx is applied in a wrong way but that the space in
<tspan data-tex="x" dx="12.858478000000002"> </tspan>
is trimmed away. The space is a unicode 8202 hair space character. If you replace the hair space with a letter it seems to work as expected.
I think the trim functions use the wrong character set: https://github.com/yWorks/svg2pdf.js/blob/07b8ca12bc8f622c36514ce3899464be526048e6/src/utils/text.ts#L60-L66
I would consider this a very minor bug, because I would argue that this is not best the way to achieve the drawing. Why not apply the dx to the word itself? Nevertheless, I would accept a pull request.
Describe the bug
<tspan dx="...">
seems to offset by an incorrect amount.svg2pdf.js@2.2.0 jspdf@2.5.1
To Reproduce Playground
SVG for reference:
Expected behavior SVG displays with correct offset:
Screenshots PDF displays a smaller offset for the "is" text:
If I chain more such
tspan
s, the reduced horizontal offset accumulates, and the SVG glyphs start overlapping with the text.Desktop
Additional context This arises in SVG generated by my Cocreate software, which renders regular text along with LaTeX rendered by MathJax.