diff options
author | Paweł Kuna <1282324+codecalm@users.noreply.github.com> | 2021-01-19 22:56:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-19 22:56:20 +0100 |
commit | f5fea343e04e514bf62690cd5b75489844e07635 (patch) | |
tree | faac8dec1fb5c21374ad83a370c1da9ab2b17e2c /generate.py | |
parent | `lock-access` fix (diff) | |
parent | [dev-iconfont-generation] add svg font generation, adjust ascent to work for ... (diff) | |
download | tabler-icons-f5fea343e04e514bf62690cd5b75489844e07635.tar.xz |
Merge pull request #104 from tabler/dev-iconfont-generation
Diffstat (limited to 'generate.py')
-rw-r--r-- | generate.py | 28 |
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!") |