tibold / svg-explorer-extension

Extension module for Windows Explorer to render SVG thumbnails, so that you can have an overview of your SVG files
Other
3.22k stars 193 forks source link

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

Open geekley opened 6 years ago

geekley commented 6 years ago

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 commented 6 years ago

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.

ionum commented 6 years ago

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

tibold commented 4 years ago

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

ionum commented 4 years ago

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...