Tuesday, 7 October 2014

[PATCH] Fix relative move commands following a path close.

---
src/svgtiny.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/src/svgtiny.c b/src/svgtiny.c
index 5be977f..0757e5f 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);

@@ -472,6 +473,10 @@ svgtiny_code svgtiny_parse_path(dom_element *path,
= x;
p[i++] = last_cubic_y = last_quad_y = last_y
= y;
+ if (*command == 'M' || *command == 'm') {
+ subpath_first_x = x;
+ subpath_first_y = y;
+ }
s += n;
plot_command = svgtiny_PATH_LINE;
} while (sscanf(s, "%f %f %n", &x, &y, &n) == 2);
@@ -481,6 +486,10 @@ 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) {
--
1.9.1

No comments:

Post a Comment