所以,我使用gulp-iconfont从 svg 图标生成图标字体。我已经通过下一种方式设置了任务:
gulp.task('iconfont', function(){
gulp.src(['src/assets/icons/*.svg'])
.pipe($.iconfont({
fontName: 'material',
normalize: true
}))
.on('codepoints', function(codepoints) {
console.log(codepoints);
gulp.src('src/templates/material.styl')
.pipe($.consolidate('mustache', {
glyphs: codepoints,
fontName: 'material',
fontPath: '../fonts/',
className: 'md'
}))
.pipe(gulp.dest('src/styles/plugins'));
})
.pipe(gulp.dest('build/fonts/'));
});
console.log(codepoints)
给了我类似的东西:
[ { name: 'notifications', codepoint: 57345 },
{ name: 'offline', codepoint: 57346 },
{ name: 'online', codepoint: 57347 },
...
]
我在我的css中使用这个代码点来生成类似的东西:
.md-notifications {
content: "\57345";
}
它不起作用,有一个空白空间而不是我的图标。但是,如果我使用直接从生成的 svg 字体获得的代码点,它可以工作:
.md-notifications {
content: "\E001"
}
我究竟做错了什么?