flutter-packages icon indicating copy to clipboard operation
flutter-packages copied to clipboard

Allow custom implementations for font data loading.

Open tdenniston opened this issue 1 year ago • 2 comments

This adds a new public API, GoogleFontsLoader, and a corresponding new instance field fontLoader in the global GoogleFonts.config class.

The new API allows users to hook the loading of fonts into the Flutter engine, which is useful in scenarios where the actual font data is needed for other purposes. The newly added default font loader simply uses Flutter's FontLoader as before.

Happy to make any changes!

Description

Any application that wishes to interact with the TTF data for a font retrieved via Google Fonts can use this API to access it. Issue #102 states one such example, using the popular Flutter pdf package to embed text using a font retrieved with this package.

Tests

Added test loadFontIfNecessary uses specified font loader and tested API use locally.

Issues

Fixes #102

Checklist

I did not update CHANGELOG.md because I am not aware of how the maintainers of this package would intend to release this change.

tdenniston avatar Aug 31 '24 14:08 tdenniston

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Aug 31 '24 14:08 google-cla[bot]

(CLA now signed)

tdenniston avatar Sep 04 '24 17:09 tdenniston