Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Generate font fallback data to be const. #38259

Merged
merged 2 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions lib/web_ui/dev/generate_fallback_font_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,28 @@ class GenerateFallbackFontDataCommand extends Command<bool>
sb.writeln('// dev/generate_fallback_font_data.dart');
sb.writeln("import 'noto_font.dart';");
sb.writeln();
sb.writeln('final List<NotoFont> fallbackFonts = <NotoFont>[');
sb.writeln('const List<NotoFont> fallbackFonts = <NotoFont>[');
for (final String family in fallbackFonts) {
sb.write(" NotoFont.fromFlatRanges('$family', '${urlForFamily[family]!}', "
'<int>[');
sb.write(" NotoFont('$family', '${urlForFamily[family]!}', ");
final List<String> starts = <String>[];
final List<String> ends = <String>[];
for (final String range in charsetForFamily[family]!.split(' ')) {
String? start;
String? end;
final List<String> parts = range.split('-');
if (parts.length == 1) {
start = parts[0];
end = parts[0];
starts.add(parts[0]);
ends.add(parts[0]);
} else {
start = parts[0];
end = parts[1];
starts.add(parts[0]);
ends.add(parts[1]);
}
sb.write('0x$start,0x$end,');
}
sb.write('<int>[');
for (final String start in starts) {
sb.write('0x$start,');
}
sb.write('], <int>[');
for (final String end in ends) {
sb.write('0x$end,');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eyebrowsoffire:const_fallback_data

}
sb.writeln(']),');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

131 137 sb.escribir ( ' ] ) , ' ) ;eyebrowsoffire:const_fallback_data

}
Expand Down
Loading