summaryrefslogtreecommitdiff
path: root/lib/lettering
diff options
context:
space:
mode:
Diffstat (limited to 'lib/lettering')
-rw-r--r--lib/lettering/categories.py30
-rw-r--r--lib/lettering/font.py2
-rw-r--r--lib/lettering/font_info.py (renamed from lib/lettering/kerning.py)14
3 files changed, 45 insertions, 1 deletions
diff --git a/lib/lettering/categories.py b/lib/lettering/categories.py
new file mode 100644
index 00000000..40b41529
--- /dev/null
+++ b/lib/lettering/categories.py
@@ -0,0 +1,30 @@
+# Authors: see git history
+#
+# Copyright (c) 2023 Authors
+# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
+
+from ..i18n import _
+
+
+class FontCategory:
+ def __init__(self, cat_id=None, name=None):
+ self.id: str = cat_id
+ self.name: str = name
+
+ def __repr__(self):
+ return "FontCategory(%s, %s)" % (self.id, self.name)
+
+
+FONT_CATEGORIES = [
+ FontCategory('applique', _("Applique")),
+ FontCategory('crossstitch', _("Crossstitch")),
+ FontCategory('display', _('Display')),
+ FontCategory('handwriting', _("Handwriting")),
+ FontCategory('italic', _("Italic")),
+ FontCategory('monogram', _("Monogram")),
+ FontCategory('multicolor', _('Multicolor')),
+ FontCategory('running_stitch', _('Running Stitch')),
+ FontCategory('sans_serif', _("Sans Serif")),
+ FontCategory('serif', _("Serif")),
+ FontCategory('tiny', _("Tiny"))
+]
diff --git a/lib/lettering/font.py b/lib/lettering/font.py
index 77f17e7f..fb17f760 100644
--- a/lib/lettering/font.py
+++ b/lib/lettering/font.py
@@ -111,6 +111,7 @@ class Font(object):
name = localized_font_metadata('name', '')
description = localized_font_metadata('description', '')
+ keywords = font_metadata('keywords', '')
letter_case = font_metadata('letter_case', '')
default_glyph = font_metadata('default_glyph', "�")
leading = font_metadata('leading', 100)
@@ -119,6 +120,7 @@ class Font(object):
min_scale = font_metadata('min_scale', 1.0)
max_scale = font_metadata('max_scale', 1.0)
size = font_metadata('size', 0)
+ available_glyphs = font_metadata('glyphs', [])
# use values from SVG Font, example:
# <font horiz-adv-x="45" ... <glyph .... horiz-adv-x="49" glyph-name="A" /> ... <hkern ... k="3"g1="A" g2="B" /> .... />
diff --git a/lib/lettering/kerning.py b/lib/lettering/font_info.py
index 5596ce8a..398786a4 100644
--- a/lib/lettering/kerning.py
+++ b/lib/lettering/font_info.py
@@ -5,9 +5,10 @@
from inkex import NSS
from lxml import etree
+from ..svg.tags import INKSCAPE_LABEL
-class FontKerning(object):
+class FontFileInfo(object):
"""
This class reads kerning information from an SVG file
"""
@@ -123,3 +124,14 @@ class FontKerning(object):
xpath = "string(.//svg:missing-glyph/@*[name()='horiz-adv-x'])"
return float(self.svg.xpath(xpath, namespaces=NSS))
"""
+
+ def glyph_list(self):
+ """
+ Returns a list of available glyphs in the font file
+ """
+ glyphs = []
+ glyph_layers = self.svg.xpath(".//svg:g[starts-with(@inkscape:label, 'GlyphLayer-')]", namespaces=NSS)
+ for layer in glyph_layers:
+ glyph_name = layer.attrib[INKSCAPE_LABEL].replace("GlyphLayer-", "", 1)
+ glyphs.append(glyph_name)
+ return glyphs