diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2025-02-03 22:37:36 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-03 22:37:36 +0100 |
| commit | 497fbcfab5734aac889f15b72384a6a8631fffa4 (patch) | |
| tree | 1f1a690a6108d7e4e0fac599d4e554edae9db6f9 /lib/lettering/font_variant.py | |
| parent | e1c6d8c5956c7c3c5e158c1f7415edd5bc1a0cc1 (diff) | |
Add debug variable to enable sew stack elements (#3476)
Diffstat (limited to 'lib/lettering/font_variant.py')
| -rw-r--r-- | lib/lettering/font_variant.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/lettering/font_variant.py b/lib/lettering/font_variant.py index 9d3793a6..baf7c09f 100644 --- a/lib/lettering/font_variant.py +++ b/lib/lettering/font_variant.py @@ -4,6 +4,7 @@ # Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. import os +from collections import defaultdict import inkex @@ -99,15 +100,20 @@ class FontVariant(object): group.attrib.pop('display', None) def _apply_transforms(self, svg): + self.clip_transforms = defaultdict(list) # apply transforms to paths and use tags - for element in svg.iterdescendants((SVG_PATH_TAG, SVG_USE_TAG)): + for element in svg.iterdescendants((SVG_PATH_TAG, SVG_USE_TAG, SVG_GROUP_TAG)): transform = element.composed_transform() + + if element.clip is not None: + self.clip_transforms[element.clip] = element.composed_transform() + if element.tag == SVG_GROUP_TAG: + continue if element.tag == SVG_PATH_TAG: path = element.path.transform(transform) element.set_path(path) element.attrib.pop("transform", None) - - if element.tag == SVG_USE_TAG: + elif element.tag == SVG_USE_TAG: oldx = element.get('x', 0) oldy = element.get('y', 0) newx, newy = transform.apply_to_point((oldx, oldy)) @@ -115,6 +121,13 @@ class FontVariant(object): element.set('y', newy) element.attrib.pop("transform", None) + for clip, transform in self.clip_transforms.items(): + for element in clip.iterdescendants(): + if element.tag == SVG_PATH_TAG: + path = element.path.transform(transform) + element.set_path(path) + element.attrib.pop("transform", None) + # remove transforms after they have been applied for group in svg.iterdescendants(SVG_GROUP_TAG): group.attrib.pop('transform', None) |
