@@ -24,24 +24,24 @@ class FontFallbackManager {
2424 factory FontFallbackManager (FallbackFontRegistry registry) =>
2525 FontFallbackManager ._(registry, getFallbackFontList ());
2626
27- FontFallbackManager ._(this .registry , this .fallbackFonts )
28- : _notoSymbols = fallbackFonts .singleWhere (
27+ FontFallbackManager ._(this ._registry , this ._fallbackFonts )
28+ : _notoSymbols = _fallbackFonts .singleWhere (
2929 (NotoFont font) => font.name == 'Noto Sans Symbols' ,
3030 ) {
31- downloadQueue = FallbackFontDownloadQueue (this );
31+ _downloadQueue = _FallbackFontDownloadQueue (this );
3232 }
3333
34- final FallbackFontRegistry registry ;
34+ final FallbackFontRegistry _registry ;
3535
36- late final FallbackFontDownloadQueue downloadQueue ;
36+ late final _FallbackFontDownloadQueue _downloadQueue ;
3737
3838 /// Code points that no known font has a glyph for.
39- final Set <int > codePointsWithNoKnownFont = < int > {};
39+ final Set <int > _codePointsWithNoKnownFont = < int > {};
4040
4141 /// Code points which are known to be covered by at least one fallback font.
42- final Set <int > knownCoveredCodePoints = < int > {};
42+ final Set <int > _knownCoveredCodePoints = < int > {};
4343
44- final List <NotoFont > fallbackFonts ;
44+ final List <NotoFont > _fallbackFonts ;
4545
4646 // By default, we use the system language to determine the user's preferred
4747 // language. This can be overridden through [debugUserPreferredLanguage] for testing.
@@ -55,6 +55,9 @@ class FontFallbackManager {
5555 _language = value;
5656 }
5757
58+ @visibleForTesting
59+ void Function (String family)? debugOnLoadFontFamily;
60+
5861 final NotoFont _notoSymbols;
5962
6063 Future <void > _idleFuture = Future <void >.value ();
@@ -101,8 +104,8 @@ class FontFallbackManager {
101104 for (final int rune in text.runes) {
102105 // Filter out code points that don't need checking.
103106 if (! (rune < 160 || // ASCII and Unicode control points.
104- knownCoveredCodePoints .contains (rune) || // Points we've already covered
105- codePointsWithNoKnownFont .contains (rune)) // Points that don't have a fallback font
107+ _knownCoveredCodePoints .contains (rune) || // Points we've already covered
108+ _codePointsWithNoKnownFont .contains (rune)) // Points that don't have a fallback font
106109 ) {
107110 runesToCheck.add (rune);
108111 }
@@ -112,7 +115,7 @@ class FontFallbackManager {
112115 }
113116
114117 final List <int > codePoints = runesToCheck.toList ();
115- final List <int > missingCodePoints = registry .getMissingCodePoints (codePoints, fontFamilies);
118+ final List <int > missingCodePoints = _registry .getMissingCodePoints (codePoints, fontFamilies);
116119
117120 if (missingCodePoints.isNotEmpty) {
118121 addMissingCodePoints (codePoints);
@@ -126,7 +129,7 @@ class FontFallbackManager {
126129 _idleFuture = Future <void >.delayed (Duration .zero, () async {
127130 _ensureFallbackFonts ();
128131 _scheduledCodePointCheck = false ;
129- await downloadQueue .waitForIdle ();
132+ await _downloadQueue .waitForIdle ();
130133 });
131134 }
132135 }
@@ -168,7 +171,7 @@ class FontFallbackManager {
168171 /// user's locale.
169172 ///
170173 /// If a code point is not covered by any font, it is added to
171- /// [codePointsWithNoKnownFont ] so it can be omitted next time to avoid
174+ /// [_codePointsWithNoKnownFont ] so it can be omitted next time to avoid
172175 /// searching for fonts unnecessarily.
173176 void findFontsForMissingCodePoints (List <int > codePoints) {
174177 final List <int > missingCodePoints = < int > [];
@@ -227,18 +230,18 @@ class FontFallbackManager {
227230 candidateFonts.removeWhere ((NotoFont font) => font.coverCount == 0 );
228231 }
229232
230- selectedFonts.forEach (downloadQueue .add);
233+ selectedFonts.forEach (_downloadQueue .add);
231234
232235 // Report code points not covered by any fallback font and ensure we don't
233236 // process those code points again.
234237 if (missingCodePoints.isNotEmpty) {
235- if (! downloadQueue .isPending) {
238+ if (! _downloadQueue .isPending) {
236239 printWarning (
237240 'Could not find a set of Noto fonts to display all missing '
238241 'characters. Please add a font asset for the missing characters.'
239242 ' See: https://flutter.dev/docs/cookbook/design/fonts' ,
240243 );
241- codePointsWithNoKnownFont .addAll (missingCodePoints);
244+ _codePointsWithNoKnownFont .addAll (missingCodePoints);
242245 }
243246 }
244247 }
@@ -335,7 +338,7 @@ class FontFallbackManager {
335338 if (kFontIndexDigit0 <= code && code < kFontIndexDigit0 + kFontIndexRadix) {
336339 final int delta = prefix * kFontIndexRadix + (code - kFontIndexDigit0);
337340 final int index = previousIndex + delta + 1 ;
338- result.add (fallbackFonts [index]);
341+ result.add (_fallbackFonts [index]);
339342 previousIndex = index;
340343 prefix = 0 ;
341344 } else if (kPrefixDigit0 <= code && code < kPrefixDigit0 + kPrefixRadix) {
@@ -436,20 +439,16 @@ class _UnicodePropertyLookup<P> {
436439 }
437440}
438441
439- class FallbackFontDownloadQueue {
440- FallbackFontDownloadQueue (this .fallbackManager);
442+ class _FallbackFontDownloadQueue {
443+ _FallbackFontDownloadQueue (this .fallbackManager);
441444
442445 final FontFallbackManager fallbackManager;
443446
444- String get fallbackFontUrlPrefix => configuration.fontFallbackBaseUrl;
445-
446447 final Set <NotoFont > downloadedFonts = < NotoFont > {};
447448 final Map <String , NotoFont > pendingFonts = < String , NotoFont > {};
448449
449450 bool get isPending => pendingFonts.isNotEmpty;
450451
451- void Function (String family)? debugOnLoadFontFamily;
452-
453452 Completer <void >? _idleCompleter;
454453
455454 Future <void > waitForIdle () {
@@ -478,17 +477,14 @@ class FallbackFontDownloadQueue {
478477 final List <String > downloadedFontFamilies = < String > [];
479478 for (final NotoFont font in pendingFonts.values) {
480479 downloads[font.url] = Future <void >(() async {
480+ final String url = '${configuration .fontFallbackBaseUrl }${font .url }' ;
481481 try {
482- final String url = '$fallbackFontUrlPrefix ${font .url }' ;
483- debugOnLoadFontFamily? .call (font.name);
484- await fallbackManager.registry.loadFallbackFont (font.name, url);
482+ fallbackManager.debugOnLoadFontFamily? .call (font.name);
483+ await fallbackManager._registry.loadFallbackFont (font.name, url);
485484 downloadedFontFamilies.add (font.url);
486485 } catch (e) {
487486 pendingFonts.remove (font.url);
488- printWarning (
489- 'Failed to load font ${font .name } at '
490- '$fallbackFontUrlPrefix ${font .url }' ,
491- );
487+ printWarning ('Failed to load font ${font .name } at $url ' );
492488 printWarning (e.toString ());
493489 return ;
494490 }
@@ -508,7 +504,7 @@ class FallbackFontDownloadQueue {
508504 }
509505
510506 if (pendingFonts.isEmpty) {
511- fallbackManager.registry .updateFallbackFontFamilies (fallbackManager.globalFontFallbacks);
507+ fallbackManager._registry .updateFallbackFontFamilies (fallbackManager.globalFontFallbacks);
512508 sendFontChangeMessage ();
513509 final Completer <void > idleCompleter = _idleCompleter! ;
514510 _idleCompleter = null ;
0 commit comments