[Breaking change] Load platform fonts fallback to avoid squares instead of glyphs - #49
Open
MaximeRougieux wants to merge 5 commits into
Open
[Breaking change] Load platform fonts fallback to avoid squares instead of glyphs#49MaximeRougieux wants to merge 5 commits into
MaximeRougieux wants to merge 5 commits into
Conversation
The matrix only covered the three example apps, so nothing under `test/` ever ran on CI. Format and analyze are left out of this job for now: the package sources still carry pre-existing analyzer infos. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A font bundled by a dependency is exposed by the font manifest as `packages/my_theme/Roboto`, and `loadFonts()` only registered it under that name. A widget styled with `TextStyle(fontFamily: 'Roboto', package: 'my_theme')` — or a theme defaulting to that family — asks for the bare `Roboto` instead, so no font was found and the text rendered as placeholder blocks in the goldens. Register both names. `loadFonts()` now returns the families it registered, which is also what lets the tests assert on it without shared state. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The families a widget gets when it specifies no font — `Roboto` on Android, `CupertinoSystemText` on iOS, `Segoe UI` on Windows — are declared in no `pubspec.yaml`: they either ship with the Flutter SDK or belong to the host OS. `loadFonts()` could not find them in the font manifest, so a `DatePickerDialog` or a `CupertinoButton` rendered as placeholder blocks in the goldens. The list is gathered from `Typography` and `CupertinoTextThemeData` instead of being hardcoded, so it follows the SDK. The families the SDK ships are loaded from its font cache, found through `FLUTTER_ROOT` or by walking up from the test executable. The ones only the OS can provide are aliased to the typeface the SDK ships: the glyphs then differ from a real device, but the goldens stay readable. Opt out with `setLoadPlatformFallbackFonts(false)`. `FontLoadingPolicy` holds what is registered on top of the manifest, and with it the arbitration introduced here: a dependency font does not claim the bare name of a platform default the SDK ships a font for. It usually bundles a single weight of such a family while the SDK ships all of them, and on a device it would not shadow the platform font either. The SDK font files are sorted before being registered: a directory listing comes back in file system order, which differs between APFS, ext4 and NTFS, and goldens must not depend on the machine that generated them. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
T-moz
self-requested a review
August 3, 2026 14:11
MaximeRougieux
force-pushed
the
chore/lint-and-ci
branch
3 times, most recently
from
August 4, 2026 08:25
af61701 to
7837c46
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With this PR, the fonts loaded by the package now also includes fallback system fonts that are not declared in the manifest, but that are sometimes used in Flutter widgets like Material and Cupertino widgets
This behavior is optional and can be opted-out (though it is on by default)