flutter-packages
flutter-packages copied to clipboard
Allow custom implementations for font data loading.
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
- [X] I've reviewed the contribution guide.
- [ ] I've updated the package
CHANGELOG.md
I did not update CHANGELOG.md because I am not aware of how the maintainers of this package would intend to release this change.
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.
(CLA now signed)