Repository navigation
Support for VariableFont_wght #174567
Description
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
Activity
guidezpl commentedon May 26, 2022
Yeah that's expected since we don't support variable fonts yet. If you only need the regular font weight, I recommend using the static font in
static/PlusJakartaSans-Regular.ttf. It's smaller (95KB) than the variable font (174KB).M123-dev commentedon May 26, 2022
Thanks for the quick response @guidezpl
If anyone else is looking for the basic font, here the link: https://github.com/tokotype/PlusJakartaSans/blob/master/fonts/ttf/PlusJakartaSans-Regular.ttf
guidezpl commentedon May 26, 2022
Tip: If you download the font family from Google Fonts, it's also included in the .zip file
M123-dev commentedon May 26, 2022
I don't have it when downloading from here https://fonts.google.com/specimen/Plus+Jakarta+Sans?query=Plus+#standard-styles
guidezpl commentedon May 26, 2022
It should be there

M123-dev commentedon May 26, 2022
Oh in the hurry I somehow missed the static folder, sorry for that and thanks @guidezpl
[google_fonts] Update the font generator to exclude variable font ent…
[google_fonts] Update the font generator to exclude variable font ent…
[google_fonts] Update the font generator to exclude variable font ent…