Switch from Noto Emoji to Noto Color Emoji and update font data (flutter/engine#40666)

This commit is contained in:
Harry Terkelsen
2023-03-29 14:12:25 -07:00
committed by GitHub
parent 7dbbb4052e
commit 8f9c5e83dd
4 changed files with 49 additions and 43 deletions

View File

@@ -64,7 +64,8 @@ class GenerateFallbackFontDataCommand extends Command<bool>
final Map<String, Uri> urlForFamily = <String, Uri>{};
for (final Map<String, dynamic> fontData in fontDatas) {
if (fallbackFonts.contains(fontData['family'])) {
final Uri uri = Uri.parse(fontData['files']['regular'] as String).replace(scheme: 'https');
final Uri uri = Uri.parse(fontData['files']['regular'] as String)
.replace(scheme: 'https');
urlForFamily[fontData['family'] as String] = uri;
}
}
@@ -82,7 +83,11 @@ class GenerateFallbackFontDataCommand extends Command<bool>
}
for (final String family in fallbackFonts) {
print('Downloading $family...');
final Uri uri = urlForFamily[family]!;
final Uri? uri = urlForFamily[family];
if (uri == null) {
throw ToolExit('Unable to determine URL to download $family. '
'Check if it is still hosted on Google Fonts.');
}
final http.Response fontResponse = await client.get(uri);
if (fontResponse.statusCode != 200) {
throw ToolExit('Failed to download font for $family');
@@ -160,7 +165,7 @@ class GenerateFallbackFontDataCommand extends Command<bool>
const List<String> fallbackFonts = <String>[
'Noto Sans',
'Noto Emoji',
'Noto Color Emoji',
'Noto Sans Symbols',
'Noto Sans Symbols 2',
'Noto Sans Adlam',
@@ -242,7 +247,7 @@ const List<String> fallbackFonts = <String>[
'Noto Sans Mro',
'Noto Sans Multani',
'Noto Sans Myanmar',
'Noto Sans N Ko',
'Noto Sans NKo',
'Noto Sans Nabataean',
'Noto Sans New Tai Lue',
'Noto Sans Newa',

File diff suppressed because one or more lines are too long

View File

@@ -225,7 +225,7 @@ class FontFallbackData {
registeredFallbackFonts.add(RegisteredFont(bytes, family, typeface));
// Insert emoji font before all other fallback fonts so we use the emoji
// whenever it's available.
if (family == 'Noto Emoji') {
if (family == 'Noto Color Emoji') {
if (globalFontFallbacks.first == 'Roboto') {
globalFontFallbacks.insert(1, family);
} else {

View File

@@ -35,7 +35,7 @@ void testMain() {
.singleWhere((NotoFont font) => font.name == 'Noto Sans Arabic')
.url;
final String notoEmojiUrl = fallbackFonts
.singleWhere((NotoFont font) => font.name == 'Noto Emoji')
.singleWhere((NotoFont font) => font.name == 'Noto Color Emoji')
.url;
TestDownloader.mockDownloads[notoSansArabicUrl] =
'/assets/fonts/NotoNaskhArabic-Regular.ttf';
@@ -123,7 +123,7 @@ void testMain() {
expect(FontFallbackData.instance.globalFontFallbacks, <String>[
'Roboto',
'Noto Emoji',
'Noto Color Emoji',
'Noto Sans Arabic',
]);
});
@@ -144,7 +144,7 @@ void testMain() {
await notoDownloadQueue.debugWhenIdle();
expect(FontFallbackData.instance.globalFontFallbacks,
contains('Noto Emoji'));
contains('Noto Color Emoji'));
final CkPictureRecorder recorder = CkPictureRecorder();
final CkCanvas canvas = recorder.beginRecording(kDefaultRegion);
@@ -235,7 +235,7 @@ void testMain() {
final Set<int> supportedUniqueCodeUnits = <int>{};
final IntervalTree<NotoFont> notoTree =
FontFallbackData.instance.notoTree;
for (final NotoFont font in notoTree.root.enumerateAllElements()) {
for (final NotoFont font in fallbackFonts) {
testedFonts.add(font.name);
for (final CodeunitRange range in font.computeUnicodeRanges()) {
for (int codeUnit = range.start; codeUnit < range.end; codeUnit++) {
@@ -250,7 +250,7 @@ void testMain() {
testedFonts,
unorderedEquals(<String>{
'Noto Sans',
'Noto Emoji',
'Noto Color Emoji',
'Noto Sans Symbols',
'Noto Sans Symbols 2',
'Noto Sans Adlam',
@@ -332,7 +332,7 @@ void testMain() {
'Noto Sans Mro',
'Noto Sans Multani',
'Noto Sans Myanmar',
'Noto Sans N Ko',
'Noto Sans NKo',
'Noto Sans Nabataean',
'Noto Sans New Tai Lue',
'Noto Sans Newa',
@@ -397,9 +397,10 @@ void testMain() {
final List<int> supportedCodeUnits = supportedUniqueCodeUnits.toList()
..shuffle(random);
const int paragraphLength = 3;
const int totalTestSize = 1000;
for (int batchStart = 0;
batchStart < supportedCodeUnits.length;
batchStart < totalTestSize;
batchStart += paragraphLength) {
final int batchEnd =
math.min(batchStart + paragraphLength, supportedCodeUnits.length);
@@ -428,7 +429,7 @@ void testMain() {
rethrow;
}
}
}, timeout: const Timeout.factor(50)); // This test is very slow.
});
}, skip: isSafari);
}