diff --git a/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/paragraph.dart b/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/paragraph.dart index e872c768a3af3..97c5b173b1b2c 100644 --- a/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/paragraph.dart +++ b/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/paragraph.dart @@ -113,7 +113,7 @@ class SkwasmParagraph extends SkwasmObjectWrapper implements ui.Pa @override void layout(ui.ParagraphConstraints constraints) { paragraphLayout(handle, constraints.width); - if (!_hasCheckedForMissingCodePoints) { + if (!debugDisableFontFallbacks && !_hasCheckedForMissingCodePoints) { _hasCheckedForMissingCodePoints = true; final int missingCodePointCount = paragraphGetUnresolvedCodePoints(handle, nullptr, 0); if (missingCodePointCount > 0) { diff --git a/lib/web_ui/test/ui/fallback_fonts_golden_test.dart b/lib/web_ui/test/ui/fallback_fonts_golden_test.dart index 4570bf2404817..621a9a3334df7 100644 --- a/lib/web_ui/test/ui/fallback_fonts_golden_test.dart +++ b/lib/web_ui/test/ui/fallback_fonts_golden_test.dart @@ -431,6 +431,26 @@ void testMain() { } } }); + + test('fallback fonts do not download when debugDisableFontFallbacks is set', () async { + debugDisableFontFallbacks = true; + + expect(renderer.fontCollection.fontFallbackManager!.globalFontFallbacks, ['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,