Home

Awesome

icon_font_generator

pub package

The icon_font_generator package provides an easy way to convert SVG icons to OpenType font and generate Flutter-compatible class that contains identifiers for the icons (just like CupertinoIcons or Icons classes).

The package is written fully in Dart and doesn't require any external dependency. Compatible with dart2js and dart2native.

Font generation

Install via dev dependency

$ flutter pub add --dev icon_font_generator

# And it's ready to go:
$ flutter pub run icon_font_generator:generate <input-svg-dir> <output-font-file> [options]

or Globally activate the package:

$ pub global activate icon_font_generator

# And it's ready to go:
$ icon_font_generator <input-svg-dir> <output-font-file> [options]

Required positional arguments:

Flutter class options:

Font options:

Other options:

Usage example:

$ icon_font_generator assets/svg/ fonts/my_icons_font.otf --output-class-file=lib/my_icons.dart -r

Updated Flutter project's pubspec.yaml:

flutter:
  fonts:
    - family: My Icons
      fonts:
        - asset: fonts/my_icons_font.otf

Config file

icon_font_generator's configuration can also be placed in yaml file. Add icon_font section to either pubspec.yaml or icon_font.yaml file:

icon_font:
  input_svg_dir: "assets/svg/"
  output_font_file: "fonts/my_icons_font.otf"
  
  output_class_file: "lib/my_icons.dart"
  class_name: "MyIcons"
  package: my_font_package
  format: true

  font_name: "My Icons"
  normalize: true
  ignore_shapes: true

  recursive: true
  verbose: false

input_svg_dir and output_font_file keys are required. It's possible to specify any other config file by using --config-file option.

Using API

svgToOtf and generateFlutterClass functions can be used for generating font and Flutter class.

The example of API usage is located in example folder.

Notes

Contributing

Any suggestions, issues, pull requests are welcomed.

License

MIT

Credits

This software is fork of unsupported package: