Skip to content

Commit

Permalink
Fix viewbox_list
Browse files Browse the repository at this point in the history
  • Loading branch information
rjadr authored Jul 30, 2022
1 parent 2f9cabe commit db56853
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion deepsvg/svglib/svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,13 @@ def from_str(svg_str: str):
svg_dom = expatbuilder.parseString(svg_str, False)
svg_root = svg_dom.getElementsByTagName('svg')[0]

viewbox_list = list(map(float, svg_root.getAttribute("viewBox").split(" ")))
viewbox_list = None
if svg_root.hasAttribute('viewBox'):
viewbox = list(map(float, svg_root.getAttribute("viewBox").split(" ")))
elif svg_root.hasAttribute('width') and svg_root.hasAttribute('height'):
viewbox_list = [0, 0, float(svg_root.getAttribute("width")), float(svg_root.getAttribute("height"))]
else:
raise Exception('<svg/> does not contain width, height attributes, nor viewBox. please double check the SVG')
view_box = Bbox(*viewbox_list)

primitives = {
Expand Down

0 comments on commit db56853

Please sign in to comment.