Skip to content

Support for VariableFont_wght #174567

@M123-dev

Description

@M123-dev

Steps to Reproduce

I am about to use a bundled version of a font, the documentation says:

Note: Since these files are listed as assets, there is no need to list them in the fonts section of the pubspec.yaml. This can be done because the files are consistently named from the Google Fonts API (so be sure not to rename them!)

I did the same for Plus Jakarta Sans with allowRuntimeFetching = false but this lead to the error:

I/flutter ( 9128): Error: google_fonts was unable to load font PlusJakartaSans-Regular because the following exception occurred:
I/flutter ( 9128): Exception: GoogleFonts.config.allowRuntimeFetching is false but font PlusJakartaSans-Regular was not found in the application assets. Ensure PlusJakartaSans-Regular.ttf exists in a folder that is included in your pubspec's assets.

Which makes sense as I don't have PlusJakartaSans-Regular.ttf in the assets but PlusJakartaSans-VariableFont_wght.ttf which is the one you get when downloading from Google Fonts.

Expected results:
The variable font should be used.

Actual results:
It does not get used

Additional context
A workaround for just downloading the regular variant is also not possible, since when you just select the regular style on fonts.google.com also only the variable font is downloaded

https://fonts.google.com/share?selection.family=Plus%20Jakarta%20Sans

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listframeworkflutter/packages/flutter repository. See also f: labels.p: google_fontsPackage to use fonts from fonts.google.com. Supports HTTP fetching, caching, and asset bundling.packageflutter/packages repository. See also p: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions