mirror of
https://github.com/thorvg/thorvg.git
synced 2025-07-23 22:58:44 +00:00
svg_loader: fixing percent. calculations of width/height
The conversion to percentages was applied twice. Additionally, when a viewbox value was provided before the width/height, incorrect scaling occurred. @Issue: https://github.com/thorvg/thorvg/issues/1414
This commit is contained in:
parent
21ac44d120
commit
4599067bee
1 changed files with 2 additions and 4 deletions
|
@ -861,17 +861,15 @@ static bool _attrParseSvgNode(void* data, const char* key, const char* value)
|
|||
|
||||
if (!strcmp(key, "width")) {
|
||||
doc->w = _toFloat(loader->svgParse, value, SvgParserLengthType::Horizontal);
|
||||
if (strstr(value, "%")) {
|
||||
if (strstr(value, "%") && !(doc->viewFlag & SvgViewFlag::Viewbox)) {
|
||||
doc->viewFlag = (doc->viewFlag | SvgViewFlag::WidthInPercent);
|
||||
doc->w /= 100.0f;
|
||||
} else {
|
||||
doc->viewFlag = (doc->viewFlag | SvgViewFlag::Width);
|
||||
}
|
||||
} else if (!strcmp(key, "height")) {
|
||||
doc->h = _toFloat(loader->svgParse, value, SvgParserLengthType::Vertical);
|
||||
if (strstr(value, "%")) {
|
||||
if (strstr(value, "%") && !(doc->viewFlag & SvgViewFlag::Viewbox)) {
|
||||
doc->viewFlag = (doc->viewFlag | SvgViewFlag::HeightInPercent);
|
||||
doc->h /= 100.0f;
|
||||
} else {
|
||||
doc->viewFlag = (doc->viewFlag | SvgViewFlag::Height);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue