summaryrefslogtreecommitdiff
path: root/src/svgtiny.c
diff options
context:
space:
mode:
authorPaul Mecklenburg <paul.mecklenburg@gmail.com>2014-10-10 23:13:02 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2014-10-10 23:13:02 +0100
commita285e3942eb288b92a3ba77eaf564d55340b2f9d (patch)
tree9ae96ac5b5adeac662d98eb4db4299795e739706 /src/svgtiny.c
parentf21ee86fd200931897c03149ca8df5570ef24120 (diff)
downloadlibsvgtiny-a285e3942eb288b92a3ba77eaf564d55340b2f9d.tar.gz
libsvgtiny-a285e3942eb288b92a3ba77eaf564d55340b2f9d.tar.bz2
Fix relative move commands following a path close.
Both 'M' and 'm' are moves and therefore start a new (sub)path. In either case the location should be cached so that a later 'close path' (z or Z) knows the location it is returning to. The location is not written to 'p', since it is assumed that the client code remembers. If the next move is relative (lowercase), then it's important that last_x, last_y were correctly updated while processing Z/z.
Diffstat (limited to 'src/svgtiny.c')
-rw-r--r--src/svgtiny.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/svgtiny.c b/src/svgtiny.c
index 5be977f..413697c 100644
--- a/src/svgtiny.c
+++ b/src/svgtiny.c
@@ -407,6 +407,7 @@ svgtiny_code svgtiny_parse_path(dom_element *path,
float last_x = 0, last_y = 0;
float last_cubic_x = 0, last_cubic_y = 0;
float last_quad_x = 0, last_quad_y = 0;
+ float subpath_first_x = 0, subpath_first_y = 0;
svgtiny_setup_state_local(&state);
@@ -468,6 +469,10 @@ svgtiny_code svgtiny_parse_path(dom_element *path,
x += last_x;
y += last_y;
}
+ if (plot_command == svgtiny_PATH_MOVE) {
+ subpath_first_x = x;
+ subpath_first_y = y;
+ }
p[i++] = last_cubic_x = last_quad_x = last_x
= x;
p[i++] = last_cubic_y = last_quad_y = last_y
@@ -481,6 +486,8 @@ svgtiny_code svgtiny_parse_path(dom_element *path,
/*LOG(("closepath"));*/
p[i++] = svgtiny_PATH_CLOSE;
s += n;
+ last_cubic_x = last_quad_x = last_x = subpath_first_x;
+ last_cubic_y = last_quad_y = last_y = subpath_first_y;
/* horizontal lineto (H, h) (1 argument) */
} else if (sscanf(s, " %1[Hh] %f %n", command, &x, &n) == 2) {