From bad59b4ec4b6587788bbf6d1e6cb0c3dcc85a2a6 Mon Sep 17 00:00:00 2001 From: buliabyak Date: Mon, 7 Apr 2008 00:51:24 +0000 Subject: [PATCH] fix bug with garbage lines caused with close_path when part of a subpath is optimized out --- src/display/inkscape-cairo.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/display/inkscape-cairo.cpp b/src/display/inkscape-cairo.cpp index 5d87d39b2..d2e2b7d8b 100644 --- a/src/display/inkscape-cairo.cpp +++ b/src/display/inkscape-cairo.cpp @@ -56,17 +56,27 @@ feed_curve_to_cairo (cairo_t *ct, NArtBpath *bpath, NR::Matrix trans, NR::Maybe< view.growBy (stroke_width); NR::Rect swept; bool closed = false; + NR::Point startpath(0,0); for (int i = 0; bpath[i].code != NR_END; i++) { switch (bpath[i].code) { case NR_MOVETO_OPEN: case NR_MOVETO: - if (closed) cairo_close_path(ct); - closed = (bpath[i].code == NR_MOVETO); + if (closed) { + // we cannot use close_path because some of the curves/lines may have been optimized out + cairo_line_to(ct, startpath[NR::X], startpath[NR::Y]); + } next[NR::X] = bpath[i].x3; next[NR::Y] = bpath[i].y3; next *= trans; last = next; next -= shift; + if (bpath[i].code == NR_MOVETO) { + // remember the start point of the subpath, for closing it later + closed = true; + startpath = next; + } else { + closed = false; + } cairo_move_to(ct, next[NR::X], next[NR::Y]); break; -- 2.30.2