woff2 library
Public API of the woff2 package.
See the package README for a quick start. The three main entry points are:
- loadWoffFontFromAsset — one-call helper for the typical
"bundle a
.woff2inassets/, use it inText(...)" case. - WoffFontRegistry — batch-register multiple
@font-facevariants (e.g. weight / style families) parsed from a CSS file. - decodeFontIfWoff — low-level decoder for callers that just want
WOFF/WOFF2→SFNTbytes and will handle font loading themselves.
Classes
- CssFontFaceRule
-
Parsed
@font-facerule containing font metadata and source. - WoffFontRegistry
- Registry for managing WOFF/WOFF2 (and TTF/OTF) fonts at runtime.
Enums
- WoffDecodeResult
- Result of a WOFF decode attempt.
Functions
-
decodeFontIfWoff(
Uint8List bytes) → (WoffDecodeResult, Uint8List?) -
Inspects
bytesand converts WOFF1/WOFF2 to SFNT if needed. -
extractFontFaceRules(
String cssText) → List< CssFontFaceRule> -
Extracts every
@font-face { ... }rule from a CSS text blob. -
loadWoffFontFromAsset(
{required String fontFamily, required String assetPath, AssetBundle? bundle}) → Future< bool> -
Loads a single WOFF / WOFF2 / TTF / OTF font from an asset bundle and
registers it under
fontFamilyso it can be used inText(...)widgets. -
loadWoffFontFromBytes(
{required String fontFamily, required Uint8List bytes}) → Future< bool> -
Loads a single WOFF / WOFF2 / TTF / OTF font from raw
bytesand registers it underfontFamily.
Typedefs
-
WoffSrcResolver
= Future<
Uint8List?> Function(String src) -
Callback used by WoffFontRegistry to resolve a
url(...)reference from a@font-facerule into the actual font bytes.