未验证 提交 8320617d 编写于 作者: H Harry Terkelsen 提交者: GitHub

Adds Roboto as a global font fallback in CanvasKit (#23928)

上级 82a0b588
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册