diff --git a/src/pixie/fileformats/svg.nim b/src/pixie/fileformats/svg.nim index c4f70dd1..23fdf5c7 100644 --- a/src/pixie/fileformats/svg.nim +++ b/src/pixie/fileformats/svg.nim @@ -500,11 +500,10 @@ proc parseSvgElement( raise newException(PixieError, "Unsupported SVG tag: " & node.tag) proc parseSvg*( - data: string | XmlNode, width = 0, height = 0 + root: XmlNode; width = 0; height = 0 ): Svg {.raises: [PixieError].} = ## Parse SVG XML. Defaults to the SVG's view box size. try: - let root = parseXml(data) if root.tag != "svg": failInvalid() @@ -545,6 +544,16 @@ proc parseSvg*( except: raise currentExceptionAsPixieError() +proc parseSvg*( + data: string; width = 0; height = 0 +): Svg {.raises: [PixieError].} = + ## Parse SVG XML. Defaults to the SVG's view box size. + try: parseSvg(parseXml(data), width, height) + except PixieError as e: + raise e + except: + raise currentExceptionAsPixieError() + proc newImage*(svg: Svg): Image {.raises: [PixieError].} = ## Render SVG and return the image. result = newImage(svg.width, svg.height)