패키지, 저장소 및 앱 카테고리 검색

패키지 상세v4.1.0

icon_font_generator

SVG 아이콘을 OTF 폰트로 변환하고 Flutter 호환 클래스를 생성합니다. API 및 CLI 도구를 제공합니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
3.4만
좋아요
147
Pub 점수
130

패키지 설치

flutter pub add icon_font_generator

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

SVG 아이콘을 OTF 폰트로 변환하고 Flutter 앱에 쉽게 통합할 수 있도록 관련 Dart 클래스를 생성하는 플러터/다트 패키지입니다. 자동화를 위한 명령줄 인터페이스(CLI)와 API를 제공하여 여러 플랫폼에서 아이콘 관리를 간소화합니다. 생성된 폰트는 안드로이드, iOS, 웹, 맥OS, 윈도우, 리눅스와 호환되어 일관된 아이콘 렌더링을 보장합니다. 사용자 정의 아이콘 세트를 효율적으로 관리하는 팀에게 이상적입니다.

사용 사례

  • SVG에서 사용자 지정 아이콘 폰트 생성
  • 아이콘 자산 생성 자동화
  • Flutter 앱에 벡터 아이콘 통합하기
  • 다중 플랫폼 아이콘 렌더링 지원
  • 디자인에서 코드로의 워크플로우를 간소화하세요

주요 기능

  • SVG에서 OTF 글꼴로의 변환
  • 아이콘용 Dart 클래스 생성
  • CLI 및 API 인터페이스
  • 크로스 플랫폼 지원
  • 사용자 정의 아이콘 세트 관리
  • Flutter와의 간편한 통합

적합한 대상

  • Flutter 개발자
  • 디자인 팀
  • UI/UX 엔지니어
  • 사용자 지정 아이콘을 필요로 하는 앱
  • 자주 아이콘을 업데이트하는 프로젝트

고려 사항

  • 입력으로 SVG 파일이 필요합니다
  • CLI 또는 API 사용을 위해 설정이 필요합니다
  • 추가 빌드 단계가 필요할 수 있습니다
  • 폰트 파일 크기 고려 사항
  • 아이콘만 사용 가능한 경우에 한정

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

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:

  • <input-svg-dir> Path to the input directory that contains .svg files.
  • <output-font-file> Path to the output font file. Should have .otf extension.

Flutter class options:

  • -o or --output-class-file=<path> Output path for Flutter-compatible class that contains identifiers for the icons.
  • -c or --class-name=<name> Name for a generated class.
  • -p or --package=<name> Name of a package that provides a font. Used to provide a font through package dependency.
  • --[no-]format Format dart generated code.

Font options:

  • -f or --font-name=<name> Name for a generated font.
  • --[no-]normalize Enables glyph normalization for the font. Disable this if every icon has the same size and positioning. (defaults to on)
  • --[no-]ignore-shapes Disables SVG shape-to-path conversion (circle, rect, etc.). (defaults to on)

Other options:

  • -z or --config-file=<path> Path to icon_font_generator yaml configuration file. pubspec.yaml and icon_font.yaml files are used by default.
  • -r or --recursive Recursively look for .svg files.
  • -v or --verbose Display every logging message.
  • -h or --help Shows usage information.

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

  • Generated OpenType font is using CFF table.
  • Generated font is using PostScript Table (post) of version 3.0, i.e., it doesn't contain glyph names.
  • Supported SVG elements: path, g, circle, rect, polyline, polygon, line.
  • SVG transforms are applied to paths according to specs.
  • SVG <g> element's children are expanded to the root with transformations applied. Anything else related to the group is ignored and group referencing is not supported.
  • Consider using Non-zero fill rule.
  • When ignoreShapes is set to false, every SVG shape's (circle, rect, etc.) outline is converted to path. Note that any attributes like "fill" or "stroke" are ignored and only the outline is used, so the resulting glyph may look different from SVG icon. It's recommended to convert every element in SVG to path.
  • When normalize is set to false, it's recommended that SVG icons have the same height. Otherwise, final result might not look as expected.
  • When Flutter class is generated, static variables names derive from SVG file name converted to pascal case with non-allowed characters removed. Name is set to 'unnamed', if it's empty. Suffix '_{i+1}' is added, if name already exists.

Contributing

Any suggestions, issues, pull requests are welcomed.

License

MIT

Credits

This software is fork of unsupported package:

카테고리

의존성

의존성 목록 11 개

소스 저장소

이 패키지를 사용하는 프로젝트