summaryrefslogtreecommitdiff
path: root/lib/extensions/lettering_remove_kerning.py
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2021-03-04 18:40:53 +0100
committerGitHub <noreply@github.com>2021-03-04 18:40:53 +0100
commite84a86d4ac0caf29d6074728376ff0a594243fec (patch)
tree888c79ed0094ba2916a1d329861a85515959913c /lib/extensions/lettering_remove_kerning.py
parentb39575a50191307b3b56eab6455626398eec6397 (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/extensions/lettering_remove_kerning.py')
-rw-r--r--lib/extensions/lettering_remove_kerning.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/extensions/lettering_remove_kerning.py b/lib/extensions/lettering_remove_kerning.py
new file mode 100644
index 00000000..aec8717e
--- /dev/null
+++ b/lib/extensions/lettering_remove_kerning.py
@@ -0,0 +1,30 @@
+import os
+
+from inkex import NSS
+from lxml import etree
+
+from .base import InkstitchExtension
+
+
+class LetteringRemoveKerning(InkstitchExtension):
+ '''
+ This extension helps font creators to generate the json file for the lettering tool
+ '''
+ def __init__(self, *args, **kwargs):
+ InkstitchExtension.__init__(self, *args, **kwargs)
+ self.arg_parser.add_argument("-p", "--font-files", type=str, default="", dest="paths")
+
+ def effect(self):
+ # file paths
+ paths = self.options.paths.split("|")
+ for path in paths:
+ if not os.path.isfile(path):
+ continue
+ with open(path, 'r+', encoding="utf-8") as fontfile:
+ svg = etree.parse(fontfile)
+ xpath = ".//svg:font[1]"
+ kerning = svg.xpath(xpath, namespaces=NSS)[0]
+ kerning.getparent().remove(kerning)
+ fontfile.seek(0)
+ fontfile.write(etree.tostring(svg).decode('utf-8'))
+ fontfile.truncate()