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_subsetinpubspec.yaml(or theFONT_SUBSET_BUILD_MODEenvironment 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-subsetcan process.
Functions
-
fontSubsetExecutable(
{BuildModeEnum? buildMode, Uri? checkoutPath, Uri? localPath, Uri? cacheDirectory}) → Future< File> -
Resolves the
font-subsetexecutable for the current host, using the givenbuildMode(defaults toFONT_SUBSET_BUILD_MODEor BuildModeEnum.fetch, falling back to building from bundled C++/HarfBuzz sources with CMake). -
isSupportedFontFile(
File file) → Future< bool> -
Returns whether
fileexists, 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-subsetto subsetinputintooutput, retaining only the glyphs atcodePoints(andoptionalCodePointsif present ininput).
Exceptions / Errors
- FontSubsetException
-
Exception thrown when locating or running
font-subsetfails.