rydmike / flex_color_scheme

A Flutter package to make and use beautiful color scheme based themes.
Other
947 stars 105 forks source link

Google Fonts nit #227

Open dickermoshe opened 5 months ago

dickermoshe commented 5 months ago

As we know the Google Fonts package doent work well https://github.com/material-foundation/flutter-packages/issues/35

Could this either link to the workaround or be removed

// To use the Playground font, add GoogleFonts package and uncomment
// fontFamily: GoogleFonts.notoSans().fontFamily,
famasf1 commented 5 months ago

I think you could've made the issue a little clearer by describe the actual problem (like a background and suggesting the alternative.) instead of just throwing a link here and said 'it doesn't work well'.

GoogleFonts got recommended here simply because it is very easy to get things up and running. And giving out a nice example to work with quickly. if you have an alternative solution, You should purpose one up so the author can considering your request.

dickermoshe commented 5 months ago

Sorry, I assumed Mike knows exactly what's going on here, this has been a pretty well known issue with Google Fonts on X, so I assumed everyone knew.

Background The 1st Party GoogleFonts package doesn't include bold fonts, this is very common issue that many developers have spent hours pulling their hair out over. In the Copy-Paste dialog on the Flex Color Scheme website the following text is included

// To use the Playground font, add GoogleFonts package and uncomment
// fontFamily: GoogleFonts.notoSans().fontFamily,

However, I propose that we shouldn't ignore the fact that this isn't as simple as it looks, or remove it

rydmike commented 5 months ago

Hi, @dickermoshe and @famasf1 thanks for taking an interest in the wondrous world of GoogleFonts and TextTheme 😄

I'm well aware of the challenges many face with setting up fonts using TextTheme and GoogleFonts. You can see one example on how I propose to do it in discussions here: https://github.com/rydmike/flex_color_scheme/discussions/160

Where I show how to do it, to set it up so that you do get the correct weights as defined to actually be used and shown up in your TextTheme and app when using GoogleFonts.

Another interesting discussion about this can be found in this X/Twitter post and its many branches:

https://x.com/luke_pighetti/status/1759721848353288601

Where I give a few similar examples on what to do to make different weights work correctly.

Some links to that: https://x.com/RydMike/status/1759746648832380954 https://x.com/RydMike/status/1759794570273882604

worth nothing is also, if you font does not contain the weights, you always only get poor approximations for those weights. All fixed fonts do not contain all weights.

You can find some interesting discussions in the thread here:

https://x.com/luke_pighetti/status/1759912133339259283

and here:

https://x.com/RydMike/status/1759920719121547306

While this is not something that is really a FlexColorScheme issue, or even a Flutter ThemeData issue, it is more like an issue of how to get GoogleFonts to load fonts from assets or the internet, but regardless of this, it is still something that I could very well add guidance and info for in the docs for FlexColorScheme.

After I have released version 8.0.0 I will be doing som overhaul of the docs. I will then add info about this this as well. I can then also include a URL link to the info in the copy/paste code about GoogleFonts usage.

Until then, I'm going to keep this issue open as reminder to improve the docs about this topic.


This is by the way also a little annoying bug in GoogleFonts and using its text theme feature: https://github.com/material-foundation/flutter-packages/issues/401

And this one is about wrong color of primaryTextTheme in ThemeData https://github.com/flutter/flutter/issues/118146

FlexColorScheme fixes and works around both those two issue. The primaryTextTheme wrong contrast color will probably never be fixed in Flutter, since the primaryTextTheme will probably be deprecated eventually.