diff --git a/Lib/fontTools/svgLib/path/shapes.py b/Lib/fontTools/svgLib/path/shapes.py
index a83274e4b..efbfc91a6 100644
--- a/Lib/fontTools/svgLib/path/shapes.py
+++ b/Lib/fontTools/svgLib/path/shapes.py
@@ -116,6 +116,18 @@ class PathBuilder(object):
self.A(r, r, cx + r, cy, large_arc=1)
self.A(r, r, cx - r, cy, large_arc=1)
+ def _parse_ellipse(self, ellipse):
+ cx = float(ellipse.attrib.get('cx', 0))
+ cy = float(ellipse.attrib.get('cy', 0))
+ rx = float(ellipse.attrib.get('rx'))
+ ry = float(ellipse.attrib.get('ry'))
+
+ # arc doesn't seem to like being a complete shape, draw two halves
+ self._start_path()
+ self.M(cx - rx, cy)
+ self.A(rx, ry, cx + rx, cy, large_arc=1)
+ self.A(rx, ry, cx - rx, cy, large_arc=1)
+
def add_path_from_element(self, el):
tag = _strip_xml_ns(el.tag)
parse_fn = getattr(self, '_parse_%s' % tag.lower(), None)
diff --git a/Tests/svgLib/path/shapes_test.py b/Tests/svgLib/path/shapes_test.py
index ee9ddeae6..6202d60f6 100644
--- a/Tests/svgLib/path/shapes_test.py
+++ b/Tests/svgLib/path/shapes_test.py
@@ -1,7 +1,6 @@
from __future__ import print_function, absolute_import, division
from fontTools.misc.py23 import *
-from fontTools.pens.recordingPen import RecordingPen
from fontTools.svgLib.path import shapes
from fontTools.misc import etree
import pytest
@@ -55,7 +54,17 @@ import pytest
(
"",
"M10.5,6.5 A1.5,1.5 0 1 1 13.5,6.5 A1.5,1.5 0 1 1 10.5,6.5"
- )
+ ),
+ # ellipse
+ (
+ '',
+ 'M0,50 A100,50 0 1 1 200,50 A100,50 0 1 1 0,50'
+ ),
+ # ellipse, decimal positioning
+ (
+ '',
+ 'M90.5,50 A10,50.5 0 1 1 110.5,50 A10,50.5 0 1 1 90.5,50'
+ ),
]
)
def test_el_to_path(svg_xml, expected_path):