From f807ccf49af5414a6d5e812d6a544ef9e68f103a Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Sun, 29 Dec 2024 19:54:15 +0100 Subject: Fix lettering commands (#3385) --- lib/lettering/font.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'lib/lettering/font.py') 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) -- cgit v1.2.3