Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class SkwasmParagraph extends SkwasmObjectWrapper<RawParagraph> implements ui.Pa
@override
void layout(ui.ParagraphConstraints constraints) {
paragraphLayout(handle, constraints.width);
if (!_hasCheckedForMissingCodePoints) {
if (!debugDisableFontFallbacks && !_hasCheckedForMissingCodePoints) {
Copy link
Member

Choose a reason for hiding this comment

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

I find if !(debugDisableFontFallbacks || _hasCheckedForMissingCodePoints) a little bit more legible, but... it's the same.

_hasCheckedForMissingCodePoints = true;
final int missingCodePointCount = paragraphGetUnresolvedCodePoints(handle, nullptr, 0);
if (missingCodePointCount > 0) {
Expand Down
20 changes: 20 additions & 0 deletions lib/web_ui/test/ui/fallback_fonts_golden_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,26 @@ void testMain() {
}
}
});

test('fallback fonts do not download when debugDisableFontFallbacks is set', () async {
debugDisableFontFallbacks = true;

expect(renderer.fontCollection.fontFallbackManager!.globalFontFallbacks, <String>['Roboto']);

// Creating this paragraph would cause us to start to download the
// fallback font if we didn't disable font fallbacks.
final ui.ParagraphBuilder pb = ui.ParagraphBuilder(
ui.ParagraphStyle(),
);
pb.addText('Hello 😊');
pb.build().layout(const ui.ParagraphConstraints(width: 1000));

await renderer.fontCollection.fontFallbackManager!.debugWhenIdle();

// Make sure we didn't download the fallback font.
expect(renderer.fontCollection.fontFallbackManager!.globalFontFallbacks,
isNot(contains('Noto Color Emoji')));
});
},
// HTML renderer doesn't use the fallback font manager.
skip: isHtml,
Expand Down