Create a SVG font from several SVG icons
Create an SVG font from several SVG icons with Gulp.
You can test this library with the frontend generator.
gulp-svgicons2svgfont as a development dependency:
npm install --save-dev gulp-svgicons2svgfont
Then, add it to your
var svgicons2svgfont = require'gulp-svgicons2svgfont';gulptask'Iconfont'gulpsrc'assets/icons/*.svg'pipesvgicons2svgfontfontName: 'myfont'on'codepoints'console.logcodepoints;// Here generate CSS/SCSS for your codepoints ...pipegulpdest'www/font/';;
Every icon must be prefixed with it's codepoint. The
allows to do it automatically. Then, in your own CSS, you just have to use
the corresponding codepoint to display your icon. See this
sample less mixin
for a real world usage.
The plugin stream emits a
codepoints event letting you do whatever you want
Please report icons to font issues to the svgicons2svgfont repository on wich this plugin depends.
Set to true to also convert read icons that doesn't have the .svg extension.
A string value that is used to name your font-family (required).
Allow to append codepoints to icon files in order to always keep the same codepoints.
Starting codepoint used for the generated glyphs. Defaults to the start of the Unicode private use area.
The svgfont2svgicons options are also available:
You may look after a full Gulp web font workflow, see gulp-iconfont fot that matter.
Feel free to push your code if you agree with publishing under the MIT license.