flutter_glove_box icon indicating copy to clipboard operation
flutter_glove_box copied to clipboard

Documentation for font weights is not valid

Open fatherOfLegends opened this issue 3 years ago • 3 comments

Caveats Unfortunately, Flutter's font loading support for testing is fairly limited. At the moment, it is only possible to load a single .ttf file for a font family. This means it may not be possible to get the proper visuals to appear. For example, different font weights may not work

Different font weights do work with this package as long as the font weights are properly configured. Flutter requires different font files to be assigned to different weights. As long as each font file has a unique name the fonts display properly.

flutter:
  fonts:
    - family: LibreBaskerville
      fonts:
        - asset: fonts/LibreBaskerville-Regular.ttf
          weight: 400
    - family: Montserrat
      fonts:
        - asset: fonts/Montserrat-Light.ttf
          weight: 300
        - asset: fonts/Montserrat-Regular.ttf
          weight: 400
        - asset: fonts/Montserrat-Medium.ttf
          weight: 500
        - asset: fonts/Montserrat-SemiBold.ttf
          weight: 600
        - asset: fonts/Montserrat-Bold.ttf
          weight: 700

Here is an example of a golden with these fonts and weights:

image

fatherOfLegends avatar Dec 23 '21 21:12 fatherOfLegends

Hello @fatherOfLegends. I can't get it to work on my own even with the config you gave.

Which version of flutter are you using? And flutter_test, test?

Are you sure it isn't flutter trying to bolden one font without having really loaded it?

Thanks for your help!

HugoHeneault avatar Jan 05 '22 07:01 HugoHeneault

I finally got it working. I wasn't defining my fonts correctly in theme!

I can confirm that the caveat seems to be gone. It could be removed from Readme. I can do a PR if that's fine for maintainers :)

HugoHeneault avatar Jan 05 '22 08:01 HugoHeneault

I can confirm that this works well

fzyzcjy avatar May 16 '23 01:05 fzyzcjy