From 7445b91851f6bd4abc255490f917f6c578bbf0f1 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Thu, 10 Nov 2022 14:03:32 +0100 Subject: [PATCH] lettering: ignore invalid glyph layers (#1892) --- lib/elements/fill_stitch.py | 3 ++- lib/lettering/font_variant.py | 5 ++++- lib/stitches/fill.py | 2 +- lib/stitches/guided_fill.py | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/elements/fill_stitch.py b/lib/elements/fill_stitch.py index ca44e3ccd..a52489521 100644 --- a/lib/elements/fill_stitch.py +++ b/lib/elements/fill_stitch.py @@ -216,7 +216,8 @@ class FillStitch(EmbroideryElement): @property @param('staggers', _('Stagger rows this many times before repeating'), - tooltip=_('Length of the cycle by which successive stitch rows are staggered. Fractional values are allowed and can have less visible diagonals than integer values.'), + tooltip=_('Length of the cycle by which successive stitch rows are staggered.' + 'Fractional values are allowed and can have less visible diagonals than integer values.'), type='int', sort_index=6, select_items=[('fill_method', 0), ('fill_method', 2), ('fill_method', 3)], diff --git a/lib/lettering/font_variant.py b/lib/lettering/font_variant.py index a7f353fea..ecdba137e 100644 --- a/lib/lettering/font_variant.py +++ b/lib/lettering/font_variant.py @@ -69,7 +69,10 @@ class FontVariant(object): self._clean_group(layer) layer.attrib[INKSCAPE_LABEL] = layer.attrib[INKSCAPE_LABEL].replace("GlyphLayer-", "", 1) glyph_name = layer.attrib[INKSCAPE_LABEL] - self.glyphs[glyph_name] = Glyph(layer) + try: + self.glyphs[glyph_name] = Glyph(layer) + except AttributeError: + pass def _clean_group(self, group): # We'll repurpose the layer as a container group labelled with the diff --git a/lib/stitches/fill.py b/lib/stitches/fill.py index ed4ff6550..60a0cb7dc 100644 --- a/lib/stitches/fill.py +++ b/lib/stitches/fill.py @@ -38,7 +38,7 @@ def row_num(point, angle, row_spacing): def adjust_stagger(stitch, angle, row_spacing, max_stitch_length, staggers): if staggers == 0: - staggers = 1 # sanity check to avoid division by zero. + staggers = 1 # sanity check to avoid division by zero. this_row_num = row_num(stitch, angle, row_spacing) stagger_phase = (this_row_num / staggers) % 1 stagger_offset = stagger_phase * max_stitch_length diff --git a/lib/stitches/guided_fill.py b/lib/stitches/guided_fill.py index 6a92f8e88..14c58b7a3 100644 --- a/lib/stitches/guided_fill.py +++ b/lib/stitches/guided_fill.py @@ -149,7 +149,7 @@ def take_only_line_strings(thing): def apply_stitches(line, max_stitch_length, num_staggers, row_spacing, row_num): if num_staggers == 0: - num_staggers = 1 # sanity check to avoid division by zero. + num_staggers = 1 # sanity check to avoid division by zero. start = ((row_num / num_staggers) % 1) * max_stitch_length projections = np.arange(start, line.length, max_stitch_length) points = np.array([line.interpolate(projection).coords[0] for projection in projections])