flutter_freetype
Cross-platform FreeType bindings for Flutter using FFI on native platforms and WebAssembly on the web.
Features
- Bindings generated automatically with ffigen
- Native FreeType is built automatically by the Flutter
plugin_ffibuild (Android/iOS/macOS/Linux/Windows) - Web/Wasm uses the bundled
wasm/dist/freetype.{js,wasm}
Installation
dependencies:
flutter_freetype: ^1.0.0
Binding generation
dart run ffigen
Native builds (Android/iOS/macOS/Linux/Windows)
No manual steps required. The consuming Flutter app builds and bundles the native library automatically (Flutter plugin_ffi).
Usage
Prefer the async constructor so the same code works on Web/Wasm and native:
import 'package:flutter_freetype/flutter_freetype.dart';
final ft = await Freetype.create();
On Web/Wasm, load fonts from bytes (paths are not supported):
final face = ft.newFaceFromBytes(fontBytes);
If you need the raw ffigen bindings on native platforms, import:
import 'package:flutter_freetype/flutter_freetype_ffi.dart';
Tests
- VM (default):
flutter test test/vm - Web/Wasm (optional):
RUN_WEB_TESTS=1 ./scripts/test_all.sh - All (VM only):
./scripts/test_all.sh
License
Original package code is available under the MIT License. The bundled FreeType source and binary are distributed under the FreeType License. Other bundled components and the example font retain their respective open-source licenses. See THIRD_PARTY_NOTICES.md for attribution and full license references.
Libraries
- flutter_freetype
- flutter_freetype_ffi
- Native (Dart VM / Flutter native) FFI exports.