From b11488bb157992950cbcb109377b281c4c79ad45 Mon Sep 17 00:00:00 2001 From: oehhar Date: Tue, 22 Nov 2022 15:21:46 +0000 Subject: nanosvg#167: complex path rendered wrong: https://github.com/memononen/nanosvg/commit/f0a3e1034dd22e2e87e5db22401e44998383124e --- generic/nanosvg.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/generic/nanosvg.h b/generic/nanosvg.h index d3cfba2..862b7d4 100644 --- a/generic/nanosvg.h +++ b/generic/nanosvg.h @@ -1266,6 +1266,19 @@ static const char* nsvg__parseNumber(const char* s, char* it, const int size) return s; } +static const char* nsvg__getNextPathItemWhenArcFlag(const char* s, char* it) +{ + it[0] = '\0'; + while (*s && (nsvg__isspace(*s) || *s == ',')) s++; + if (!*s) return s; + if (*s == '0' || *s == '1') { + it[0] = *s++; + it[1] = '\0'; + return s; + } + return s; +} + static const char* nsvg__getNextPathItem(const char* s, char* it) { it[0] = '\0'; @@ -2374,7 +2387,11 @@ static void nsvg__parsePath(NSVGparser* p, const char** attr) nargs = 0; while (*s) { - s = nsvg__getNextPathItem(s, item); + item[0] = '\0'; + if ((cmd == 'A' || cmd == 'a') && (nargs == 3 || nargs == 4)) + s = nsvg__getNextPathItemWhenArcFlag(s, item); + if (!*item) + s = nsvg__getNextPathItem(s, item); if (!*item) break; if (cmd != '\0' && nsvg__isCoordinate(item)) { if (nargs < 10) -- cgit v0.12