Closed zhangchen0514 closed 5 years ago
Hmm... your test-case looks convincing. @HackbrettXXX I fail to see that your comment applies, here. Any ideas? It really does seems as if removing that if would fix the issue and in all browsers I tried the above SVG there was no space inserted. Could it be that you had xml-whitespace between the tspans? Do you remember the test-cases that you had when you wrote that comment?
The test case I was referring to is text-placement/spec.svg
. I think the problem is, that in this test case, the tSpans end with a space character, that will get trimmed in line 1551:
transformedText = transformText(node, removeNewlinesAndTrim(tSpan.textContent));
That probably led me to the conclusion, that a space needs to be inserted between tSpans.
Oh - so that's actually two bugs!
This issue is now fixed. However, if you test your file, you will find that the space between the two tSpans is still slightly too large. The reason is missing kerning between tSpans (usually, the distance between "f" and "e" is smaller than between for example "ss"). Fixing this seems quite difficult, though. I'm gonna open a new issue for this.
Why add space between tspans? It looks different from origin svg.
svg: pdf:
test file: test.zip
src: https://github.com/yWorks/svg2pdf.js/blob/dd06aad011a784823ff1465691b2bb261ebeec3c/src/svg2pdf.js#L1428-L1432