aboutsummaryrefslogtreecommitdiff
path: root/fix-outline.py
diff options
context:
space:
mode:
authorcodecalm <codecalm@gmail.com>2021-01-20 23:16:00 +0100
committercodecalm <codecalm@gmail.com>2021-01-20 23:16:00 +0100
commit612f6b4c6b14bfd380a5533e7c53c9f194dba74b (patch)
tree88e9888a32e1fbb069d117befcc2cca6e4999aa9 /fix-outline.py
parentbuild process improvement (diff)
downloadtabler-icons-612f6b4c6b14bfd380a5533e7c53c9f194dba74b.tar.xz
fix outline script
Diffstat (limited to 'fix-outline.py')
-rw-r--r--fix-outline.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/fix-outline.py b/fix-outline.py
new file mode 100644
index 00000000..4eb7466c
--- /dev/null
+++ b/fix-outline.py
@@ -0,0 +1,28 @@
+import os
+import fontforge
+
+# svg2ttf library does not support fill-rule="evenodd" so after converting icons to outlineStroke we fix path directions to work with "nonzero"
+# more: https://github.com/tabler/tabler-icons/issues/13 - thanks for awesome suggestions in the issue
+
+
+print ("Running fontforge to fix svg outline directions!")
+
+def files(path):
+ for file in os.listdir(path):
+ if os.path.isfile(os.path.join(path, file)):
+ yield file
+
+# refer to https://fontforge.org/docs/scripting/python/fontforge.html for documentation
+# inspiration from https://github.com/FontCustom/fontcustom/blob/master/lib/fontcustom/scripts/generate.py
+
+font = fontforge.font()
+for file in files("./icons-outlined"):
+ print (f"Correcting outline for {file}")
+ glyph = font.createChar(123, file)
+ glyph.importOutlines("./icons-outlined/" + file)
+ glyph.correctDirection()
+ glyph.export("./icons-outlined/" + file)
+ glyph.clear()
+
+
+print ("Finished fixing svg outline directions!")