Failed to load font packages/widgetbook/Nunito
Last active 16 days ago
15 replies
3 views
- LE
Description
Using the example code to create an app I get missing font errors in the console.
(it works but I think the fonts are not the ones intended)
Steps To ReproduceUse example sample code from pub.dev
Use flutter pub add widgetbook to add the dependency
Run as web app using flutter run
Works but prints lots of font warnings…
Failed to load font packages/widgetbook/Nunito at assets/packages/widgetbook/googlefonts/Nunito-Black.ttf Verify that assets/packages/widgetbook/googlefonts/Nunito-Black.ttf contains a valid font.
…
Expected Behavior
Use intended fonts and not print warnings
Additional Context
I tried adding the google fonts dependency to the app, but still had the issue. - HE
Same behavior here
- JE
Thanks @LeeHigginsExeter and @heavybeard for reporting this issue. While the warnings are certainly annoying, does this make Widgetbook unusable for you?
I'm assuming Flutter will default to another font in such a case. - HE
I will work on a fix in a few minutes, I have an idea because I faced the same problem with an app a few months ago.
Anyway Widgetbook is usable for me. - JE
Ok, it's great that it's still usable. I assume the problem is that the fonts are defined in the package and are not properly 'exported' by the package which results in the missing fonts package.
It would be great if you could fix this - we always love to see contributions 👍🏻 - HE
@jenshor it's a pleasure to dedicate time to your project. The #211 PR is ready to review.
- MO
Please have a look at the PR @jenshor , Widgetbook still works, but as you say, this warning is very annoying… :)
- JE
@heavybeard @momrak We're currently busy doing other awesome stuff, but we'll merge the PR within the next week. We highly appreciate you, the community, in making Widgetbook better 💙 Sorry for the wait.
- MO
@heavybeard did this fix work for you? I still get the same Failed to load font… messages. Anything I have to in order to get them away after bumping the widgetbook version?
- HE
Oh wow, yeah… I still have the same message in the console.
It is really strange because I use the same font directory structure in my monorepo application, and it works.
I cannot work on it in next days, can you try to fix it @momrak?
I investigate a little bit and maybe here it is a fix from flutter, but it seems a verbose fix → https://docs.flutter.dev/cookbook/design/package-fonts#1-add-a-font-to-a-packageTo export a font from a package, you need to import the font files into the lib folder of the package project. You can place font files directly in the lib folder or in a subdirectory, such as lib/fonts.
lib/
widgetbook.dart
fonts/
Nunito-Regular.ttf
Nunito-Italic.ttfAnd the application can now use the font with
flutter:
fonts:
- family: Nunito
fonts:
- asset: packages/widgetbook/fonts/Raleway-Regular.ttf
- asset: packages/widgetbook/fonts/Raleway-Italic.ttf
style: italic - HE
Using google_fonts package could be another idea?
- JE
I'll reopen so we can investigate again. Before deployment I checked if this works and it did but there seems to be a more difficult scenario.
While google_fonts is great, I'd refrain from adding it as a dependency because it every package dependency can make it more difficult to use widgetbook. - VO
Having the same problem
- EV
I have the same issue. And this ticket is marked as included in 2.4.1 release, but it's not!
- LU
The discord users
robotkins
andciochetta
also still have the issue. As soon as it's resolved, we'll ping them.
Last active 16 days ago
15 replies
3 views