svgs2fonts
1.0.0
svg icon to font icon library (svgs -> svg,ttf,eot,woff,woff2). English readme
2.0.3
npm i -g svgs2fontssvgs2fonts -vnpm i --save svgs2fonts import Svgs2fonts from 'svgs2fonts' ;
// or
// const Svgs2fonts = require('svgs2fonts');
Svgs2fonts . init ( options ) ;Where options parameters:
| Fields | type | default value | describe |
|---|---|---|---|
| src | string | - | Directory path of svg icon file |
| dist | string | ./dist | Font icon output path |
| fontName | string | iconfont | Output icon/font name |
| unicodeStart | number | 10000 | unicode start number (setting this means you need to avoid the normal unicode range), (the corresponding field before v2.0 is startNumber ) |
| noDemo | boolean | true | Is it necessary to output the html demo file? |
| demoUnicodeHTML | string | demo_unicode.html | Example html name of unicode type |
| demoFontClassHTML | string | demo_fontclass.html | Sample html name of fontClass type |
*V2 Abandoned fields:
v2.1.0废弃): ${Boolean} , whether to enable debug mode to output more execution information, default falsev2.0废弃): {Number} , execution timeout, default is 60s ( 60000 )v2.0废弃): {Object} , logging. import Svgs2fonts from 'svgs2fonts' ;
import { join } from 'path' ;
Svgs2fonts . init ( {
src : __dirname , // svg path
dist : join ( __dirname , 'dest' ) , // output path
fontName : 'myIconfont' , // font name
noDemo : true , // no demo html files
} )
. then ( ( ) => console . log ( 'task success!' ) )
. catch ( err => console . log ( `task failed( ${ err } )` ) ) ;svgs2fonts {srcpath} {distpath} {options}Where parameters:
svgs2fonts svg distoptions configuration parameters
-n / --name The name of the icon library (default: "iconfont" ).
svgs2fonts svg dist -n myiconfont--number unicode start encoding (default: 10000 ).
svgs2fonts svg dist --number 50000
--nodemo Don't demo html(default: false ).
svgs2fonts svg dist --nodemo
svgs2fonts svg dist
Installation dependencies:
npm i
Build:
npm run build
Single test:
npm run test
demo test:
npm run test:example
Micheal Wayne
Guided article-"Research and conversion of svg, ttf, woff, woff2 icons (svgs2fonts)"
2018.08.26
v2.1.0 change log and remove debug;v2.0.3 add some defensive handing;v2.0.2 optical variable control;v2.0.1 split css & support svg size options;