diff --git a/src/svg/SvgImport.js b/src/svg/SvgImport.js index e4ab3fc7d1..961dcbc52c 100644 --- a/src/svg/SvgImport.js +++ b/src/svg/SvgImport.js @@ -281,11 +281,25 @@ new function() { // https://www.w3.org/TR/SVG/shapes.html#RectElement rect: function(node) { + var rx = SvgElement.get(node, 'rx'); + var ry = SvgElement.get(node, 'ry'); + if (rx === null && ry !== null) { + rx = ry; + } else if (ry === null && rx !== null) { + ry = rx; + } + if (/%\s*$/.test(rx)) { + rx = parseFloat(rx) * rootSize.width / 100; + } + if (/%\s*$/.test(ry)) { + ry = parseFloat(ry) * rootSize.height / 100; + } + var radius = rx !== null && ry !== null ? new Size(rx, ry) : null; return new Shape.Rectangle(new Rectangle( getPoint(node), getSize(node) - ), getSize(node, 'rx', 'ry')); - }, + ), radius); + }, // https://www.w3.org/TR/SVG/shapes.html#LineElement line: function(node) { diff --git a/test/assets/rectangles.svg b/test/assets/rectangles.svg new file mode 100644 index 0000000000..40bd6d7182 --- /dev/null +++ b/test/assets/rectangles.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/test/tests/SvgImport.js b/test/tests/SvgImport.js index 3f8409a706..5443c55cd2 100644 --- a/test/tests/SvgImport.js +++ b/test/tests/SvgImport.js @@ -205,7 +205,8 @@ if (!isNodeContext) { 'gradients-1': {}, 'gradients-2': !isPhantomContext && {}, 'gradients-3': {}, - 'gradients-4': {} + 'gradients-4': {}, + 'rectangles': {} }; Base.each(svgFiles, function(options, name) { if (options) {