Skip to main content

woff2 0.1.1 copy "woff2: ^0.1.1" to clipboard
woff2: ^0.1.1 copied to clipboard

WOFF and WOFF2 font support for Flutter — decodes WOFF1/WOFF2 to SFNT (TTF/OTF) so Flutter's FontLoader can load them. Pure-Dart decoder, high-level Flutter FontLoader wrapper, and a CSS @font-face parser.

Changelog #

0.1.1 #

Fixed #

  • The package is now listed as Web-compatible on pub.dev. dart:io's zlib was imported unconditionally, which made pana mark the whole package (and every package depending on it) as not supporting Web. zlib decoding now sits behind a conditional import keyed on dart.library.js_interop. Native behaviour is unchanged.
  • On the web, compressed fonts fail gracefully as before. Uncompressed WOFF1 still decodes. zlib-compressed WOFF1 and WOFF2 return WoffDecodeResult.malformed, and the loaders return false.

0.1.0 — initial release #

First public release. The decoder and Flutter FontLoader wrapper were extracted from flutter_full_svg_support, where they have shipped since v1.0.0 driving SVG @font-face handling.

Added #

  • decodeFontIfWoff(Uint8List bytes) — pure-Dart WOFF1 and WOFF2 → SFNT (TTF/OTF) decoder. Implements the full W3C WOFF2 spec including glyf/loca/hmtx transformations.
  • loadWoffFontFromAsset({fontFamily, assetPath}) — one-call helper that loads a .woff2 asset and registers it with Flutter's FontLoader so it works in Text(...) and TextStyle.
  • loadWoffFontFromBytes({fontFamily, bytes}) — the same, for bytes in memory (network, file system, runtime-generated).
  • WoffFontRegistry — batch-registers multiple weight/style variants of one or more font families, typically from a parsed CSS file.
  • extractFontFaceRules(String cssText) — minimal CSS @font-face parser that returns CssFontFaceRule value objects with font-family, font-weight (normalised to numeric), font-style, src, and format.

Known limitations #

  • WOFF2 TTC collections are not supported (decoder returns WoffDecodeResult.malformed).
  • Flutter Web is not a target platform — modern browsers handle .woff2 natively via @font-face in CSS.
2
likes
150
points
3.03k
downloads

Documentation

Documentation
API reference

Publisher

unverified uploader

Weekly Downloads

WOFF and WOFF2 font support for Flutter — decodes WOFF1/WOFF2 to SFNT (TTF/OTF) so Flutter's FontLoader can load them. Pure-Dart decoder, high-level Flutter FontLoader wrapper, and a CSS @font-face parser.

Homepage
Repository (GitHub)
View/report issues

Topics

#fonts #woff2 #woff #typography #sfnt

License

Apache-2.0 (license)

Dependencies

es_compression, flutter

More

Packages that depend on woff2