From d49857597639b1df8b07cd59b3d823c966b3882b Mon Sep 17 00:00:00 2001 From: ed Date: Wed, 23 Oct 2019 11:40:39 +0100 Subject: [PATCH] Fixed some SVG parsing bugs --- .../drawables/juce_SVGParser.cpp | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/modules/juce_gui_basics/drawables/juce_SVGParser.cpp b/modules/juce_gui_basics/drawables/juce_SVGParser.cpp index 4f3b7ea574..d425a89308 100644 --- a/modules/juce_gui_basics/drawables/juce_SVGParser.cpp +++ b/modules/juce_gui_basics/drawables/juce_SVGParser.cpp @@ -365,18 +365,19 @@ public: if (parseCoordsOrSkip (d, p1, false)) { String num; + bool flagValue = false; if (parseNextNumber (d, num, false)) { - const float angle = degreesToRadians (num.getFloatValue()); + auto angle = degreesToRadians (num.getFloatValue()); - if (parseNextNumber (d, num, false)) + if (parseNextFlag (d, flagValue)) { - const bool largeArc = num.getIntValue() != 0; + auto largeArc = flagValue; - if (parseNextNumber (d, num, false)) + if (parseNextFlag (d, flagValue)) { - const bool sweep = num.getIntValue() != 0; + auto sweep = flagValue; if (parseCoordsOrSkip (d, p2, false)) { @@ -1064,7 +1065,7 @@ private: if (xml->hasTagName ("use")) return useText (xml); - if (! xml->hasTagName ("text")) + if (! xml->hasTagName ("text") && ! xml->hasTagNameIgnoringNamespace ("tspan")) return nullptr; Array xCoords, yCoords, dxCoords, dyCoords; @@ -1501,6 +1502,22 @@ private: return true; } + static bool parseNextFlag (String::CharPointerType& text, bool& value) + { + while (text.isWhitespace() || *text == ',') + ++text; + + if (*text != '0' && *text != '1') + return false; + + value = *(text++) != '0'; + + while (text.isWhitespace() || *text == ',') + ++text; + + return true; + } + //============================================================================== Colour parseColour (const XmlPath& xml, StringRef attributeName, const Colour defaultColour) const {