Skip to content
Open
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
60 changes: 34 additions & 26 deletions cairosvg/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,32 +419,40 @@ def draw(self, node):

# Fill and stroke
if self.stroke_and_fill and visible and node.tag in TAGS:
# Fill
self.context.save()
paint_source, paint_color = paint(node.get('fill', 'black'))
if not gradient_or_pattern(self, node, paint_source):
if node.get('fill-rule') == 'evenodd':
self.context.set_fill_rule(cairo.FILL_RULE_EVEN_ODD)
self.context.set_source_rgba(*color(paint_color, fill_opacity))
if TAGS[node.tag] == text:
self.cursor_position = save_cursor[0]
self.cursor_d_position = save_cursor[1]
self.text_path_width = save_cursor[2]
text(self, node, draw_as_text=True)
else:
self.context.fill_preserve()
self.context.restore()

# Stroke
self.context.save()
self.context.set_line_width(
size(self, node.get('stroke-width', '1')))
paint_source, paint_color = paint(node.get('stroke'))
if not gradient_or_pattern(self, node, paint_source):
self.context.set_source_rgba(
*color(paint_color, stroke_opacity))
self.context.stroke()
self.context.restore()
order = [1, 0] if node.get('paint-order', "fill") == "stroke" \
else [0, 1]
for i in order:
if i == 0:
# Fill
self.context.save()
paint_source, paint_color = \
paint(node.get('fill', 'black'))
if not gradient_or_pattern(self, node, paint_source):
if node.get('fill-rule') == 'evenodd':
self.context.set_fill_rule(
cairo.FILL_RULE_EVEN_ODD)
self.context.set_source_rgba(
*color(paint_color, fill_opacity))
if TAGS[node.tag] == text:
self.cursor_position = save_cursor[0]
self.cursor_d_position = save_cursor[1]
self.text_path_width = save_cursor[2]
text(self, node, draw_as_text=True)
else:
self.context.fill_preserve()
self.context.restore()
else:
# Stroke
self.context.save()
self.context.set_line_width(
size(self, node.get('stroke-width', '1')))
paint_source, paint_color = paint(node.get('stroke'))
if not gradient_or_pattern(self, node, paint_source):
self.context.set_source_rgba(
*color(paint_color, stroke_opacity))
self.context.stroke_preserve()
self.context.restore()
self.context.new_path()
elif not visible:
self.context.new_path()

Expand Down