tibold / svg-explorer-extension

Extension module for Windows Explorer to render SVG thumbnails, so that you can have an overview of your SVG files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

geekley opened this issue · 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.

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.

commented

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

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

commented

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