-
Notifications
You must be signed in to change notification settings - Fork 76
/
gulpfile.js
51 lines (47 loc) · 1.26 KB
/
gulpfile.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
const
gulp = require('gulp'),
rename = require('gulp-rename'),
sketch = require('gulp-sketch'),
iconfont = require('gulp-iconfont'),
consolidate = require('gulp-consolidate')
/**
* Font settings
*/
const
// set name of your symbol font
fontName = 'symbols'
/**
* Recommended to get consistent builds when watching files
* See https://github.com/nfroidure/gulp-iconfont
*/
const timestamp = Math.round(Date.now() / 1000)
gulp.task('symbols', () =>
gulp.src('symbol-android-16px.sketch')
.pipe(sketch({
export: 'artboards',
formats: 'svg'
}))
.pipe(iconfont({
fontName,
formats: ['ttf'],
timestamp,
log: () => {} // suppress unnecessary logging
}))
.on('glyphs', function(glyphs) {
const options = {
glyphs: glyphs.map(mapGlyphs),
fontName: fontName
}
gulp.src('android.xml')
.pipe(consolidate('lodash', options))
.pipe(rename({ basename: fontName }))
.pipe(gulp.dest('dist/xml/')) // set path to export your xml
})
.pipe(gulp.dest('dist/fonts/')) // set path to export your fonts
)
/**
* This is needed for mapping glyphs and codepoints.
*/
function mapGlyphs(glyph) {
return { name: glyph.name, codepoint: glyph.unicode[0].charCodeAt(0) }
}