summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2009-11-22 13:32:37 (GMT)
committer James Bursa <james@netsurf-browser.org>2009-11-22 13:32:37 (GMT)
commit2d35f3325216927539a026c2e74c0f874e04a137 (patch)
treec631835350296f634a56be977e1da68a2b18bbbb
parent8df2f2d97cdd34a4b60dfb86a70d66fcc7ad674e (diff)
downloadlibsvgtiny-2d35f3325216927539a026c2e74c0f874e04a137.tar.gz
libsvgtiny-2d35f3325216927539a026c2e74c0f874e04a137.tar.bz2
Start implementing arcs in paths. Fix crash when an empty path has a gradient fill.
svn path=/trunk/libsvgtiny/; revision=9682
-rw-r--r--src/svgtiny.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/svgtiny.c b/src/svgtiny.c
index 56f0028..aae0b0e 100644
--- a/src/svgtiny.c
+++ b/src/svgtiny.c
@@ -240,7 +240,7 @@ svgtiny_code svgtiny_parse_path(xmlNode *path,
while (*s) {
char command[2];
int plot_command;
- float x, y, x1, y1, x2, y2;
+ float x, y, x1, y1, x2, y2, rx, ry, rotation, large_arc, sweep;
int n;
/* moveto (M, m), lineto (L, l) (2 arguments) */
@@ -395,14 +395,39 @@ svgtiny_code svgtiny_parse_path(xmlNode *path,
} while (sscanf(s, "%f %f %n",
&x, &y, &n) == 2);
+ /* elliptical arc (A, a) (7 arguments) */
+ } else if (sscanf(s, " %1[Aa] %f %f %f %f %f %f %f %n", command,
+ &rx, &ry, &rotation, &large_arc, &sweep,
+ &x, &y, &n) == 8) {
+ do {
+ p[i++] = svgtiny_PATH_LINE;
+ if (*command == 'a') {
+ x += last_x;
+ y += last_y;
+ }
+ p[i++] = last_cubic_x = last_quad_x = last_x
+ = x;
+ p[i++] = last_cubic_y = last_quad_y = last_y
+ = y;
+ s += n;
+ } while (sscanf(s, "%f %f %f %f %f %f %f %n",
+ &rx, &ry, &rotation, &large_arc, &sweep,
+ &x, &y, &n) == 7);
+
} else {
- /*LOG(("parse failed at \"%s\"", s));*/
+ fprintf(stderr, "parse failed at \"%s\"\n", s);
break;
}
}
xmlFree(path_d);
+ if (i <= 4) {
+ /* no real segments in path */
+ free(p);
+ return svgtiny_OK;
+ }
+
return svgtiny_add_path(p, i, &state);
}