From d853548c57a95fbc4d8a62b67df50b0c7e13916e Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Fri, 24 Feb 2017 03:04:15 +0100 Subject: [PATCH] Don't force whitespace for elliptical paths (fixes #89) This was only required in an early draft of the SVG spec (an error that was corrected later, see [1,2]) [1] https://github.com/scour-project/scour/issues/89#issuecomment-244216600 [2] https://github.com/scour-project/scour/issues/89#issuecomment-244337118 --- scour/scour.py | 6 +++--- testscour.py | 9 --------- unittests/path-elliptical-arc-parsing.svg | 4 ---- 3 files changed, 3 insertions(+), 16 deletions(-) delete mode 100644 unittests/path-elliptical-arc-parsing.svg diff --git a/scour/scour.py b/scour/scour.py index 7055db0..ebc44c6 100644 --- a/scour/scour.py +++ b/scour/scour.py @@ -2539,7 +2539,7 @@ def serializePath(pathObj, options): """ # elliptical arc commands must have comma/wsp separating the coordinates # this fixes an issue outlined in Fix https://bugs.launchpad.net/scour/+bug/412754 - return ''.join([cmd + scourCoordinates(data, options, (cmd == 'a'), cmd) for cmd, data in pathObj]) + return ''.join([cmd + scourCoordinates(data, options, path_cmd=cmd) for cmd, data in pathObj]) def serializeTransform(transformObj): @@ -2554,7 +2554,7 @@ def serializeTransform(transformObj): ) -def scourCoordinates(data, options, force_whitespace=False, cmd=''): +def scourCoordinates(data, options, force_whitespace=False, path_cmd=''): """ Serializes coordinate data with some cleanups: - removes all trailing zeros after the decimal @@ -2567,7 +2567,7 @@ def scourCoordinates(data, options, force_whitespace=False, cmd=''): c = 0 previousCoord = '' for coord in data: - cp = ((cmd == 'c' and (c % 6) < 4) or (cmd == 's' and (c % 4) < 2)) + cp = ((path_cmd == 'c' and (c % 6) < 4) or (path_cmd == 's' and (c % 4) < 2)) scouredCoord = scourUnitlessLength(coord, needsRendererWorkaround=options.renderer_workaround, isControlPoint=cp) diff --git a/testscour.py b/testscour.py index 29b70a9..d73090d 100755 --- a/testscour.py +++ b/testscour.py @@ -1640,15 +1640,6 @@ class PropagateCommonAttributesUp(unittest.TestCase): 'Did not move common fill attribute to grandparent') -class PathEllipticalArcParsingCommaWsp(unittest.TestCase): - - def runTest(self): - p = scourXmlFile('unittests/path-elliptical-arc-parsing.svg') \ - .getElementsByTagNameNS(SVGNS, 'path')[0] - self.assertEqual(p.getAttribute('d'), 'm100 100a100 100 0 1 1 -50 100z', - 'Did not parse elliptical arc command properly') - - class RemoveUnusedAttributesOnParent(unittest.TestCase): def runTest(self): diff --git a/unittests/path-elliptical-arc-parsing.svg b/unittests/path-elliptical-arc-parsing.svg deleted file mode 100644 index 77a8cbd..0000000 --- a/unittests/path-elliptical-arc-parsing.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - -