diff options
Diffstat (limited to 'io_curve_svg/import_svg.py')
-rw-r--r-- | io_curve_svg/import_svg.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/io_curve_svg/import_svg.py b/io_curve_svg/import_svg.py index 4cf5052b..f3f89508 100644 --- a/io_curve_svg/import_svg.py +++ b/io_curve_svg/import_svg.py @@ -407,6 +407,10 @@ def SVGParseStyles(node, context): styles['useFill'] = True styles['fill'] = SVGGetMaterial(val, context) + if styles['useFill'] is None: + styles['useFill'] = True + styles['fill'] = SVGGetMaterial('#000', context) + return styles if styles['useFill'] is None: @@ -419,6 +423,10 @@ def SVGParseStyles(node, context): styles['useFill'] = True styles['fill'] = SVGGetMaterial(fill, context) + if styles['useFill'] is None: + styles['useFill'] = True + styles['fill'] = SVGGetMaterial('#000', context) + return styles #### SVG path helpers #### @@ -482,6 +490,16 @@ class SVGPathData: return self._data[self._index] + def lookupNext(self): + """ + get next token without moving pointer + """ + + if self.eof(): + return None + + return self._data[self._index] + def next(self): """ Return current token and go to next one @@ -584,6 +602,27 @@ class SVGPathParser: self._splines.append(self._spline) + if len(self._spline['points']) > 0: + # Not sure bout specifications, but Illustrator could create + # last point at the same position, as start point (which was + # reached by MoveTo command) to set needed handle coords. + # It's also could use last point at last position to make path + # filled. + + first = self._spline['points'][0] + if abs(first['x'] - x) < 1e-6 and abs(first['y'] - y) < 1e-6: + if handle_left is not None: + first['handle_left'] = handle_left + first['handle_left_type'] = 'FREE' + + if handle_left_type != 'VECTOR': + first['handle_left_type'] = handle_left_type + + if self._data.eof() or self._data.lookupNext().lower() == 'm': + self._spline['closed'] = True + + return + point = {'x': x, 'y': y, |