From f79cfcc0d38681b1abbb2e1168933db38f947059 Mon Sep 17 00:00:00 2001 From: Jackson Gardner Date: Fri, 22 Mar 2024 12:22:22 -0700 Subject: [PATCH] [Skwasm] Respect the `debugDisableFallbackFonts` flag. (flutter/engine#51626) Skwasm needs to respect the `debugDisableFallbackFonts` flag, which is used by framework tests. --- .../engine/skwasm/skwasm_impl/paragraph.dart | 2 +- .../test/ui/fallback_fonts_golden_test.dart | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/paragraph.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/paragraph.dart index e872c768a3a..97c5b173b1b 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/paragraph.dart +++ b/engine/src/flutter/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/engine/src/flutter/lib/web_ui/test/ui/fallback_fonts_golden_test.dart b/engine/src/flutter/lib/web_ui/test/ui/fallback_fonts_golden_test.dart index 4570bf24048..621a9a3334d 100644 --- a/engine/src/flutter/lib/web_ui/test/ui/fallback_fonts_golden_test.dart +++ b/engine/src/flutter/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,