Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/memononen/nanosvg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCaleb Jones <code@calebjones.net>2018-04-14 02:57:06 +0300
committerCaleb Jones <code@calebjones.net>2018-04-14 02:57:06 +0300
commitd6eabf29c9c10038924e823e693dddef281abee5 (patch)
treea2dcee474437c5a2ac5b34315b9341793dc3b1b1 /src
parent1f17a7eceaf1fff9161cd685db0a86bb935b28fc (diff)
Parse <svg> percentage width for automatic sizing
Instead of calculating percentage coordinates relative to 1px, we calculate them relative to 0px width, that way an explicit <svg width="100%"> will be converted to <svg width="0px"> and trigger the bounding-box sizing calculation.
Diffstat (limited to 'src')
-rw-r--r--src/nanosvg.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/nanosvg.h b/src/nanosvg.h
index 089857f..65ba2a7 100644
--- a/src/nanosvg.h
+++ b/src/nanosvg.h
@@ -2494,9 +2494,9 @@ static void nsvg__parseSVG(NSVGparser* p, const char** attr)
for (i = 0; attr[i]; i += 2) {
if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
if (strcmp(attr[i], "width") == 0) {
- p->image->width = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 1.0f);
+ p->image->width = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 0.0f);
} else if (strcmp(attr[i], "height") == 0) {
- p->image->height = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 1.0f);
+ p->image->height = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 0.0f);
} else if (strcmp(attr[i], "viewBox") == 0) {
sscanf(attr[i + 1], "%f%*[%%, \t]%f%*[%%, \t]%f%*[%%, \t]%f", &p->viewMinx, &p->viewMiny, &p->viewWidth, &p->viewHeight);
} else if (strcmp(attr[i], "preserveAspectRatio") == 0) {