aboutsummaryrefslogtreecommitdiff
path: root/generate.py
diff options
context:
space:
mode:
authorcodecalm <codecalm@gmail.com>2021-01-20 22:18:49 +0100
committercodecalm <codecalm@gmail.com>2021-01-20 22:18:49 +0100
commitc8da3525fac1d02e48b957a0ed9676b28e38e394 (patch)
treed29c214daad37893134cd10637cc3536f37fcd2d /generate.py
parentUpdate README.md (diff)
parentMerge pull request #104 from tabler/dev-iconfont-generation (diff)
downloadtabler-icons-c8da3525fac1d02e48b957a0ed9676b28e38e394.tar.xz
Merge branch 'dev' of https://github.com/tabler/tabler-icons
 Conflicts:  iconfont/fonts/tabler-icons.eot  iconfont/fonts/tabler-icons.ttf  iconfont/fonts/tabler-icons.woff  iconfont/fonts/tabler-icons.woff2
Diffstat (limited to 'generate.py')
-rw-r--r--generate.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/generate.py b/generate.py
new file mode 100644
index 00000000..d763ed16
--- /dev/null
+++ b/generate.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!")