mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
svg_loader: handling zero width/height viewbox
For svgs with the width and/or height value set to zero rendering was disabled - the load api return Result:Unknown and draw - Result::InsufficientCondition. Now an empty scene is added, so that both, load and draw, return Result::Success.
This commit is contained in:
parent
9e8980a1f7
commit
be361221df
2 changed files with 8 additions and 1 deletions
|
@ -3186,6 +3186,12 @@ SvgLoader::~SvgLoader()
|
|||
|
||||
void SvgLoader::run(unsigned tid)
|
||||
{
|
||||
//According to the SVG standard the value of the width/height of the viewbox set to 0 disables rendering
|
||||
if (renderingDisabled) {
|
||||
root = Scene::gen();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!simpleXmlParse(content, size, true, _svgLoaderParser, &(loaderData))) return;
|
||||
|
||||
if (loaderData.doc) {
|
||||
|
@ -3316,7 +3322,7 @@ bool SvgLoader::read()
|
|||
if (((uint32_t)viewFlag & (uint32_t)SvgViewFlag::Viewbox) &&
|
||||
(fabsf(vw) <= FLT_EPSILON || fabsf(vh) <= FLT_EPSILON)) {
|
||||
TVGLOG("SVG", "The <viewBox> width and/or height set to 0 - rendering disabled.");
|
||||
return false;
|
||||
renderingDisabled = true;
|
||||
}
|
||||
|
||||
TaskScheduler::request(this);
|
||||
|
|
|
@ -54,6 +54,7 @@ private:
|
|||
SvgViewFlag viewFlag = SvgViewFlag::None;
|
||||
AspectRatioAlign align = AspectRatioAlign::XMidYMid;
|
||||
AspectRatioMeetOrSlice meetOrSlice = AspectRatioMeetOrSlice::Meet;
|
||||
bool renderingDisabled = false;
|
||||
|
||||
bool header();
|
||||
void clear();
|
||||
|
|
Loading…
Add table
Reference in a new issue