Generate custom icon webfonts from SVG/EPS files via Grunt. Based on Font Custom.
This task will make all you need to use font-face icon on your website: font in all needed formats, CSS and HTML demo page.
brew install fontforge ttfautohint sfnt2woff
npm install grunt-webfont
You may need to use sudo
for brew
, depending on your setup.
sudo apt-get install fontforge eot-utils ttfautohint
wget http://people.mozilla.com/~jkew/woff/woff-code-latest.zip
unzip woff-code-latest.zip -d sfnt2woff && cd sfnt2woff && make && sudo mv sfnt2woff /usr/local/bin/
npm install grunt-webfont
Note that if ttfautohint
is not available in your distribution, Font Custom will still work but your generated font will not be properly hinted.
For Grunt 0.3
npm install grunt-webfont --save-dev
For Grunt 0.4rc
npm install git://github.com/sapegin/grunt-webfont.git --save-dev
Add somewhere in your Gruntfile.js
:
grunt.loadNpmTasks('grunt-webfont');
Inside your Gruntfile.js
file add a section named webfont
. See Parameters section below for details.
Glyphs list: SVG or EPS. String or array. Wildcards are supported.
Directory for resulting files.
Directory for resulting CSS files (if different than font directory).
Name of font and base name of font files.
Apend font file names with unique string to flush browser cache when you update your icons.
List of style to be added to CSS files: font
(font-face
declaration), icon
(base .icon
class), extra
(extra stuff for Bootstrap (only for stylesheet
= 'bootstrap'
).
Font files types to generate.
Icon classes syntax. bem
for double class names: icon icon-awesome
or bootstrap
for single class names: icon-awesome
.
Stylesheet type. Can be css, sass, scss, less... If sass
or scss
is used, _
will prefix the file (so it can be a used as a partial).
If true
, a .html will be available in destCSS
to test the render.
If stylesheet
is not css
, will be set to false automatically.
If true
task will not be ran. In example, you can skip task on Windows (becase of difficult installation):
skip: require('os').platform() === 'win32'
webfont: {
icons: {
src: 'icons/*.svg',
dest: 'build/fonts',
destCss: 'build/fonts/css'
options: {
}
}
}
The MIT License, see the included License.md
file.