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