Browse Source

Fixed some SVG parsing bugs

tags/2021-05-28
ed 5 years ago
parent
commit
d498575976
1 changed files with 23 additions and 6 deletions
  1. +23
    -6
      modules/juce_gui_basics/drawables/juce_SVGParser.cpp

+ 23
- 6
modules/juce_gui_basics/drawables/juce_SVGParser.cpp View File

@@ -365,18 +365,19 @@ public:
if (parseCoordsOrSkip (d, p1, false)) if (parseCoordsOrSkip (d, p1, false))
{ {
String num; String num;
bool flagValue = false;
if (parseNextNumber (d, num, 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)) if (parseCoordsOrSkip (d, p2, false))
{ {
@@ -1064,7 +1065,7 @@ private:
if (xml->hasTagName ("use")) if (xml->hasTagName ("use"))
return useText (xml); return useText (xml);
if (! xml->hasTagName ("text"))
if (! xml->hasTagName ("text") && ! xml->hasTagNameIgnoringNamespace ("tspan"))
return nullptr; return nullptr;
Array<float> xCoords, yCoords, dxCoords, dyCoords; Array<float> xCoords, yCoords, dxCoords, dyCoords;
@@ -1501,6 +1502,22 @@ private:
return true; 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 Colour parseColour (const XmlPath& xml, StringRef attributeName, const Colour defaultColour) const
{ {


Loading…
Cancel
Save