Skip to content

Commit

Permalink
[web] Switch all fonts to WOFF2 (non-split) (#56035)
Browse files Browse the repository at this point in the history
Google Fonts serves TTF fonts gzipped. By switching to WOFF2 fonts, we get Brotli compression by design.

Google Font's WOFF2 fonts are 30%+ smaller than their gzipped TTF counterparts (including Roboto).
  • Loading branch information
mdebbar authored Nov 5, 2024
1 parent dfa70d7 commit e553cd6
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 147 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ deps = {
'packages': [
{
'package': 'flutter/flutter_font_fallbacks',
'version': '0570a0ea824083da79de07b131fc5df7f55dad4d6cba2ee704912ce7e4ce812a'
'version': '10da6a95fedad127634500aa854466fe9e3fa760220a2a1c7c20df84073fce76'
}
],
'dep_type': 'cipd',
Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/dev/roll_fallback_fonts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ OTHER DEALINGS IN THE FONT SOFTWARE.
}
final List<_FontInfo> processedFonts = <_FontInfo>[];
final http.Response response = await client.get(Uri.parse(
'https://www.googleapis.com/webfonts/v1/webfonts?key=$apiKey'));
'https://www.googleapis.com/webfonts/v1/webfonts?capability=WOFF2&key=$apiKey'));
if (response.statusCode != 200) {
throw ToolExit('Failed to download Google Fonts list.');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/lib/src/engine/canvaskit/fonts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'package:ui/ui_web/src/ui_web.dart' as ui_web;
// Roboto font. The API reference is here:
// https://developers.google.com/fonts/docs/developer_api
String _robotoUrl =
'${configuration.fontFallbackBaseUrl}roboto/v20/KFOmCnqEu92Fr1Me5WZLCzYlKw.ttf';
'${configuration.fontFallbackBaseUrl}roboto/v32/KFOmCnqEu92Fr1Me4GZLCzYlKw.woff2';

/// Manages the fonts used in the Skia-based backend.
class SkiaFontCollection implements FlutterFontCollection {
Expand Down
Loading

0 comments on commit e553cd6

Please sign in to comment.