Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to load font packages/widgetbook/Nunito #206

Closed
LeeHigginsExeter opened this issue May 31, 2022 · 15 comments
Closed

Failed to load font packages/widgetbook/Nunito #206

LeeHigginsExeter opened this issue May 31, 2022 · 15 comments
Labels
t: bug Something isn't working

Comments

@LeeHigginsExeter
Copy link

LeeHigginsExeter commented May 31, 2022

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 Reproduce

  1. Use example sample code from pub.dev
  2. Use flutter pub add widgetbook to add the dependency
  3. Run as web app using flutter run
  4. Works but prints lots of font warnings

...
Failed to load font packages/widgetbook/Nunito at assets/packages/widgetbook/google_fonts/Nunito-Black.ttf
Verify that assets/packages/widgetbook/google_fonts/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.

@heavybeard
Copy link
Contributor

Same behavior here

@jenshor
Copy link
Member

jenshor commented Jun 3, 2022

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.

@jenshor jenshor added the t: bug Something isn't working label Jun 3, 2022
@heavybeard
Copy link
Contributor

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.

@jenshor
Copy link
Member

jenshor commented Jun 3, 2022

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 👍🏻

@heavybeard
Copy link
Contributor

@jenshor it's a pleasure to dedicate time to your project. The #211 PR is ready to review.

@momrak
Copy link

momrak commented Jun 10, 2022

Please have a look at the PR @jenshor , Widgetbook still works, but as you say, this warning is very annoying... :)

@jenshor
Copy link
Member

jenshor commented Jun 10, 2022

@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.

@jenshor jenshor closed this as completed Jun 13, 2022
@momrak
Copy link

momrak commented Jul 4, 2022

@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?

@heavybeard
Copy link
Contributor

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-package

To 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.ttf

And 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

@heavybeard
Copy link
Contributor

Using google_fonts package could be another idea?

@jenshor
Copy link
Member

jenshor commented Jul 4, 2022

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.

@jenshor jenshor reopened this Jul 4, 2022
@vovaklh
Copy link

vovaklh commented Oct 8, 2022

Having the same problem
image

@evekeen
Copy link

evekeen commented Nov 24, 2022

I have the same issue. And this ticket is marked as included in 2.4.1 release, but it's not!

@LucasJosefiak
Copy link
Member

The discord users robotkins and ciochetta also still have the issue. As soon as it's resolved, we'll ping them.

@YoussefRaafatNasry
Copy link
Member

This font was removed in #744

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants