Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

svglib ignores <switch> nodes #397

Open
ilkoch008 opened this issue Jan 11, 2024 · 4 comments
Open

svglib ignores <switch> nodes #397

ilkoch008 opened this issue Jan 11, 2024 · 4 comments

Comments

@ilkoch008
Copy link

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.

Copy link

Thank you for raising your first issue! Your help to improve svglib is much appreciated!

@claudep
Copy link
Collaborator

claudep commented Jan 11, 2024

Possible, certainly, but someone will need to add this support.

@ilkoch008
Copy link
Author

Found out that just default case processing is not enough for me, but maybe this would help someone.

@deeplook
Copy link
Owner

Just to add some context: https://www.w3.org/TR/SVG/struct.html#SwitchElement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants