mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
svg: fix incorrect assignment of <stop> elements
If the svg contained an unsupported element with <stop> elements, they were incorrectly assigned to the last loaded gradient. Now fixed. @Issue: https://github.com/thorvg/thorvg/issues/3321
This commit is contained in:
parent
c554205238
commit
731f137d2d
3 changed files with 263 additions and 3 deletions
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 35 KiB |
|
@ -1 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="2500" height="2500" viewBox="0 0 192.756 192.756"><g fill-rule="evenodd" clip-rule="evenodd"><path fill="#fff" d="M0 0h192.756v192.756H0V0z"/><path fill="#2d4f9e" d="M156.547 110.788v13.033h3.098v-4.857h2.746v-2.666h-2.688v-5.51h-3.156zM144.863 124.888v10.663h14.84v-10.663h-14.84zm11.807 8.06h-8.775v-5.457h8.775v5.457zM149.1 111.263s-.176 7.05 5.258 9.894l-1.811 2.229s-3.975-2.644-4.908-5.665c-.936 3.021-4.908 5.665-4.908 5.665l-1.811-2.229c5.434-2.844 5.258-9.894 5.258-9.894h2.922zM183.619 110.788v13.033h-3.096v-5.982h-4.031v-2.666h3.971v-4.385h3.156zM175.908 123.675c-4.609 0-8.346 2.851-8.346 6.367s3.736 6.367 8.346 6.367c4.607 0 8.344-2.851 8.344-6.367s-3.736-6.367-8.344-6.367zm0 9.924c-2.867 0-5.191-1.593-5.191-3.557 0-1.965 2.324-3.557 5.191-3.557 2.865 0 5.188 1.592 5.188 3.557 0 1.964-2.323 3.557-5.188 3.557zM172.547 111.263s-.174 7.05 5.26 9.894l-1.811 2.229s-3.975-2.644-4.908-5.665c-.936 3.021-4.908 5.665-4.908 5.665l-1.811-2.229c5.434-2.844 5.258-9.894 5.258-9.894h2.92zM152.955 57.15c-32.988-3.323-81.185 3.869-114.766 17.621l-2.008.873c.617-.032 1.037-.004 1.037-.004 5.589.155 5.249 3.681 5.249 3.681l.008 2.152H38.02v-1.462c0-1.036-1.244-1.105-1.244-1.105-.955 0-1.176.657-1.176.657-.528 1.002.375 1.866.375 1.866.46.518 2.778 1.607 2.778 1.607.75.293 1.959 1.054 1.959 1.054 2.266 1.382 2.062 4.008 2.062 4.008v1.729c-.272 4.285-6.1 4.164-6.1 4.164-6.101 0-5.967-4.06-5.967-4.06v-2.122h4.748v1.462c0 1.244 1.186 1.299 1.186 1.299 1.294.052 1.404-1.219 1.404-1.219.177-1.235-1.166-2.012-1.166-2.012a257.858 257.858 0 0 1-3.544-1.901c-1.091-.726-1.533-1.383-1.533-1.383-.784-1.001-.733-2.557-.733-2.557V80.15c0-1.866.494-2.401.494-2.401.006-.013.016-.024.023-.037-32.86 15.581-29.113 31.778 1.507 34.782 33.471 3.283 84.017-3.244 117.979-18.639-.107.006-.203.026-.314.026 0 0-5.748.472-5.885-4.228v-9.088s-.715-5.01 5.725-5.01c0 0 4.193-.139 5.301 2.384 0 0 .547.676.4 3.465h-4.465v-1.43s-.01-1.154-1.168-1.154c0 0-1.209.052-1.209 1.02v9.399s-.051 1.262 1.312 1.262c0 0 1.117-.025 1.117-1.351v-2.719h-1.217V83.9h5.736v5.339s-.014 1.124-.475 1.78c0 0-.34.515-.549.746l1.867-.948c30.088-15.639 26.322-30.584-4.293-33.667zM55.734 93.377L53.998 80.07h-.39l-1.736 13.307H47.13l2.93-17.161h7.486l2.931 17.161h-4.743zm23.969.018l-.106-12.929h-.306l-2.307 12.926h-4.635l-2.336-12.931h-.346l-.053 12.934h-4.406l.372-17.166h7.443l1.425 9.395h.348l1.492-9.394h7.369l.477 17.165h-4.431zm21.822-5.298v1.729c-.273 4.285-6.1 4.164-6.1 4.164-6.1 0-5.968-4.06-5.968-4.06v-2.122h4.748v1.462c0 1.244 1.186 1.299 1.186 1.299 1.295.052 1.404-1.219 1.404-1.219.177-1.235-1.166-2.012-1.166-2.012-1.328-.691-3.544-1.901-3.544-1.901-1.09-.726-1.534-1.383-1.534-1.383-.784-1.001-.733-2.557-.733-2.557v-1.348c0-1.866.495-2.401.495-2.401 1.261-2.402 5.656-2.108 5.656-2.108 5.588.155 5.249 3.681 5.249 3.681l.008 2.152H96.77v-1.462c0-1.036-1.243-1.105-1.243-1.105-.955 0-1.176.657-1.176.657-.528 1.002.375 1.866.375 1.866.46.518 2.777 1.607 2.777 1.607.75.293 1.961 1.054 1.961 1.054 2.266 1.381 2.061 4.007 2.061 4.007zm17.582 1.159c0 4.718-5.893 4.646-5.893 4.646-6.781 0-6.285-4.872-6.285-4.872V76.159h4.84l.016 12.976c0 1.454 1.361 1.381 1.361 1.381 1.295 0 1.23-1.417 1.23-1.417V76.16h4.73v13.096h.001zm20.084 4.142h-5.26l-4.693-10.497h-.197l.264 10.496h-4.412V76.235h5.422l4.533 10.41h.193l-.318-10.413h4.469v17.166h-.001z"/></g></svg>
|
Before Width: | Height: | Size: 3.3 KiB |
|
@ -3382,6 +3382,7 @@ static void _svgLoaderParserXmlOpen(SvgLoaderData* loader, const char* content,
|
|||
if (node->type != SvgNodeType::Defs || !empty) {
|
||||
loader->stack.push(node);
|
||||
}
|
||||
loader->latestGradient = nullptr;
|
||||
} else if ((method = _findGraphicsFactory(tagName))) {
|
||||
if (loader->stack.count > 0) parent = loader->stack.last();
|
||||
else parent = loader->doc;
|
||||
|
@ -3392,6 +3393,7 @@ static void _svgLoaderParserXmlOpen(SvgLoaderData* loader, const char* content,
|
|||
loader->stack.push(defs);
|
||||
loader->currentGraphicsNode = node;
|
||||
}
|
||||
loader->latestGradient = nullptr;
|
||||
} else if ((gradientMethod = _findGradientFactory(tagName))) {
|
||||
SvgStyleGradient* gradient;
|
||||
gradient = gradientMethod(loader, attrs, attrsLength);
|
||||
|
@ -3417,8 +3419,9 @@ static void _svgLoaderParserXmlOpen(SvgLoaderData* loader, const char* content,
|
|||
loader->svgParse->flags = SvgStopStyleFlags::StopDefault;
|
||||
simpleXmlParseAttributes(attrs, attrsLength, _attrParseStops, loader);
|
||||
loader->latestGradient->stops.push(loader->svgParse->gradStop);
|
||||
} else if (!isIgnoreUnsupportedLogElements(tagName)) {
|
||||
TVGLOG("SVG", "Unsupported elements used [Elements: %s]", tagName);
|
||||
} else {
|
||||
loader->latestGradient = nullptr;
|
||||
if (!isIgnoreUnsupportedLogElements(tagName)) TVGLOG("SVG", "Unsupported elements used [Elements: %s]", tagName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue