diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2023-12-29 17:00:41 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-29 17:00:41 +0100 |
| commit | fd01c2e2f1b9bfb972377492c7769b6b62170193 (patch) | |
| tree | fff515f83c8d5a8f91ac7476224d9cec3d70e76f /lib/extensions/letters_to_font.py | |
| parent | 3f37c05a7d411412faa521d1c3b9dd59b426725f (diff) | |
Stitch plan: escape labels (#2644)
Diffstat (limited to 'lib/extensions/letters_to_font.py')
| -rw-r--r-- | lib/extensions/letters_to_font.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/extensions/letters_to_font.py b/lib/extensions/letters_to_font.py index d4d9e60a..e779b5d1 100644 --- a/lib/extensions/letters_to_font.py +++ b/lib/extensions/letters_to_font.py @@ -4,6 +4,7 @@ # Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. import os +from html import escape, unescape from pathlib import Path import inkex @@ -42,7 +43,8 @@ class LettersToFont(InkstitchExtension): group = None for glyph in glyphs: letter = self.get_glyph_element(glyph) - label = "GlyphLayer-%s" % letter.get(INKSCAPE_LABEL, ' ').split('.')[0][-1] + label = unescape(letter.get(INKSCAPE_LABEL, ' ')).split('.')[0][-1] + label = f"GlyphLayer-{ label }" group = inkex.Group(attrib={ INKSCAPE_LABEL: label, INKSCAPE_GROUPMODE: "layer", @@ -79,8 +81,11 @@ class LettersToFont(InkstitchExtension): stitch_plan = generate_stitch_plan(str(glyph), self.options.import_commands) # we received a stitch plan wrapped in an svg document, we only need the stitch_plan group # this group carries the name of the file, so we can search for it. - stitch_plan = stitch_plan.xpath('.//*[@inkscape:label="%s"]' % os.path.basename(glyph), namespaces=inkex.NSS)[0] + label = os.path.basename(glyph) + search_string = f'.//*[@inkscape:label="{ escape(label) }"]' + stitch_plan = stitch_plan.xpath(search_string, namespaces=inkex.NSS)[0] stitch_plan.attrib.pop(INKSCAPE_GROUPMODE) + stitch_plan.label = label return stitch_plan def insert_baseline(self): |
