ifont
1.0.0
同構圖標字體生成器,並支持連接。
它從SVG圖標列表及其名稱列表中生成一個TTF文件,將每個名稱映射到綁紮中。
它也可以在瀏覽器中工作。
npm install --save ifont您將使用這樣的CLI命令:
# Build an icon font from some SVG icons
ifont build -i resources/icons/ * .svg -o dist/IconFont.ttf
# Preview an icon font from some SVG icons
ifont preview -i resources/icons/ * .svg
# List icons by bytes needed once added to the TTF font
ifont stats -i resources/icons/ * .svg您將使用這樣的程序化API:
import ifont from 'ifont' ;
import fs from 'node:fs' ;
// Generate a TTF font, as a Uint8Array, from some SVG icons
const ttf = ifont ( {
icons : [
{ name : 'circle' , content : '<svg>...</svg>' }
{ name : 'square' , content : '<svg>...</svg>' } ,
{ name : 'triangle' , content : '<svg>...</svg>' }
]
} ) ;
fs . writeFileSync ( 'IconFont.ttf' , ttf ) ; svg2ttf :MIT©Vitaly Puzrin