在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):nfroidure/gulp-iconfont开源软件地址(OpenSource Url):https://github.com/nfroidure/gulp-iconfont开源编程语言(OpenSource Language):JavaScript 78.7%开源软件介绍(OpenSource Introduction):gulp-iconfont
You can test this library with the frontend generator. Warning: While this plugin may still be useful for fonts generation or old browser
support, you should consider using SVG icons directly. Indeed, when i created
More info on with using SVG over icon fonts. UsageFirst, install npm install --save-dev gulp-iconfont Then, add it to your var iconfont = require('gulp-iconfont');
var runTimestamp = Math.round(Date.now()/1000);
gulp.task('Iconfont', function(){
return gulp.src(['assets/icons/*.svg'])
.pipe(iconfont({
fontName: 'myfont', // required
prependUnicode: true, // recommended option
formats: ['ttf', 'eot', 'woff'], // default, 'woff2' and 'svg' are available
timestamp: runTimestamp, // recommended to get consistent builds when watching files
}))
.on('glyphs', function(glyphs, options) {
// CSS templating, e.g.
console.log(glyphs, options);
})
.pipe(gulp.dest('www/fonts/'));
});
If some font glyphs aren't converted properly you should add the
Make your CSSTo use this font in your CSS, you could add a mixin like in this
real world example.
You can also generate your CSS automatically with
It's also easy to make a CSS template by yourself. Like
this example,
var async = require('async');
var gulp = require('gulp');
var iconfont = require('gulp-iconfont');
var consolidate = require('gulp-consolidate');
gulp.task('Iconfont', function(done){
var iconStream = gulp.src(['assets/icons/*.svg'])
.pipe(iconfont({ fontName: 'myfont' }));
async.parallel([
function handleGlyphs (cb) {
iconStream.on('glyphs', function(glyphs, options) {
gulp.src('templates/myfont.css')
.pipe(consolidate('lodash', {
glyphs: glyphs,
fontName: 'myfont',
fontPath: '../fonts/',
className: 's'
}))
.pipe(gulp.dest('www/css/'))
.on('finish', cb);
});
},
function handleFonts (cb) {
iconStream
.pipe(gulp.dest('www/fonts/'))
.on('finish', cb);
}
], done);
}); IssuesAdd issues to the right repos:
APIiconfont(options)options.formatsType: Since SVG fonts are deprecated in some (every ?) browsers, they are disabled per default. Also the WOFF2 fonts are disabled since it seems to cause issues on some setup (see #64). options.autohintType: If ttfautohint is installed on your system, you may want to auto hint your fonts. Beware that this is an experimental and untested feature (beware to use at least the 0.93 version). If the value is a string, it is taken to be the path to the options.*The svgicons2svgfont are available:
So are the gulp-svgicons2svgfont:
And the gulp-svg2ttf:
Preparing SVG'sBeware that your SVG icons must have a high enough height. 500 is a minimum. If
you do not want to resize them, you can try to combine the InkscapeDegroup every shapes (Ctrl+Shift+G), convert to pathes (Ctrl+Maj+C) and merge them (Ctrl++). Then save your SVG, prefer 'simple SVG' file type. IllustratorSave your file as SVG with the following settings:
Leave the rest unchecked. More in-depth information: http://www.adobe.com/inspire/2013/09/exporting-svg-illustrator.html SketchSketch is a relatively new drawing tool on Mac. With help of Sketch Tools and gulp-sketch, you can directly create fonts from your Sketch file. No need to export intermediate SVGs. Here is a sample repo "Symbols for Sketch".
ContributingFeel free to push your code if you agree with publishing under the MIT license. Stats |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论