From eb09be71a96c4fe910fdc43373be5ec08b419d2c Mon Sep 17 00:00:00 2001
From: linhsu0723 <linhsu0723>
Date: Thu, 6 Oct 2022 11:13:06 +0200
Subject: [PATCH] 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
---
 io_curve_svg/import_svg.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/io_curve_svg/import_svg.py b/io_curve_svg/import_svg.py
index 28f407649..e84c9949c 100644
--- a/io_curve_svg/import_svg.py
+++ b/io_curve_svg/import_svg.py
@@ -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):
         """
-- 
GitLab