SVG icon indicating copy to clipboard operation
SVG copied to clipboard

Text not centred when multiple tspan elements are used

Open jojje888 opened this issue 6 years ago • 4 comments

When using the following markup in a browser (Edge, Chrome, Firefox) the text is properly centred. SVG seems to centre on the first <tspan> and the rest of the text will be rendered too much to the right.

<svg width="250" height="40" viewBox="0 0 250 40" xmlns="http://www.w3.org/2000/svg"> <rect x="0" y="0" width="100%" height="100%" style="fill: none; stroke: black; stroke-width: 0.25;" /> <text x="125" y="25" font-size="10" font-family="Verdana, Helvetica, sans-serif" text-anchor="middle"> <tspan id="patient-age">x</tspan> <tspan> year old </tspan> <tspan id="patient-gender">(gender)</tspan> </text> </svg>

jojje888 avatar May 18 '19 17:05 jojje888

I have this same problem, is there already a solution? Or some workaround?

vhogendoorn avatar Oct 04 '19 12:10 vhogendoorn

Unfortunately, there is no solution yet. While checking this, I also found that the rectangle in the test image does is no longer drawn - probably an unrelated regression.

mrbean-bremen avatar Oct 06 '19 17:10 mrbean-bremen

Still not working. Any idea? I found out, that since version 2.4.0 it stopped working v2 3 0 v2 4 0 <text x="14731.0" y="-42910.0" id="text507-4-1-7-1" transform="scale(1,-1)"><tspan id="tspan505-5-0-1-2" style="font-size:1066.66662598px;font-family:Arial;text-align:center;text-anchor:middle">{#W1#}</tspan></text>

boschem avatar Feb 26 '20 14:02 boschem

I'm having the same issue when using tspan. Is there a solution yet?

trapi789 avatar Dec 15 '20 18:12 trapi789