Skip to content

Feat/warn missing fonts - #47

Open
MaximeRougieux wants to merge 2 commits into
chore/lint-and-cifrom
feat/warn-missing-fonts
Open

Feat/warn missing fonts#47
MaximeRougieux wants to merge 2 commits into
chore/lint-and-cifrom
feat/warn-missing-fonts

Conversation

@MaximeRougieux

Copy link
Copy Markdown
Contributor

With this PR, the package now warns when a test creates a golden of a widget that uses an unknown font

This behavior is optional and can be opted-out (though it is on by default)

@T-moz
T-moz self-requested a review August 3, 2026 14:11
Comment thread lib/src/adaptive/adaptive_test.dart Outdated
await awaitImages();
}

// Find by its type except if the widget's unique key was given.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Delete this comment

Comment thread lib/src/adaptive/adaptive_test.dart Outdated
);
}

/// Warns about the font families the snapshotted tree asks for while no font

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Delete this comment

Comment thread lib/src/helpers/fonts_loader.dart Outdated
Comment on lines +19 to +21
/// The registered families are also recorded in the
/// [AdaptiveTestConfiguration], which is how [expectGolden] knows whether the
/// text it snapshots will render real glyphs.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Remove those added comments. They don't help package user use the function

Comment thread test/helpers/fonts_loader_test.dart Outdated
});

test('records the loaded families in the configuration', () {
// This is how expectGolden knows what will render real glyphs.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Remove this comments

Comment on lines +52 to +77
final Set<String> _loadedFontFamilies = {};

/// The font families [loadFonts] registered in this test isolate.
Set<String> get loadedFontFamilies => Set.unmodifiable(_loadedFontFamilies);

/// Records the families [loadFonts] registered, so that [expectGolden] can
/// tell whether the text it snapshots will render real glyphs.
void addLoadedFontFamilies(Iterable<String> families) {
_loadedFontFamilies.addAll(families);
}

final Set<String> _warnedFontFamilies = {};

/// The missing font families [expectGolden] already warned about, see
/// [MissingFontsBehavior.warn].
Set<String> get warnedFontFamilies => Set.unmodifiable(_warnedFontFamilies);

/// Records the families that were warned about, so that a gap shared by many
/// goldens is only reported once.
void addWarnedFontFamilies(Iterable<String> families) {
_warnedFontFamilies.addAll(families);
}

MissingFontsBehavior _missingFontsBehavior = MissingFontsBehavior.warn;

MissingFontsBehavior get missingFontsBehavior => _missingFontsBehavior;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

All how this should stay private. or at least not being exposed to the public API of adaptive_test

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed I think I missed this part when reviewing, sorry i'll see what i can change

Comment thread lib/src/configuration.dart Outdated
/// [MissingFontsBehavior.warn].
Set<String> get warnedFontFamilies => Set.unmodifiable(_warnedFontFamilies);

/// Records the families that were warned about, so that a gap shared by many

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

delete this comment

Comment thread lib/src/configuration.dart Outdated

final Set<String> _warnedFontFamilies = {};

/// The missing font families [expectGolden] already warned about, see

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

delete this comment

Comment thread lib/src/configuration.dart Outdated
/// The font families [loadFonts] registered in this test isolate.
Set<String> get loadedFontFamilies => Set.unmodifiable(_loadedFontFamilies);

/// Records the families [loadFonts] registered, so that [expectGolden] can

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

delete this comment

Comment thread lib/src/configuration.dart Outdated

final Set<String> _loadedFontFamilies = {};

/// The font families [loadFonts] registered in this test isolate.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

delete this comment

@T-moz

T-moz commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

@MaximeRougieux Remove "Co-Authored-By" AI commit attributions

@MaximeRougieux
MaximeRougieux force-pushed the feat/warn-missing-fonts branch from 8c13588 to d53c8e6 Compare August 4, 2026 08:52
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.

2 participants