-
Notifications
You must be signed in to change notification settings - Fork 4
/
fonts.js
61 lines (56 loc) · 1.87 KB
/
fonts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/** global require **/
const webfontsGenerator = require('webfonts-generator');
const Promise = require('bluebird');
const fs = Promise.promisifyAll(require('fs'));
const sass = require('node-sass');
const timestamp = Date.now();
const iconList = [];
const iconDir = './icons';
const fontname = 'FontFare';
const iconPrefix = 'ff';
const scssOutput = './dist/scss/_fontfare.scss';
fs.readdirAsync(iconDir).then((files) => {
files.forEach((file) => {
iconList.push(iconDir + "/" + file)
});
webfontsGenerator({
fontName: fontname,
files: iconList,
types: ['woff', 'woff2', 'eot', 'ttf', 'svg'],
startCodepoint: 0xE000,
normalize: true,
fontHeight: 10000,
css: true,
cssDest: scssOutput,
cssTemplate: 'templates/scss.hbs',
cssFontsUrl: './dist/fonts/',
cssClass: iconPrefix,
html: true,
htmlDest: './dist/preview/index.html',
htmlTemplate: './templates/html.hbs',
templateOptions: {
cacheBuster: timestamp,
fontDir: '../fonts/',
classPrefix: iconPrefix + '-',
baseSelector: iconPrefix
},
dest: 'dist/fonts/',
}, function (error) {
if (error) {
console.log('Error creating font ', error);
} else {
sass.render({
file: scssOutput,
outFile: 'main.css',
}, function (error, result) {
if (!error) {
fs.writeFile('dist/preview/main.css', result.css, () => {
console.log('Preview created')
})
}
});
}
console.log('Fonts were generated!');
}
)
});