@@ -19,7 +19,7 @@ void main() {
1919 internalBootstrapBrowserTest (() => testMain);
2020}
2121
22- const ui.Rect kDefaultRegion = const ui.Rect .fromLTRB (0 , 0 , 500 , 250 );
22+ const ui.Rect kDefaultRegion = const ui.Rect .fromLTRB (0 , 0 , 100 , 50 );
2323
2424Future <void > matchPictureGolden (String goldenFile, CkPicture picture,
2525 {ui.Rect region = kDefaultRegion, bool write = false }) async {
@@ -105,22 +105,86 @@ void testMain() {
105105 final CkCanvas canvas = recorder.beginRecording (kDefaultRegion);
106106
107107 pb = CkParagraphBuilder (
108- CkParagraphStyle (
109- fontSize: 32 ,
110- ),
108+ CkParagraphStyle (),
111109 );
110+ pb.pushStyle (ui.TextStyle (fontSize: 32 ));
112111 pb.addText ('مرحبا' );
112+ pb.pop ();
113113 final CkParagraph paragraph = pb.build ();
114114 paragraph.layout (ui.ParagraphConstraints (width: 1000 ));
115115
116- canvas.drawParagraph (paragraph, ui.Offset (200 , 120 ));
116+ canvas.drawParagraph (paragraph, ui.Offset (0 , 0 ));
117117
118118 await matchPictureGolden (
119119 'canvaskit_font_fallback_arabic.png' , recorder.endRecording ());
120120 // TODO: https://github.com/flutter/flutter/issues/60040
121121 // TODO: https://github.com/flutter/flutter/issues/71520
122122 }, skip: isIosSafari || isFirefox);
123123
124+ test ('will download Noto Emojis and Noto Symbols if no matching Noto Font' ,
125+ () async {
126+ final Completer <void > fontChangeCompleter = Completer <void >();
127+ // Intercept the system font change message.
128+ ui.window.onPlatformMessage = (String name, ByteData ? data,
129+ ui.PlatformMessageResponseCallback ? callback) {
130+ if (name == 'flutter/system' ) {
131+ const JSONMessageCodec codec = JSONMessageCodec ();
132+ final dynamic message = codec.decodeMessage (data);
133+ if (message is Map ) {
134+ if (message['type' ] == 'fontsChange' ) {
135+ fontChangeCompleter.complete ();
136+ }
137+ }
138+ }
139+ if (savedCallback != null ) {
140+ savedCallback !(name, data, callback);
141+ }
142+ };
143+
144+ TestDownloader .mockDownloads[
145+ 'https://fonts.googleapis.com/css2?family=Noto+Color+Emoji+Compat' ] =
146+ '''
147+ /* arabic */
148+ @font-face {
149+ font-family: 'Noto Color Emoji';
150+ src: url(packages/ui/assets/NotoColorEmoji.ttf) format('ttf');
151+ }
152+ ''' ;
153+
154+ expect (skiaFontCollection.globalFontFallbacks, ['Roboto' ]);
155+
156+ // Creating this paragraph should cause us to start to download the
157+ // fallback font.
158+ CkParagraphBuilder pb = CkParagraphBuilder (
159+ CkParagraphStyle (),
160+ );
161+ pb.addText ('Hello 😊' );
162+
163+ await fontChangeCompleter.future;
164+
165+ expect (skiaFontCollection.globalFontFallbacks,
166+ contains ('Noto Color Emoji Compat 0' ));
167+
168+ final CkPictureRecorder recorder = CkPictureRecorder ();
169+ final CkCanvas canvas = recorder.beginRecording (kDefaultRegion);
170+
171+ pb = CkParagraphBuilder (
172+ CkParagraphStyle (),
173+ );
174+ pb.pushStyle (ui.TextStyle (fontSize: 26 ));
175+ pb.addText ('Hello 😊' );
176+ pb.pop ();
177+ final CkParagraph paragraph = pb.build ();
178+ paragraph.layout (ui.ParagraphConstraints (width: 1000 ));
179+
180+ canvas.drawParagraph (paragraph, ui.Offset (0 , 0 ));
181+
182+ await matchPictureGolden (
183+ 'canvaskit_font_fallback_emoji.png' , recorder.endRecording ());
184+ // TODO: https://github.com/flutter/flutter/issues/60040
185+ // TODO: https://github.com/flutter/flutter/issues/71520
186+ }, skip: isIosSafari || isFirefox);
187+
124188 test ('will gracefully fail if we cannot parse the Google Fonts CSS' ,
125189 () async {
126190 TestDownloader .mockDownloads[
0 commit comments