mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-04 03:40:07 +00:00
SVG parser fix for files that contain a viewBox but no preserveAspectRatio attribute.
This commit is contained in:
parent
609794ceae
commit
37d8f5ca41
1 changed files with 23 additions and 24 deletions
|
|
@ -85,31 +85,13 @@ public:
|
|||
newState.viewBoxW = vwh.x;
|
||||
newState.viewBoxH = vwh.y;
|
||||
|
||||
int placementFlags = 0;
|
||||
const int placementFlags = parsePlacementFlags (xml->getStringAttribute ("preserveAspectRatio").trim());
|
||||
|
||||
const String aspect (xml->getStringAttribute ("preserveAspectRatio"));
|
||||
|
||||
if (aspect.containsIgnoreCase ("none"))
|
||||
{
|
||||
placementFlags = RectanglePlacement::stretchToFit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (aspect.containsIgnoreCase ("slice")) placementFlags |= RectanglePlacement::fillDestination;
|
||||
|
||||
if (aspect.containsIgnoreCase ("xMin")) placementFlags |= RectanglePlacement::xLeft;
|
||||
else if (aspect.containsIgnoreCase ("xMax")) placementFlags |= RectanglePlacement::xRight;
|
||||
else placementFlags |= RectanglePlacement::xMid;
|
||||
|
||||
if (aspect.containsIgnoreCase ("yMin")) placementFlags |= RectanglePlacement::yTop;
|
||||
else if (aspect.containsIgnoreCase ("yMax")) placementFlags |= RectanglePlacement::yBottom;
|
||||
else placementFlags |= RectanglePlacement::yMid;
|
||||
}
|
||||
|
||||
newState.transform = RectanglePlacement (placementFlags)
|
||||
.getTransformToFit (Rectangle<float> (viewboxXY.x, viewboxXY.y, vwh.x, vwh.y),
|
||||
Rectangle<float> (newState.width, newState.height))
|
||||
.followedBy (newState.transform);
|
||||
if (placementFlags != 0)
|
||||
newState.transform = RectanglePlacement (placementFlags)
|
||||
.getTransformToFit (Rectangle<float> (viewboxXY.x, viewboxXY.y, vwh.x, vwh.y),
|
||||
Rectangle<float> (newState.width, newState.height))
|
||||
.followedBy (newState.transform);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -1004,6 +986,23 @@ private:
|
|||
return String();
|
||||
}
|
||||
|
||||
static int parsePlacementFlags (const String& align) noexcept
|
||||
{
|
||||
if (align.isEmpty())
|
||||
return 0;
|
||||
|
||||
if (align.containsIgnoreCase ("none"))
|
||||
return RectanglePlacement::stretchToFit;
|
||||
|
||||
return (align.containsIgnoreCase ("slice") ? RectanglePlacement::fillDestination : 0)
|
||||
| (align.containsIgnoreCase ("xMin") ? RectanglePlacement::xLeft
|
||||
: (align.containsIgnoreCase ("xMax") ? RectanglePlacement::xRight
|
||||
: RectanglePlacement::xMid))
|
||||
| (align.containsIgnoreCase ("yMin") ? RectanglePlacement::yTop
|
||||
: (align.containsIgnoreCase ("yMax") ? RectanglePlacement::yBottom
|
||||
: RectanglePlacement::yMid));
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static bool isIdentifierChar (const juce_wchar c)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue