ifont
1.0.0
เครื่องกำเนิดฟอนต์ไอคอน Isomorphic พร้อมรองรับ ligatures
มันสร้างไฟล์ TTF เดียวจากรายการไอคอน SVG และชื่อของพวกเขาการแมปแต่ละชื่อเป็นมัด
มันใช้งานได้ในเบราว์เซอร์ด้วย
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