diff options
| author | Claudine Peyrat <88194877+claudinepeyrat06@users.noreply.github.com> | 2025-04-26 08:52:31 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-26 08:52:31 +0200 |
| commit | 7497a582840fa94415b56a8b45df593328d644ca (patch) | |
| tree | 6f88b587088d8a02f49ac90961f86ba3f87fb426 /lib/lettering | |
| parent | 4cfb02c370e2f09d59658f652c4b15bd41d46d6e (diff) | |
Claudine/fix font sample (#3684)
* twist monicha
* Update lettering_font_sample.py
* better use default value
* and leave Monicha alone in this branch
* ensure command and marker symbols
---------
Co-authored-by: Kaalleen <reni@allenka.de>
Diffstat (limited to 'lib/lettering')
| -rw-r--r-- | lib/lettering/font.py | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/lib/lettering/font.py b/lib/lettering/font.py index cc81cc9d..50fb804f 100644 --- a/lib/lettering/font.py +++ b/lib/lettering/font.py @@ -11,12 +11,13 @@ from random import randint import inkex -from ..commands import add_commands, ensure_symbol +from ..commands import add_commands, ensure_command_symbols from ..elements import SatinColumn, Stroke, nodes_to_elements from ..exceptions import InkstitchException from ..extensions.lettering_custom_font_dir import get_custom_font_dir from ..i18n import _, get_languages -from ..marker import MARKER, ensure_marker, has_marker, is_grouped_with_marker +from ..marker import (MARKER, ensure_marker_symbols, has_marker, + is_grouped_with_marker) from ..stitches.auto_satin import auto_satin from ..svg.clip import get_clips from ..svg.tags import (CONNECTION_END, CONNECTION_START, EMBROIDERABLE_TAGS, @@ -282,8 +283,8 @@ class Font(object): # add trims self._add_trims(destination_group, text, trim_option, use_trim_symbols, back_and_forth, color_sort) # make sure necessary marker and command symbols are in the defs section - self._ensure_command_symbols(destination_group) - self._ensure_marker_symbols(destination_group) + ensure_command_symbols(destination_group) + ensure_marker_symbols(destination_group) if color_sort != 0 and self.sortable: self.do_color_sort(destination_group, color_sort) @@ -443,7 +444,7 @@ class Font(object): return node - def _update_commands(self, node, glyph, id_extension): + def _update_commands(self, node, glyph, id_extension=""): for element, connectors in glyph.commands.items(): # update element el = node.find(".//*[@id='%s']" % element) @@ -537,26 +538,6 @@ class Font(object): else: add_commands(element, ['trim']) - def _ensure_command_symbols(self, group): - # collect commands - commands = set() - for element in group.iterdescendants(SVG_USE_TAG): - xlink = element.get(XLINK_HREF, ' ') - if xlink.startswith('#inkstitch_'): - commands.add(xlink[11:]) - # make sure all necessary command symbols are in the document - for command in commands: - ensure_symbol(group.getroottree().getroot(), command) - - def _ensure_marker_symbols(self, group): - for marker in MARKER: - xpath = ".//*[contains(@style, 'marker-start:url(#inkstitch-%s-marker')]" % marker - marked_elements = group.xpath(xpath, namespaces=inkex.NSS) - if marked_elements: - ensure_marker(group.getroottree().getroot(), marker) - for element in marked_elements: - element.style['marker-start'] = "url(#inkstitch-%s-marker)" % marker - def _apply_auto_satin(self, group): """Apply Auto-Satin to an SVG XML node tree with an svg:g at its root. |
