Add a check to prevent we make path data longer by "optimization"

This commit is contained in:
Eduard Braun 2016-08-31 07:06:42 +02:00
parent 21e6c7491b
commit 0c63344ea4
3 changed files with 18 additions and 2 deletions

View file

@ -2286,8 +2286,12 @@ def cleanPath(element, options) :
path = newPath
newPathStr = serializePath(path, options)
numBytesSavedInPathData += ( len(oldPathStr) - len(newPathStr) )
element.setAttribute('d', newPathStr)
# if for whatever reason we actually made the path longer don't use it
# TODO: maybe we could compare path lengths after each optimization step and use the shortest
if len(newPathStr) <= len(oldPathStr):
numBytesSavedInPathData += ( len(oldPathStr) - len(newPathStr) )
element.setAttribute('d', newPathStr)