From d78699ab7845ad9d8067ce5f28d3a2057998ceaa Mon Sep 17 00:00:00 2001 From: jaspervdg Date: Mon, 28 Apr 2008 15:53:11 +0000 Subject: [PATCH] Fix for closepath handling of SVG path data parser and tolerance for approximately closed check in gnome-canvas-bpath-util.cpp. --- src/svg/gnome-canvas-bpath-util.cpp | 4 +--- src/svg/svg-path.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/svg/gnome-canvas-bpath-util.cpp b/src/svg/gnome-canvas-bpath-util.cpp index ab67b20be..49a4162fb 100644 --- a/src/svg/gnome-canvas-bpath-util.cpp +++ b/src/svg/gnome-canvas-bpath-util.cpp @@ -31,7 +31,7 @@ static inline NR::Point distTo(GnomeCanvasBpathDef *bpd, size_t idx1, size_t idx static bool isApproximatelyClosed(GnomeCanvasBpathDef *bpd) { int const np = prefs_get_int_attribute("options.svgoutput", "numericprecision", 8); - double const precision = pow(10.0, -np); // This roughly corresponds to a difference below the last significant digit + double const precision = 5*pow(10.0, -np); // This roughly corresponds to a difference below the last significant digit int const initial = bpd->moveto_idx; int const current = bpd->n_bpath - 1; int const previous = bpd->n_bpath - 2; @@ -187,8 +187,6 @@ gnome_canvas_bpath_def_closepath (GnomeCanvasBpathDef *bpd) // If it is approximately closed we close it here to prevent internal logic to fail. // In addition it is probably better to continue working with this end point, as it // is probably more precise than the original. - // NOTE: At the very least sp_bpath_check_subpath will fail, but it is not unreasonable - // to assume that there might be more places where similar problems would occur. bpath[n_bpath-1].x3 = bpath[bpd->moveto_idx].x3; bpath[n_bpath-1].y3 = bpath[bpd->moveto_idx].y3; } diff --git a/src/svg/svg-path.cpp b/src/svg/svg-path.cpp index c645133a6..3823071b0 100644 --- a/src/svg/svg-path.cpp +++ b/src/svg/svg-path.cpp @@ -386,12 +386,14 @@ static void rsvg_parse_path_do_cmd(RSVGParsePathCtx *ctx, bool final, const char if (ctx->param == 0) { rsvg_bpath_def_closepath (ctx->bpath); + ctx->cpx = ctx->rpx = ctx->spx; + ctx->cpy = ctx->rpy = ctx->spy; if (next_cmd != 0 && next_cmd != 'm') { // This makes sure we do the right moveto if the closepath is followed by anything other than a moveto ctx->cmd = 'm'; - ctx->params[0] = ctx->cpx = ctx->rpx = ctx->spx; - ctx->params[1] = ctx->cpy = ctx->rpy = ctx->spy; + ctx->params[0] = ctx->cpx; + ctx->params[1] = ctx->cpy; ctx->param = 2; rsvg_parse_path_do_cmd(ctx, final, next_cmd); } -- 2.30.2