svg2pdf.js icon indicating copy to clipboard operation
svg2pdf.js copied to clipboard

Incorrect kerning between tSpans

Open HackbrettXXX opened this issue 6 years ago • 3 comments

The space between the following tSpans is slightly too large

<text><tSpan>f</tSpan><tSpan>e<tSpan></text>

compared to

<text>fe</text>

HackbrettXXX avatar Jan 15 '19 16:01 HackbrettXXX

This is a minor issue. This would require a lot of work that is probably not worth the investment. There are more complex issues with font rendering and font-kerning that should be addressed, first, IMHO.

yGuy avatar Jan 17 '19 10:01 yGuy

I may have a solution that involves measuring the text a few times, I'll code it up and see how well it works.

There also appears to be a difference between Chrome and Firefox when it comes to inter-tspan kerning. Chrome behaves like font-kerning is set to none whereas Firefox applies kerning.

<svg font-family="serif" viewBox="0 0 550 600" xmlns="http://www.w3.org/2000/svg">
  <text y="50" x="20" style="font-kerning: auto;"><tspan>agbW</tspan><tspan>A</tspan></text>
  <text y="70" x="20" style="font-kerning: auto;">agbWA</text>
  <text y="90" x="20" style="font-kerning: none;"><tspan>agbW</tspan><tspan>A</tspan></text>
</svg>

image

Mrfence97 avatar Nov 15 '20 15:11 Mrfence97

@Mrfence97 thanks for digging into this. Did you make any progress?

HackbrettXXX avatar Nov 24 '20 10:11 HackbrettXXX