From 612f6b4c6b14bfd380a5533e7c53c9f194dba74b Mon Sep 17 00:00:00 2001 From: codecalm Date: Wed, 20 Jan 2021 23:16:00 +0100 Subject: fix outline script --- .build/generate.py | 28 ---------------------------- fix-outline.py | 28 ++++++++++++++++++++++++++++ gulpfile.js | 2 +- 3 files changed, 29 insertions(+), 29 deletions(-) delete mode 100644 .build/generate.py create mode 100644 fix-outline.py diff --git a/.build/generate.py b/.build/generate.py deleted file mode 100644 index d763ed16..00000000 --- a/.build/generate.py +++ /dev/null @@ -1,28 +0,0 @@ -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!") 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!") diff --git a/gulpfile.js b/gulpfile.js index 36721329..bdda07da 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -231,7 +231,7 @@ gulp.task('iconfont-svg-outline', function (cb) { }); // correct svg outline directions in a child process using fontforge - const generate = cp.spawn("fontforge", ["-lang=py", "-script", ".build/generate.py"], { stdio: 'inherit' }); + const generate = cp.spawn("fontforge", ["-lang=py", "-script", "./fix-outline.py"], { stdio: 'inherit' }); generate.on("close", function (code) { console.log(`Correcting svg outline directions exited with code ${code}`); if (!code) { -- cgit v1.2.1