svgs2fonts
1.0.0
svg 图标转字体图标库(svgs -> svg,ttf,eot,woff,woff2)。English readme
2.0.3
npm i -g svgs2fontssvgs2fonts -vnpm i --save svgs2fontsimport Svgs2fonts from 'svgs2fonts';
// or
// const Svgs2fonts = require('svgs2fonts');
Svgs2fonts.init(options);其中 options 参数:
| 字段 | 类型 | 默认值 | 描述 |
|---|---|---|---|
| src | string |
- |
svg 图标文件的目录路径 |
| dist | string |
./dist |
字体图标输出路径 |
| fontName | string |
iconfont |
输出图标/字体名称 |
| unicodeStart | number |
10000 |
unicode 起始数字(设置此指是需要避开正常 unicode 范围),(v2.0之前对应字段为startNumber) |
| noDemo | boolean |
true |
是否需要输出 html Demo 文件 |
| demoUnicodeHTML | string |
demo_unicode.html |
unicode 类型的示例 html 名称 |
| demoFontClassHTML | string |
demo_fontclass.html |
fontClass 类型的示例 html 名称 |
*V2 废弃字段:
v2.1.0废弃):${Boolean},是否开启 debug 模式以输出更多执行信息,默认falsev2.0废弃):{Number},执行超时时间,默认为 60s(60000)v2.0废弃):{Object},日志记录。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}其中参数:
svgs2fonts svg distoptions 配置参数
-n / --name图标库的名字(default: "iconfont").
svgs2fonts svg dist -n myiconfont--numberunicode 起始编码(default: 10000).
svgs2fonts svg dist --number 50000
--nodemo不要 demo html(default: false).
svgs2fonts svg dist --nodemo
svgs2fonts svg dist
安装依赖:
npm i
构建:
npm run build
单测:
npm run test
demo 测试:
npm run test:example
Micheal Wayne
引导文章-《svg、ttf、woff、woff2 图标的研究及转换(svgs2fonts)》
2018.08.26
v2.1.0 change log and remove debug;v2.0.3 add some defensive handing;v2.0.2 optimal variable control;v2.0.1 split css & support svg size options;