gulp-iconfont10.0.3 • Public • Published
Create SVG/TTF/EOT/WOFF/WOFF2 fonts from several SVG icons with Gulp.
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
gulp-iconfont and all its related modules, using SVG icons was just not realistic
for a wide browser suppport but i was already conviced that SVG was the
future, that's why i wanted my SVG source files to sit separated in a folder.
So, now, just enjoy switching to SVG with almost no effort :). Was a great
open source journey with you all!
gulp-iconfont as a development dependency:
npm install --save-dev gulp-iconfont
Then, add it to your
var iconfont = ;var runTimestamp = Math;gulp;
gulp-iconfont bundles several plugins to bring a simpler API
for more flexibility, feel free to use them separately.
If some font glyphs aren't converted properly you should add the
normalize:true option and a
fontHeight greater than 1000
Make your CSS
It's also easy to make a CSS template by yourself. Like
gulp-consolidate is useful to handling
such a template. The template is outdated, change every occurrence of
glyph.unicode.charCodeAt(0).toString(16).toUpperCase(), otherwise it will not work.
var async = ;var gulp = ;var iconfont = ;var consolidate = ;gulp;
Add issues to the right repos:
- the plugin doesn't work at all, submit your issue in this repo.
- every font doesn't display as expected: submit the issue to the svgicons2svgfont repository.
- only some fonts are damaged? Please look at the font format the targeted browser actually use and then, submit your issue to one of those projects: svg2ttf, ttf2eot, ttf2woff.
['ttf', 'eot', 'woff']
['svg', 'ttf', 'eot', 'woff', 'woff2']
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 https://github.com/nfroidure/gulp-iconfont/issues/64).
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
ttfautohint is searched in $PATH.
The svgicons2svgfont are available:
- options.fontName (required)
So are the gulp-svgicons2svgfont:
And the gulp-svg2ttf:
Beware 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
normalize option to get them in a correct size.
Degroup every shapes (Ctrl+Shift+G), convert to pathes (Ctrl+Maj+C) and merge them (Ctrl++). Then save your SVG, prefer 'simple SVG' file type.
Save your file as SVG with the following settings:
- SVG Profiles: SVG 1.1
- Fonts Type: SVG
- Fonts Subsetting: None
- Options Image Location: Embed
- Advanced Options
- CSS Properties: Presentation Attributes
- Decimal Places: 1
- Encoding: UTF-8
- Output fewer elements: check
Leave the rest unchecked.
More in-depth information: http://www.adobe.com/inspire/2013/09/exporting-svg-illustrator.html
Here is a sample repo "Symbols for Sketch".
- Download the zipped repo and extract it.
- Go to the directory.
$ cd path/to/dir
- Install some tools.
$ npm install
- Create fonts and CSS
$ gulp symbols
Feel free to push your code if you agree with publishing under the MIT license.