summaryrefslogtreecommitdiff
path: root/lib/extensions/lettering_svg_font_to_layers.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/extensions/lettering_svg_font_to_layers.py')
-rw-r--r--lib/extensions/lettering_svg_font_to_layers.py46
1 files changed, 25 insertions, 21 deletions
diff --git a/lib/extensions/lettering_svg_font_to_layers.py b/lib/extensions/lettering_svg_font_to_layers.py
index 81586195..0bcd7003 100644
--- a/lib/extensions/lettering_svg_font_to_layers.py
+++ b/lib/extensions/lettering_svg_font_to_layers.py
@@ -28,6 +28,8 @@ from .base import InkstitchExtension
from ..svg import PIXELS_PER_MM
+import unicodedata
+
class LetteringSvgFontToLayers(InkstitchExtension):
"""
@@ -165,33 +167,35 @@ class LetteringSvgFontToLayers(InkstitchExtension):
Converts a single glyph into a new SVG layer, applying scaling and coordinate transformation.
"""
unicode_char = glyph.get("unicode")
+ if unicode_char is None or unicodedata.category(unicode_char[0])[0] != "Z":
+ # all unicode with category starting with 'Z' is not rendered, no need to create layers with path.d =""
+
+ glyph_name = glyph.get("glyph-name").split('.')
+ if unicode_char is None:
+ if len(glyph_name) == 2:
+ unicode_char = glyph_name[0]
+ else:
+ return
- glyph_name = glyph.get("glyph-name").split('.')
- if unicode_char is None:
+ typographic_feature = ''
if len(glyph_name) == 2:
- unicode_char = glyph_name[0]
+ typographic_feature = glyph_name[1]
else:
- return
-
- typographic_feature = ''
- if len(glyph_name) == 2:
- typographic_feature = glyph_name[1]
- else:
- arabic_form = glyph.get('arabic-form', None)
- if arabic_form is not None and len(arabic_form) > 4:
- typographic_feature = arabic_form[:4]
- if typographic_feature:
- typographic_feature = f".{typographic_feature}"
+ arabic_form = glyph.get('arabic-form', None)
+ if arabic_form is not None and len(arabic_form) > 4:
+ typographic_feature = arabic_form[:4]
+ if typographic_feature:
+ typographic_feature = f".{typographic_feature}"
- layer = self.svg.add(Layer.new(f"GlyphLayer-{unicode_char}{typographic_feature}"))
+ layer = self.svg.add(Layer.new(f"GlyphLayer-{unicode_char}{typographic_feature}"))
- # glyph layers (except the first one) are initially hidden
- if hide_layer:
- layer.style["display"] = "none"
+ # glyph layers (except the first one) are initially hidden
+ if hide_layer:
+ layer.style["display"] = "none"
- # Using curve description in d attribute of svg:glyph
- path = layer.add(PathElement())
- path.path = self.flip_cordinate_system(glyph, emsize, baseline, scale_by)
+ # Using curve description in d attribute of svg:glyph
+ path = layer.add(PathElement())
+ path.path = self.flip_cordinate_system(glyph, emsize, baseline, scale_by)
def effect(self) -> None:
# Current code only reads the first svgfont instance