From e423bf08b53133474f57c45ce6527b406ee9c921 Mon Sep 17 00:00:00 2001 From: codecalm Date: Thu, 15 Oct 2020 17:04:54 +0200 Subject: icons tags --- gulpfile.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'gulpfile.js') diff --git a/gulpfile.js b/gulpfile.js index da9f4aa0..8f6da156 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,6 +4,7 @@ const gulp = require('gulp'), fs = require('fs'), path = require('path'), p = require('./package.json'), + csv = require('csv-parser'), zip = require('gulp-zip'), puppeteer = require('puppeteer'), outlineStroke = require('svg-outline-stroke'), @@ -12,6 +13,7 @@ const gulp = require('gulp'), sass = require('node-sass'), cleanCSS = require('clean-css'), argv = require('minimist')(process.argv.slice(2)), + svgpath = require('svgpath'), svgr = require('@svgr/core').default; async function asyncForEach(array, callback) { @@ -650,6 +652,44 @@ gulp.task('update-icons-version', function (cb) { cb(); }); +// gulp.task('svg-path', function (cb) { +// let transformed = svgpath('m 9 5 a 2.4 2.4 0 0 1 2 -1 a 2.4 2.4 0 0 1 2 1 a 2.4 2.4 0 0 0 2 1 a 2.4 2.4 0 0 0 2 -1 a 2.4 2.4 0 0 1 2 -1 a 2.4 2.4 0 0 1 2 1') +// .rel() +// .toString(); +// +// console.log('transformed', transformed); +// cb(); +// }); + +gulp.task('import-tags', function(cb) { + fs.createReadStream('./_import.csv') + .pipe(csv({ + headers: false, + separator: "\t" + })) + .on('data', (row) => { + console.log(row[0], row[1]); + + const filename = `src/_icons/${row[0]}.svg`; + + let data = fs.readFileSync(filename).toString(); + data = data.replace(/(---[\s\S]+?---)/, function(m, headerContent){ + + headerContent = headerContent.replace(/tags: .*\n/, ''); + headerContent = headerContent.replace(/---/, `---\ntags: [${row[1]}]`); + + return headerContent; + }); + + fs.writeFileSync(filename, data); + + }) + .on('end', () => { + console.log('CSV file successfully processed'); + }); + cb(); +}); + gulp.task("build-react", function (cb) { cp.exec("npm run build-react", function () { cb(); -- cgit v1.2.1 From cc22ad9b1fc48aa10561eda05e7245205c4e9967 Mon Sep 17 00:00:00 2001 From: codecalm Date: Thu, 15 Oct 2020 18:09:19 +0200 Subject: icons optimize --- gulpfile.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'gulpfile.js') diff --git a/gulpfile.js b/gulpfile.js index 8f6da156..1817ff9d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -13,6 +13,7 @@ const gulp = require('gulp'), sass = require('node-sass'), cleanCSS = require('clean-css'), argv = require('minimist')(process.argv.slice(2)), + svgParse = require('parse-svg-path'), svgpath = require('svgpath'), svgr = require('@svgr/core').default; @@ -406,6 +407,17 @@ gulp.task('optimize', function (cb) { return Math.round((parseFloat(n1) + parseFloat(n2)) * 1000) / 1000 }; + const optimizePath = function(path) { + let transformed = svgpath(path) + .rel() + .round(3) + .toString(); + + return svgParse(transformed).map(function(a){ + return a.join(' '); + }).join(' '); + }; + glob("src/_icons/*.svg", {}, function (er, files) { files.forEach(function (file, i) { @@ -418,6 +430,11 @@ gulp.task('optimize', function (cb) { .replace(/\s?\/>/g, ' />') .replace(/\n\s*<(line|circle|path|polyline|rect)/g, "\n <$1") .replace(/polyline points="([0-9.]+)\s([0-9.]+)\s([0-9.]+)\s([0-9.]+)"/g, 'line x1="$1" y1="$2" x2="$3" y2="$4"') + .replace(/ Date: Fri, 8 Jan 2021 15:00:00 +0100 Subject: [dev-iconfont-generation] fix svg outline stroke directions during iconfont generation --- gulpfile.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'gulpfile.js') diff --git a/gulpfile.js b/gulpfile.js index d461eecd..da9d0df8 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -230,7 +230,14 @@ gulp.task('iconfont-svg-outline', function (cb) { }).catch(error => console.log(error)); }); - cb(); + // correct svg outline directions in a child process using fontforge + const generate = cp.spawn("fontforge", ["-lang=py", "-script", "generate.py"], { stdio: 'inherit' }); + generate.on("close", function (code) { + console.log(`Correcting svg outline directions exited with code ${code}`); + if (!code) { + cb(); + } + }); }); }); -- cgit v1.2.1 From 8f994341146e400b6b9f1c91727fd314b826778c Mon Sep 17 00:00:00 2001 From: Michal Wolny Date: Fri, 8 Jan 2021 19:48:13 +0100 Subject: [dev-iconfont-generation] descent font a little --- gulpfile.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gulpfile.js') diff --git a/gulpfile.js b/gulpfile.js index da9d0df8..64a13c2c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -262,7 +262,9 @@ gulp.task('iconfont', function () { prependUnicode: true, formats: ['ttf', 'eot', 'woff', 'woff2'], normalize: true, - startUnicode: maxUnicode + startUnicode: maxUnicode, + fontHeight: 1000, + descent: 100 })) .on('glyphs', function (glyphs, options) { //glyphs json -- cgit v1.2.1 From 4a46e87fe3759e02c9772e969646c49f8fbaf264 Mon Sep 17 00:00:00 2001 From: Michal Wolny Date: Wed, 13 Jan 2021 19:18:33 +0100 Subject: [dev-iconfont-generation] add svg font generation, adjust ascent to work for mac os notepad --- gulpfile.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gulpfile.js') diff --git a/gulpfile.js b/gulpfile.js index 64a13c2c..86fc12be 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -260,11 +260,12 @@ gulp.task('iconfont', function () { .pipe(iconfont({ fontName: 'tabler-icons', prependUnicode: true, - formats: ['ttf', 'eot', 'woff', 'woff2'], + formats: ['ttf', 'eot', 'woff', 'woff2', 'svg'], normalize: true, startUnicode: maxUnicode, fontHeight: 1000, - descent: 100 + descent: 100, + ascent: 986.5 })) .on('glyphs', function (glyphs, options) { //glyphs json -- cgit v1.2.1