Iconfont-builder is a node.js package for providing a middleware that create some font files.
Installation (via npm)
$ npm i --save iconfont-builder
var builder = require('iconfont-builder');
var path = require('path');
var options = {
icons: [
{
name: 'www-font-o',
file: 'abc.svg',
codepoint: 61441
}
],
src: path.join(__dirname, 'src'),
fontName: 'iconfont',
descent: 0,
dest: path.join(__dirname, 'dest')
};
builder(options)
.then().catch();
Type: Array<Object>
Example:
{
name: 'www-font-o', // className of icon
file: 'abc.svg', // fileName of icon
codepoint: 61441 // unicode of icon
}
Type: Boolean
Default: true
It is possible to not create font files but get the attribute d of each icon svg. The attribute d contains all paths' information of an icon, which can be use to draw a svg icon.
Type: Boolean
Default: true
You can only use attribute d to create font files! If this param is false
, the Object in param icons
should have attribute d
.
Type: String
Default: 'iconfont'
Name of font and font files.
Type: Number
Default: 0xF000
Start of font's unicode in DEC(e.g. 61441
) or HEX(e.g. 0xF001
). When passing options
without icons
, builder will use startCodePoint
as the first unicode of font icon, and the unicode of each remaining icons will increased by one in order.
Type: String
Default: '.'
Directory of source svg font files.
Type: String
Directory for generated font files.
Type: Number
Default: 0
The font descent. It's useful to fix the font baseline yourself.
Warning: The descent is a positive value!