summaryrefslogtreecommitdiff
path: root/lib/lettering/font.py
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2024-12-29 19:54:15 +0100
committerGitHub <noreply@github.com>2024-12-29 19:54:15 +0100
commitf807ccf49af5414a6d5e812d6a544ef9e68f103a (patch)
tree7038ba47dd7a4ab192cdbc7421b64b4f397d701c /lib/lettering/font.py
parentc429bf5f17eae8a33382127ca5bec7fecfda9d9b (diff)
Fix lettering commands (#3385)
Diffstat (limited to 'lib/lettering/font.py')
-rw-r--r--lib/lettering/font.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/lettering/font.py b/lib/lettering/font.py
index 5c56ca0b..6857c830 100644
--- a/lib/lettering/font.py
+++ b/lib/lettering/font.py
@@ -231,8 +231,18 @@ class Font(object):
position.x = 0
position.y += self.leading
- bounding_box = letter_group.bounding_box()
+ # We need to insert the destination_group now, even though it is possibly empty
+ # otherwise we could run into a FragmentError in case a glyph contains commands
+ destination_group.append(letter_group)
+ bounding_box = None
+ try:
+ bounding_box = letter_group.bounding_box()
+ except AttributeError:
+ # letter group is None
+ continue
+ # remove destination_group if it is empty
if not bounding_box:
+ destination_group.remove(letter_group)
continue
line_width = bounding_box.width
@@ -243,8 +253,6 @@ class Font(object):
if text_align == 2:
letter_group.transform = f'translate({-line_width}, 0)'
- destination_group.append(letter_group)
-
if text_align in [3, 4]:
for line_group in destination_group.iterchildren():
# print(line_group.label, len(line_group), file=sys.stderr)