yWorks / svg2pdf.js

A javascript-only SVG to PDF conversion utility that runs in the browser. Brought to you by yWorks - the diagramming experts
MIT License
666 stars 104 forks source link

Incorrect kerning between tSpans #68

Open HackbrettXXX opened 5 years ago

HackbrettXXX commented 5 years ago

The space between the following tSpans is slightly too large

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

compared to

<text>fe</text>
yGuy commented 5 years ago

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.

Mrfence97 commented 3 years ago

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

HackbrettXXX commented 3 years ago

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