One-Click Icon Font Generation: icon-font-generator Usage Guide
Say goodbye to tedious icon management - convert SVG icons to lightweight web fonts with command line
Why Do We Need Icon Fonts?
In web development, icon management often faces challenges:
- Multi-resolution adaptation issues
- Multiple small images increase HTTP requests
- Color/size adjustments require re-exporting
- Complex multi-color icon management
Icon fonts perfectly solve these problems: vector scaling, CSS control, single-request loading of all icons. Today's featured tool icon-font-generator
can generate a complete solution with just two commands!
Quick Start
1️⃣ Install the Tool Globally
npm install -g icon-font-generator
2️⃣ Generate Icon Font
icon-font-generator C:\icons\*.svg -o dist
This command will:
- Read all SVG files from the
C:\icons
directory - Generate font files (TTF/WOFF/WOFF2/EOT/SVG)
- Output to the
dist
directory and automatically create CSS/HTML preview
Core Parameters Explained
icon-font-generator [svg-path] -o [output-directory] [options]
Common Configuration Example:
icon-font-generator assets/icons/*.svg \
-o public/fonts \
--name "app-icons" \
--prefix "ico-" \
--types "woff2,woff" \
--normalize \
--height 1000
Key Parameters:
Parameter | Description | Default Value |
---|---|---|
-o, --out | Required! Output directory | - |
--name | Font name (affects filename) | icons |
--css | Whether to generate CSS file | true |
--html | Whether to generate preview HTML | true |
--prefix | CSS class prefix (.prefix-icon ) | icon |
--types | Font formats to generate | svg,ttf,woff,woff2,eot |
--normalize | Normalize icon sizes | false |
--mono | Generate monospace font | false |
--height | Fixed font height (solves alignment) | - |
评论