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

[google_fonts] Enhance font fallback #505

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

gonuit
Copy link

@gonuit gonuit commented Nov 17, 2023

Description

The main motivation behind this change is to improve the font fallback mechanism. This makes it possible to switch to another font if the current one does not support certain glyphs.

For example, replace all emoticons with an emoji font:

/* ... */
theme: GoogleFonts.latoTextTheme(
  GoogleFonts.notoColorEmojiTextTheme(theme.textTheme),
);
/* ... */

With these changes, the app will still use the lato font, but all emoji will be replaced by notoColorEmoji.

Tests

Verifying that the text style correctly falls back to the next available font when the primary font is unavailable.

Checklist

@gonuit gonuit requested a review from a team as a code owner November 17, 2023 00:40
@gonuit gonuit requested review from guidezpl and removed request for a team November 17, 2023 00:40
Copy link
Collaborator

@guidezpl guidezpl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing! Do you think adding a short example to the README or Dart documentation some dartdoc would make it easier to find this feature?

Comment on lines +124 to +126
fontFamily,
if (currentFontFamily != null) currentFontFamily,
...?textStyle.fontFamilyFallback,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand the need for 124 and 125, can you please clarify?

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

Successfully merging this pull request may close these issues.

2 participants