svglib
svglib copied to clipboard
svglib ignores <switch> nodes
Is it possible to add support for at least default cases (without requiredFeatures)?
My case:
I use rst2pdf to compile document containing svg images.
Those svg images are exported from draw.io.
draw.io uses <switch> when exporting to svg for all text blocks.
Example:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="121" height="61" viewBox="-0.5 -0.5 121 61">
<rect width="120" height="60" rx="9" ry="9" fill="#FFF" stroke="#000" pointer-events="all"/>
<switch transform="translate(-.5 -.5)">
<foreignObject pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" style="overflow:visible;text-align:left">
<div xmlns="http://www.w3.org/1999/xhtml" style="display:flex;align-items:unsafe center;justify-content:unsafe center;width:118px;height:1px;padding-top:30px;margin-left:1px">
<div data-drawio-colors="color: rgb(0, 0, 0);" style="box-sizing:border-box;font-size:0;text-align:center">
<div style="display:inline-block;font-size:12px;font-family:Helvetica;color:#000;line-height:1.2;pointer-events:all;white-space:normal;overflow-wrap:normal">
some text
</div>
</div>
</div>
</foreignObject>
<text x="60" y="34" font-family="Helvetica" font-size="12" text-anchor="middle">some text</text>
</switch>
</svg>
As a result, all text in the images is lost after assembly.
Thank you for raising your first issue! Your help to improve svglib is much appreciated!
Possible, certainly, but someone will need to add this support.
Found out that just default case processing is not enough for me, but maybe this would help someone.
Just to add some context: https://www.w3.org/TR/SVG/struct.html#SwitchElement