font_subset library

Builds or fetches the Flutter font-subset binary and provides a Dart API for subsetting TTF and OTF fonts.

Classes

BuildOptions
Configuration options read from hooks.user_defines.font_subset in pubspec.yaml (or the FONT_SUBSET_BUILD_MODE environment variable).
FontSubsetResult
Summary of a completed subsetFont invocation.

Enums

BuildModeEnum
Supported build modes for package:font_subset.

Constants

kSupportedFontMimeTypes → const Set<String>
The MIME types recognized as TTF/OTF font files that font-subset can process.

Functions

fontSubsetExecutable({BuildModeEnum? buildMode, Uri? checkoutPath, Uri? localPath, Uri? cacheDirectory}) → Future<File>
Resolves the font-subset executable for the current host, using the given buildMode (defaults to FONT_SUBSET_BUILD_MODE or BuildModeEnum.fetch, falling back to building from bundled C++/HarfBuzz sources with CMake).
isSupportedFontFile(File file) → Future<bool>
Returns whether file exists, has at least 12 bytes, and matches one of kSupportedFontMimeTypes.
subsetFont({required File input, required File output, required Iterable<int> codePoints, Iterable<int> optionalCodePoints = const <int>[], File? executable}) → Future<FontSubsetResult>
Runs font-subset to subset input into output, retaining only the glyphs at codePoints (and optionalCodePoints if present in input).

Exceptions / Errors

FontSubsetException
Exception thrown when locating or running font-subset fails.