Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom implementations for font data loading. #611

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tdenniston
Copy link

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.

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.

Fixes material-foundation#102.
@tdenniston tdenniston requested a review from a team as a code owner August 31, 2024 14:41
@tdenniston tdenniston requested review from guidezpl and removed request for a team August 31, 2024 14:41
Copy link

google-cla bot commented Aug 31, 2024

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.

@tdenniston
Copy link
Author

(CLA now signed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow obtaining the font files
1 participant