diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2021-03-04 18:40:53 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-04 18:40:53 +0100 |
| commit | e84a86d4ac0caf29d6074728376ff0a594243fec (patch) | |
| tree | 888c79ed0094ba2916a1d329861a85515959913c /lib/lettering/font_variant.py | |
| parent | b39575a50191307b3b56eab6455626398eec6397 (diff) | |
Update for Inkscape 1.0 (#880)
* update for inkscape 1.0
* add about extension
* Build improvements for the inkscape1.0 branch (#985)
* zip: export real svg not stitch plan
* #411 and #726
* Tools for Font Creators (#1018)
* ignore very small holes in fills
* remove embroider (#1026)
* auto_fill: ignore shrink_or_grow if result is empty (#589)
* break apart: do not ignore small fills
Co-authored-by: Hagen Fritsch <rumpeltux-github@irgendwo.org>
Co-authored-by: Lex Neva <github.com@lexneva.name>
Diffstat (limited to 'lib/lettering/font_variant.py')
| -rw-r--r-- | lib/lettering/font_variant.py | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/lib/lettering/font_variant.py b/lib/lettering/font_variant.py index 7c9fa1c0..2071b2cb 100644 --- a/lib/lettering/font_variant.py +++ b/lib/lettering/font_variant.py @@ -1,9 +1,7 @@ -# -*- coding: UTF-8 -*- - import os import inkex -import simplestyle +from lxml import etree from ..svg.tags import INKSCAPE_GROUPMODE, INKSCAPE_LABEL from .glyph import Glyph @@ -26,10 +24,10 @@ class FontVariant(object): # We use unicode characters rather than English strings for font file names # in order to be more approachable for languages other than English. - LEFT_TO_RIGHT = u"→" - RIGHT_TO_LEFT = u"←" - TOP_TO_BOTTOM = u"↓" - BOTTOM_TO_TOP = u"↑" + LEFT_TO_RIGHT = "→" + RIGHT_TO_LEFT = "←" + TOP_TO_BOTTOM = "↓" + BOTTOM_TO_TOP = "↑" VARIANT_TYPES = (LEFT_TO_RIGHT, RIGHT_TO_LEFT, TOP_TO_BOTTOM, BOTTOM_TO_TOP) @classmethod @@ -57,9 +55,9 @@ class FontVariant(object): self._load_glyphs() def _load_glyphs(self): - svg_path = os.path.join(self.path, u"%s.svg" % self.variant) - with open(svg_path) as svg_file: - svg = inkex.etree.parse(svg_file) + 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) glyph_layers = svg.xpath(".//svg:g[starts-with(@inkscape:label, 'GlyphLayer-')]", namespaces=inkex.NSS) for layer in glyph_layers: @@ -78,9 +76,9 @@ class FontVariant(object): if style_text: # The layer may be marked invisible, so we'll clear the 'display' # style. - style = simplestyle.parseStyle(group.get('style')) + style = dict(inkex.Style.parse_str(group.get('style'))) style.pop('display') - group.set('style', simplestyle.formatStyle(style)) + group.set('style', str(inkex.Style(style))) def __getitem__(self, character): if character in self.glyphs: |
