Convert svg icons to webfont.
npm install svgicon2webfont --save
const svgicon2webfont = require('svgicon2webfont');
svgicon2webfont({
fontName: 'iconfont',
glyphs: [{
name: 'xx',
codepoint: 0xF101,
svg: fs.readFileSync('xx.svg')).toString()
}],
dest: 'dest'
}).then((result) => {
// handle result
}).catch((error) => {
// handle error
})
required
Type: string
Name of font and base name of font files.
required
Type: string
Directory for generated font files.
required
Type: Array<Glyph>
Specific name
, codepoint
, svg
for icons.
interface Glyph {
name: string;
codepoint: number;
svg: string;
}
Options that are passed directly to svgicons2svgfont.
Type: object
Specific per format arbitrary options to pass to the generator
format and matching generator:
svg
- svgicons2svgfont.ttf
- svg2ttf.woff2
- ttf2woff2.woff
- ttf2woff.eot
- ttf2eot.
svgicon2webfont({
// options
formatOptions: {
// options to pass specifically to the ttf generator
ttf: {
ts: 1451512800000
}
}
})