Adds Roboto as a global font fallback in CanvasKit (flutter/engine#23928)
This commit is contained in:
@@ -28,7 +28,7 @@ class SkiaFontCollection {
|
||||
final Map<String, List<SkTypeface>> familyToTypefaceMap =
|
||||
<String, List<SkTypeface>>{};
|
||||
|
||||
final List<String> globalFontFallbacks = <String>[];
|
||||
final List<String> globalFontFallbacks = <String>['Roboto'];
|
||||
|
||||
final Map<String, int> _fontFallbackCounts = <String, int>{};
|
||||
|
||||
@@ -178,6 +178,7 @@ class SkiaFontCollection {
|
||||
void debugResetFallbackFonts() {
|
||||
_registeredFallbackFonts.clear();
|
||||
globalFontFallbacks.clear();
|
||||
globalFontFallbacks.add('Roboto');
|
||||
_fontFallbackCounts.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -814,9 +814,7 @@ enum _ParagraphCommandType {
|
||||
List<String> _getEffectiveFontFamilies(String? fontFamily,
|
||||
[List<String>? fontFamilyFallback]) {
|
||||
List<String> fontFamilies = <String>[];
|
||||
if (fontFamily == null) {
|
||||
fontFamilies.add('Roboto');
|
||||
} else {
|
||||
if (fontFamily != null) {
|
||||
fontFamilies.add(fontFamily);
|
||||
}
|
||||
if (fontFamilyFallback != null &&
|
||||
|
||||
@@ -51,6 +51,10 @@ void testMain() {
|
||||
ui.window.onPlatformMessage = savedCallback;
|
||||
});
|
||||
|
||||
test('Roboto is always a fallback font', () {
|
||||
expect(skiaFontCollection.globalFontFallbacks, contains('Roboto'));
|
||||
});
|
||||
|
||||
test('will download Noto Naskh Arabic if Arabic text is added', () async {
|
||||
final Completer<void> fontChangeCompleter = Completer<void>();
|
||||
// Intercept the system font change message.
|
||||
@@ -83,7 +87,7 @@ void testMain() {
|
||||
}
|
||||
''';
|
||||
|
||||
expect(skiaFontCollection.globalFontFallbacks, isEmpty);
|
||||
expect(skiaFontCollection.globalFontFallbacks, ['Roboto']);
|
||||
|
||||
// Creating this paragraph should cause us to start to download the
|
||||
// fallback font.
|
||||
@@ -123,7 +127,7 @@ void testMain() {
|
||||
'https://fonts.googleapis.com/css2?family=Noto+Naskh+Arabic+UI'] =
|
||||
'invalid CSS... this should cause our parser to fail';
|
||||
|
||||
expect(skiaFontCollection.globalFontFallbacks, isEmpty);
|
||||
expect(skiaFontCollection.globalFontFallbacks, ['Roboto']);
|
||||
|
||||
// Creating this paragraph should cause us to start to download the
|
||||
// fallback font.
|
||||
@@ -136,7 +140,7 @@ void testMain() {
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
|
||||
expect(notoDownloadQueue.isPending, isFalse);
|
||||
expect(skiaFontCollection.globalFontFallbacks, isEmpty);
|
||||
expect(skiaFontCollection.globalFontFallbacks, ['Roboto']);
|
||||
});
|
||||
// TODO: https://github.com/flutter/flutter/issues/60040
|
||||
}, skip: isIosSafari);
|
||||
|
||||
Reference in New Issue
Block a user