From c2aef4a98f6cabef9a6d38a33035f02cf8233dd0 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin <sergey.vfx@gmail.com> Date: Mon, 29 Oct 2018 16:09:02 +0100 Subject: [PATCH] SVG: Fix wrong closed path with quadratic segments Fixes T55601: SVG import wrong shape --- io_curve_svg/import_svg.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/io_curve_svg/import_svg.py b/io_curve_svg/import_svg.py index 4298470bf..6b45d91d0 100644 --- a/io_curve_svg/import_svg.py +++ b/io_curve_svg/import_svg.py @@ -666,6 +666,9 @@ class SVGPathParser: if last['handle_right_type'] == 'VECTOR' and handle_left_type == 'FREE': last['handle_right'] = (last['x'], last['y']) last['handle_right_type'] = 'FREE' + if last['handle_right_type'] == 'FREE' and handle_left_type == 'VECTOR': + handle_left = (x, y) + handle_left_type = 'FREE' point = {'x': x, 'y': y, @@ -1230,6 +1233,19 @@ class SVGGeometryPATH(SVGGeometry): for spline in self._splines: act_spline = None + + if spline['closed'] and len(spline['points']) >= 2: + first = spline['points'][0] + last = spline['points'][-1] + if ( first['handle_left_type'] == 'FREE' and + last['handle_right_type'] == 'VECTOR'): + last['handle_right_type'] = 'FREE' + last['handle_right'] = (last['x'], last['y']) + if ( last['handle_right_type'] == 'FREE' and + first['handle_left_type'] == 'VECTOR'): + first['handle_left_type'] = 'FREE' + first['handle_left'] = (first['x'], first['y']) + for point in spline['points']: co = self._transformCoord((point['x'], point['y'])) -- GitLab