Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ Known limitations
of supported attributes is still limited
- clipping is limited to single paths, no mask support
- color gradients are not supported (limitation of reportlab)
- SVG ``ForeignObject`` elements are not supported.
- SVG ``ForeignObject`` elements are not supported
- limited support for SVG ``switch`` elements.


Examples
Expand Down
11 changes: 11 additions & 0 deletions svglib/svglib.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,9 @@ def renderNode(self, node, parent=None):
parent.add(item)
elif name == "clipPath":
item = self.renderG(node)
elif name == "switch": # process only default case
item = self.renderSwitch(node)
parent.add(item)
elif name in self.handled_shapes:
if name == 'image':
# We resolve the image target at renderer level because it can point
Expand Down Expand Up @@ -826,6 +829,14 @@ def renderG(self, node, clipping=None):

return gr

def renderSwitch(self, node):
gr = Group()
for child in node.iter_children():
if child.getAttribute('requiredFeatures') == '':
self.renderNode(child, parent=gr)
break
return gr

def renderStyle(self, node):
self.attrConverter.css_rules.add_styles(node.text or "")

Expand Down