-
Notifications
You must be signed in to change notification settings - Fork 30.6k
[google_fonts] Support fetching WOFF2 font files via HTTP on web platforms #180998
Copy link
Copy link
Open
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.p: google_fontsPackage to use fonts from fonts.google.com. Supports HTTP fetching, caching, and asset bundling.Package to use fonts from fonts.google.com. Supports HTTP fetching, caching, and asset bundling.packageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-webWeb applications specificallyWeb applications specificallyteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
Metadata
Metadata
Assignees
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.p: google_fontsPackage to use fonts from fonts.google.com. Supports HTTP fetching, caching, and asset bundling.Package to use fonts from fonts.google.com. Supports HTTP fetching, caching, and asset bundling.packageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-webWeb applications specificallyWeb applications specificallyteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Type
Fields
Give feedbackNo fields configured for issues without a type.
Use case
When fonts are not bundled with the app, the google_fonts package fetches font files from the Google Fonts API. Currently, the URL is hard-coded to request .ttf files:
https://github.com/flutter/packages/blob/2e46240651cbd14d2b726d2fd46c8dcc13987fa2/packages/google_fonts/lib/src/google_fonts_descriptor.dart#L36-L51
This means web applications that rely on HTTP fetching (rather than bundling fonts) cannot benefit from the smaller file sizes and better compression that WOFF2 provides. WOFF2 files are typically 30-50% smaller than TTF files, which would improve load times for web applications.
Related PR: flutter/packages#10703 (adds for support for locally bundled fonts).
Proposal
Extend the HTTP font fetching logic to request WOFF2 files when running on web platforms:
This would complement the upcoming WOFF2 support for bundled fonts, providing a complete solution for web platforms.