summaryrefslogtreecommitdiff
path: root/lib/lettering/glyph.py
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2024-11-12 19:07:24 +0100
committerGitHub <noreply@github.com>2024-11-12 19:07:24 +0100
commit45dda2616d4d636759136e2c65998670ea06855c (patch)
tree0dd33c7ab51cb69b0b6128df0095c5f84e876f2b /lib/lettering/glyph.py
parent7c99a138d12bcd5f9f4cdbfd3ff7c2b15ec890e4 (diff)
Clipped groups (#3261)
Diffstat (limited to 'lib/lettering/glyph.py')
-rw-r--r--lib/lettering/glyph.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/lettering/glyph.py b/lib/lettering/glyph.py
index 0b916fc0..a3a9df71 100644
--- a/lib/lettering/glyph.py
+++ b/lib/lettering/glyph.py
@@ -3,6 +3,7 @@
# Copyright (c) 2010 Authors
# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
+from collections import defaultdict
from copy import copy
from inkex import paths, transforms, units
@@ -36,11 +37,20 @@ class Glyph(object):
"""
self._process_baseline(group.getroottree().getroot())
+ self.clips = self._process_clips(group)
self.node = self._process_group(group)
self._process_bbox()
self._move_to_origin()
self._process_commands()
+ def _process_clips(self, group):
+ clips = defaultdict(list)
+ for node in group.iterdescendants():
+ if node.clip:
+ node_id = node.get_id()
+ clips[node_id] = node.clip
+ return clips
+
def _process_group(self, group):
new_group = copy(group)
# new_group.attrib.pop('transform', None)
@@ -124,3 +134,11 @@ class Glyph(object):
x, y = transform.apply_to_point((oldx, oldy))
node.set('x', x)
node.set('y', y)
+
+ # transform clips
+ for node in self.node.iterdescendants():
+ node_id = node.get_id()
+ if node_id in self.clips:
+ clip = self.clips[node_id]
+ for childnode in clip.iterchildren():
+ childnode.transform @= transform