description
A command-line tool that generates a Flutter Icon class from fonts obtained from iconfont.cn.
usage
1、add iconfontool to dev dependenceis
dev_dependencies:
iconfontool: latest
2、add fonts assets which download from iconfont.cn to flutter
Basically only need the iconfont.tts and iconfont.json file, and you can rename it according to your preference.
flutter:
fonts:
- family: iconfont
fonts:
- asset: assets/fonts/shiny_music.ttf
3、config iconfontool
iconfontool support seperate yaml or integrate pubspec.yaml
iconfontool:
- json_path: assets/fonts/iconfont.json # including icons information
font_family: shiny_music # set font family
font_path: assets/fonts/shiny_music.ttf # the font asset file path
icon_class: ShinyMusic # generated dart class name
out_dir: lib/fonts/shiny/ # generated file output dir
- json_path: assets/fonts/iconfont.json # including icons information
font_family: shiny_music2 # set font family
font_path: assets/fonts/shiny_music.ttf # the font asset file path
icon_class: ShinyMusic2 # generated dart class name
out_dir: lib/fonts/shiny/ # generated file output dir
or seperate yaml
iconfontool.yaml
- json_path: assets/fonts/iconfont.json # including icons information
font_family: shiny_music # set font family
font_path: assets/fonts/shiny_music.ttf # the font asset file path
icon_class: ShinyMusic # generated dart class name
out_dir: lib/fonts/shiny/ # generated file output dir
- json_path: assets/fonts/iconfont.json # including icons information
font_family: shiny_music2 # set font family
font_path: assets/fonts/shiny_music.ttf # the font asset file path
icon_class: ShinyMusic2 # generated dart class name
out_dir: lib/fonts/shiny/ # generated file output dir
4、generate
flutter pub run iconfontool
# flutter pub run iconfontool -c iconfontool.yaml