From 55c624c13ac57b225c10efe6bea462bade083c64 Mon Sep 17 00:00:00 2001 From: Jackson Gardner Date: Fri, 22 Mar 2024 10:30:58 -0700 Subject: [PATCH 1/2] Don't fetch fallback fonts when the debug flag is enabled. --- .../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/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..027a628640ba2 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 disabled', () 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, From b6393954904bfc53c7714aac896f2fae2ccfb6c7 Mon Sep 17 00:00:00 2001 From: Jackson Gardner Date: Fri, 22 Mar 2024 11:47:08 -0700 Subject: [PATCH 2/2] Update lib/web_ui/test/ui/fallback_fonts_golden_test.dart Co-authored-by: David Iglesias --- lib/web_ui/test/ui/fallback_fonts_golden_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 027a628640ba2..621a9a3334df7 100644 --- a/lib/web_ui/test/ui/fallback_fonts_golden_test.dart +++ b/lib/web_ui/test/ui/fallback_fonts_golden_test.dart @@ -432,7 +432,7 @@ void testMain() { } }); - test('fallback fonts do not download when debugDisableFontFallbacks is disabled', () async { + test('fallback fonts do not download when debugDisableFontFallbacks is set', () async { debugDisableFontFallbacks = true; expect(renderer.fontCollection.fontFallbackManager!.globalFontFallbacks, ['Roboto']);