summaryrefslogtreecommitdiff
path: root/lib/lettering
diff options
context:
space:
mode:
Diffstat (limited to 'lib/lettering')
-rw-r--r--lib/lettering/font.py11
-rw-r--r--lib/lettering/font_variant.py16
-rw-r--r--lib/lettering/glyph.py5
3 files changed, 11 insertions, 21 deletions
diff --git a/lib/lettering/font.py b/lib/lettering/font.py
index d241bf05..cbd8f257 100644
--- a/lib/lettering/font.py
+++ b/lib/lettering/font.py
@@ -7,16 +7,15 @@ import json
import os
from copy import deepcopy
-from inkex import styles
-from lxml import etree
+import inkex
+from .font_variant import FontVariant
from ..elements import nodes_to_elements
from ..exceptions import InkstitchException
from ..i18n import _, get_languages
from ..stitches.auto_satin import auto_satin
-from ..svg.tags import INKSCAPE_LABEL, SVG_GROUP_TAG, SVG_PATH_TAG
+from ..svg.tags import INKSCAPE_LABEL, SVG_PATH_TAG
from ..utils import Point
-from .font_variant import FontVariant
class FontError(InkstitchException):
@@ -190,7 +189,7 @@ class Font(object):
for element in destination_group.iterdescendants(SVG_PATH_TAG):
dash_array = ""
stroke_width = ""
- style = styles.Style(element.get('style'))
+ style = inkex.styles.Style(element.get('style'))
if style.get('fill') == 'none':
stroke_width = ";stroke-width:1px"
@@ -224,7 +223,7 @@ class Font(object):
An svg:g element containing the rendered text.
"""
- group = etree.Element(SVG_GROUP_TAG, {
+ group = inkex.Group(attrib={
INKSCAPE_LABEL: line
})
diff --git a/lib/lettering/font_variant.py b/lib/lettering/font_variant.py
index b1e38368..d9d8ed44 100644
--- a/lib/lettering/font_variant.py
+++ b/lib/lettering/font_variant.py
@@ -6,7 +6,6 @@
import os
import inkex
-from lxml import etree
from ..svg.tags import INKSCAPE_GROUPMODE, INKSCAPE_LABEL
from .glyph import Glyph
@@ -61,8 +60,7 @@ class FontVariant(object):
def _load_glyphs(self):
svg_path = os.path.join(self.path, "%s.svg" % self.variant)
- with open(svg_path, encoding="utf-8") as svg_file:
- svg = etree.parse(svg_file)
+ svg = inkex.load_svg(svg_path)
glyph_layers = svg.xpath(".//svg:g[starts-with(@inkscape:label, 'GlyphLayer-')]", namespaces=inkex.NSS)
for layer in glyph_layers:
@@ -76,14 +74,10 @@ class FontVariant(object):
# glyph.
del group.attrib[INKSCAPE_GROUPMODE]
- style_text = group.get('style')
-
- if style_text:
- # The layer may be marked invisible, so we'll clear the 'display'
- # style.
- style = dict(inkex.Style.parse_str(group.get('style')))
- style.pop('display')
- group.set('style', str(inkex.Style(style)))
+ # The layer may be marked invisible, so we'll clear the 'display'
+ # style and presentation attribute.
+ group.style.pop('display', None)
+ group.attrib.pop('display', None)
def __getitem__(self, character):
if character in self.glyphs:
diff --git a/lib/lettering/glyph.py b/lib/lettering/glyph.py
index 3bedd7ed..047c12cf 100644
--- a/lib/lettering/glyph.py
+++ b/lib/lettering/glyph.py
@@ -8,7 +8,6 @@ from copy import copy
from inkex import paths, transforms
from ..svg import get_guides
-from ..svg.path import get_correction_transform
from ..svg.tags import SVG_GROUP_TAG, SVG_PATH_TAG
@@ -53,9 +52,7 @@ class Glyph(object):
node_copy = copy(node)
if "d" in node.attrib:
- transform = -transforms.Transform(get_correction_transform(node, True))
- path = paths.Path(node.get("d")).transform(transform).to_absolute()
- node_copy.set("d", str(path))
+ node_copy.path = node.path.transform(node.composed_transform()).to_absolute()
# Delete transforms from paths and groups, since we applied
# them to the paths already.