Fix (partial) T92713: SVG importer: Ensure path closed before MoveTo

This can fix some broken paths in T92713, like the following PeerTube icon.

| before | now
| {F13615071} | {F13615072}

But some icons are still incomplete due to other issues.

Differential Revision: https://developer.blender.org/D16143
This commit is contained in:
linhsu0723 2022-10-06 11:13:06 +02:00 committed by Sergey Sharybin
parent c71c092b75
commit eb09be71a9
1 changed files with 5 additions and 2 deletions

View File

@ -884,14 +884,17 @@ class SVGPathParser:
if cmd is None:
raise Exception('Unknown path command: {0}' . format(code))
if cmd in {'Z', 'z'}:
if code in {'Z', 'z'}:
closed = True
else:
closed = False
if code in {'M', 'm'} and self._use_fill and not closed:
self._pathClose('z') # Ensure closed before MoveTo path command
cmd(code)
if self._use_fill and not closed:
self._pathClose('z')
self._pathClose('z') # Ensure closed at the end of parsing
def getSplines(self):
"""