Code

fix bug with garbage lines caused with close_path when part of a subpath is optimized out
authorbuliabyak <buliabyak@users.sourceforge.net>
Mon, 7 Apr 2008 00:51:24 +0000 (00:51 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Mon, 7 Apr 2008 00:51:24 +0000 (00:51 +0000)
src/display/inkscape-cairo.cpp

index 5d87d39b2f57733e1eccfdd5e1e6f4d3fd81dd4c..d2e2b7d8b12b3554d9c7cd4313bc981c969fd616 100644 (file)
@@ -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;