From 8d9a935eaa13a28e482ed614da92cf034b1556a6 Mon Sep 17 00:00:00 2001 From: Miguel Sousa Date: Tue, 2 Apr 2019 12:46:36 -0700 Subject: [PATCH] [svgLib] Add support for polyline element --- Lib/fontTools/svgLib/path/shapes.py | 5 +++++ Tests/svgLib/path/shapes_test.py | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/Lib/fontTools/svgLib/path/shapes.py b/Lib/fontTools/svgLib/path/shapes.py index a0b529429..ac19a9908 100644 --- a/Lib/fontTools/svgLib/path/shapes.py +++ b/Lib/fontTools/svgLib/path/shapes.py @@ -1,5 +1,6 @@ import re + def _prefer_non_zero(*args): for arg in args: if arg != 0: @@ -123,6 +124,10 @@ class PathBuilder(object): self._start_path('M' + poly.attrib['points']) self._end_path() + def _parse_polyline(self, poly): + if 'points' in poly.attrib: + self._start_path('M' + poly.attrib['points']) + def _parse_circle(self, circle): cx = float(circle.attrib.get('cx', 0)) cy = float(circle.attrib.get('cy', 0)) diff --git a/Tests/svgLib/path/shapes_test.py b/Tests/svgLib/path/shapes_test.py index 550eef623..a7b82eabb 100644 --- a/Tests/svgLib/path/shapes_test.py +++ b/Tests/svgLib/path/shapes_test.py @@ -58,6 +58,12 @@ import pytest "M30,10 50,30 10,30 z", None ), + # polyline + ( + "", + "M30,10 50,30 10,30", + None + ), # circle, minimal valid example ( "",