Skip to main content

font_asset 0.1.0 copy "font_asset: ^0.1.0" to clipboard
font_asset: ^0.1.0 copied to clipboard

A hooks protocol extension for declaring font assets from build hooks in Flutter.

package:font_asset #

A package:hooks protocol extension that lets a package declare font files from its hook/build.dart instead of the flutter: fonts: section of pubspec.yaml.

Flutter bundles these fonts exactly like pubspec.yaml fonts: they are listed in FontManifest.json (so the engine pre-registers them and no FontLoader call is needed) and icon fonts are subsetted by Flutter's icon tree shaker in release builds.

// hook/build.dart
import 'package:font_asset/font_asset.dart';
import 'package:hooks/hooks.dart';

void main(List<String> args) => build(args, (input, output) async {
  addFontFamily(
    input,
    output,
    family: 'Roboto',
    fonts: const [
      FontFile('fonts/Roboto-Regular.ttf'),
      FontFile('fonts/Roboto-Bold.ttf', weight: 700),
    ],
  );
});

Fonts of a dependency package are available under the family name packages/<package>/<family>, fonts of the app itself under <family>.

Experimental: requires the Flutter data assets experiment (flutter config --enable-dart-data-assets).

1
likes
150
points
75
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A hooks protocol extension for declaring font assets from build hooks in Flutter.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

Dependencies

hooks

More

Packages that depend on font_asset