svg-explorer-extension icon indicating copy to clipboard operation
svg-explorer-extension copied to clipboard

<tspan> tag with x and y attributes not being rendered correctly

Open geekley opened this issue 6 years ago • 4 comments

Simple example:

<svg
   xmlns="http://www.w3.org/2000/svg"
   height="45" width="200">
  <text x="0" y="15">
  <tspan x="0" y="15">Above</tspan>
  <tspan x="0" y="30">Center</tspan>
  <tspan x="0" y="45">Below</tspan>
  </text>
</svg>

This should render each <tspan> in a separate line, but the preview is not doing this. It is ignoring either the <tspan> tag or its x and y attributes.

Oddly enough, unlike #4, the width and height attributes on the root element, are not ignored in this example.

geekley avatar Jul 30 '18 23:07 geekley

It turns out that QtSVG follows SVG Tiny specification, which does not support x and y positioning, and a lot of other features.

Positional attributes such as 'x', 'y', and 'rotate' are not available on 'tspan' in SVG Tiny 1.2.

Can't we use some other library which supports full SVG? Maybe someone wants to fork?

Or maybe there could be some setting or something that calls Inkscape or ImageMagick via command line to render the file, if it's installed.

geekley avatar Jul 31 '18 14:07 geekley

@maphew, cairo library https://cairographics.org/ would be a better choice ....

ionum avatar Aug 02 '18 10:08 ionum

@ionum, do you have some samples how to render SVGs using cairo?

tibold avatar Dec 29 '19 17:12 tibold

Not really. But have a look at the documentation: https://www.cairographics.org/documentation/

Someone wrote a python script for converting svg to png (with support of cairo libs) https://cairosvg.org/documentation/

Maybe this helps...

ionum avatar Jan 24 '20 13:01 ionum