@devpack/iconfont-builder
v2.5.0
Published
a tool to build fonts via svg
Downloads
5
Maintainers
Keywords
Readme
iconfont-builder
Introduction
Iconfont-builder is a node.js package for providing a middleware that create some font files.
Installation (via npm)
$ npm i --save @devpack/iconfont-builder
Usage
Simple Usage
var builder = require('@devpack/iconfont-builder');
var path = require('path');
var options = {
icons: [
{
name: 'www-font-o',
label: 'FontTitle',
file: 'abc.svg',
codepoint: 61441,
svg: '<svg>...</svg>'
}
],
src: path.join(__dirname, 'src'),
baseName: 'iconfont',
fontName: 'myfont',
descent: 0,
dest: path.join(__dirname, 'dest')
};
builder(options)
.then().catch();
List of options
icons
Type: Array<Object>
Example:
{
name: 'www-font-o', // className of icon
label: 'My Font', // label of icon
file: 'abc.svg', // fileName of icon
svg: '<svg>...</svg>' // svg info
codepoint: 61441 // unicode of icon
}
writeFiles
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.
readFiles
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
.
baseName
Type: String
Default: 'iconfont'
Name of font files and css class name.
fontName
Type: String
Default: 'iconfont'
Name of font family.
startCodePoint
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.
src
Type: String
Default: '.'
Directory of source svg font files.
dest
Type: String
Directory for generated font files.
descent
Type: Number
Default: 0
The font descent. It's useful to fix the font baseline yourself.
Warning: The descent is a positive value!