피드로 돌아가기
Stop hand-writing IconData — introducing `icon_font_extractor`
Dev.toDev.to
Frontend

GSUB Ligature 분석을 통한 Flutter IconData 자동 생성 및 Tree-shaking 최적화

Stop hand-writing IconData — introducing `icon_font_extractor`

Julian Finkler2026년 5월 14일4intermediate

Context

Custom Icon Font 도입 시 Codepoint를 수동으로 매핑하는 반복적 작업과 유지보수 비용 발생. 기존 Third-party 패키지는 무료 버전 한정 및 버전 간 동기화 지연으로 인해 Pro 버전 폰트의 효율적 활용 불가.

Technical Solution

  • 폰트 파일 내 GSUB Ligature Table을 분석하여 Human-readable string과 Glyph ID 간의 매핑 관계 추출
  • cmap Table과의 연동을 통한 Glyph ID 기반의 정확한 Codepoint 도출 로직 구현
  • Pure Dart 기반의 분석 엔진 설계를 통한 Native Dependency 및 외부 툴 의존성 제거
  • @staticIconProvider 어노테이션 기반의 코드 생성으로 Flutter 내장 Tree-shaking 메커니즘 활성화
  • YAML 설정을 통한 Naming Strategy 및 Prefix 제어로 팀별 컨벤션 유연성 확보
  • CI 파이프라인 내 --check 플래그 도입을 통한 Generated Code의 정합성 검증 자동화

- Custom 폰트 도입 시 Codepoint 수동 매핑 대신 Ligature 기반 자동 생성 도구 검토 - 릴리즈 빌드 크기 최적화를 위해 @staticIconProvider 기반의 Tree-shaking 적용 여부 확인 - Generated Code의 버전 관리를 위해 CI 단계에서 --check 옵션을 통한 변경 사항 감지 체계 구축

원문 읽기