Skip to content

Instantly share code, notes, and snippets.

@mbr
Created April 29, 2013 11:24
Show Gist options
  • Save mbr/5481042 to your computer and use it in GitHub Desktop.
Save mbr/5481042 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mbr
Copy link
Author

mbr commented Apr 29, 2013

This will break with cairosvg 0.5 with the following error:

Traceback (most recent call last):
  File "/home/marc/.virtualenvs/svglue/bin/cairosvg", line 25, in <module>
    cairosvg.main()
  File "/home/marc/.virtualenvs/svglue/lib/python2.7/site-packages/cairosvg/__init__.py", line 92, in main
    SURFACES[output_format.upper()].convert(**kwargs)
  File "/home/marc/.virtualenvs/svglue/lib/python2.7/site-packages/cairosvg/surface/__init__.py", line 79, in convert
    cls(tree, output, dpi).finish()
  File "/home/marc/.virtualenvs/svglue/lib/python2.7/site-packages/cairosvg/surface/__init__.py", line 128, in __init__
    self.draw_root(tree)
  File "/home/marc/.virtualenvs/svglue/lib/python2.7/site-packages/cairosvg/surface/__init__.py", line 353, in draw_root
    self.draw(node)
  File "/home/marc/.virtualenvs/svglue/lib/python2.7/site-packages/cairosvg/surface/__init__.py", line 315, in draw
    self.draw(child, stroke_and_fill)
  File "/home/marc/.virtualenvs/svglue/lib/python2.7/site-packages/cairosvg/surface/__init__.py", line 327, in draw
    self.context.paint_with_alpha(opacity)
cairo.Error: Context.pop_group without matching Context.push_group

The issue seems to be with the nested tspan elements. Removing the inner causes it to work correctly.

The image is valid SVG: http://validator.w3.org/check?uri=https%3A%2F%2Fgist.github.com%2Fmbr%2F5481042%2Fraw%2F06f0c1d802081f47a60dcddf4b78c90d77524096%2Fbroken.svg&charset=%28detect+automatically%29&doctype=Inline&group=0

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