I have some graphics done in my favourite Inkscape and I need it to be Tiny SVG compliant in order to be able to drive it later pragmatically by QtSVG.
Collecting tiny bits and pieces from many different sources, I came with a following procedure:
- Save as..
- Choosing "Optimized SVG"
- In the optimization dialog I checked (translated to EN):
- Options
- [x] Shorten color values
- [x] Convert CSS properties to XML
- [x] Collapse groups
- [x] Create groups for similar attributes
- [ ] Keep editor data
- [ ] Keep unreferenced definitions
- [x] Work around renderer bugs
- SVG output
- [ ] Remove XML declaration
- [x] Remove metadata <<< Note: Important <<<
- [ ] Remove comments
- [x] Embed raster images
- [ ] Enable viewboxing
- [x] Format output with line-breaks and indentation
- [ ] Strip the "xml:space" attribute from the root SVG element
- ID
- [ ] Remove unused IDs
- [ ] Shorten IDs
- [x] Preserve manually created IDs not ending with digits
- Options
Now it works, if the graphics does not contain a text. However I need the graphics to contain text, basically AFAIK meaning it must contain <text>
elements.
My Inkscape is 1.0.1 running on OpenSuSE Leap 15.3 Linux system with "Optimized SVG" extension for Scour of version 0.31+. System tells me I have python3-scour
0.37-1.45.
The default format of the output for a text field from Inkscape is:
<text id="T1m" transform="translate(-4.4781 -24.9064)"
fill="#000000" font-family="sans-serif" font-size="10.5833px"
letter-spacing="0px" word-spacing="0px">
<tspan x="46.580078" y="138.18859">
<tspan>T</tspan>
<tspan baseline-shift="sub" font-size="65%">1m</tspan>
<tspan>=15°C</tspan>
</tspan>
</text>
That gives me errors like:
qt.svg: <input>:207:212: Could not add child element to parent element because the types are incorrect.
qt.svg: <input>:207:273: Could not add child element to parent element because the types are incorrect.
qt.svg: <input>:207:298: Could not add child element to parent element because the types are incorrect.
...and the program subsequently crashes.
If I manually edit it removing <tspan>
elements:
<text id="T1m" transform="translate(-4.4781 -24.9064)" fill="#000000" font-family="sans-serif" font-size="10.5833px" letter-spacing="0px" word-spacing="0px">T1m=15°C</text>
...then I get no errors, but also no text in the graphics.
Could anyone advise how to get a compliant Tiny SVG from Inkscape? I.e. a change to the output dialogue, a CLI conversion tool or even a text-editor changes that make the text elements to work...