flutter_html icon indicating copy to clipboard operation
flutter_html copied to clipboard

[FEATURE] add support for specifying font package

Open AristideVB opened this issue 3 years ago • 5 comments

Describe your feature request

Currently if our fonts are located inside a local package they cannot be retrieved inside flutter_html Style() like they can in a regular Flutter TextStyle() :

TextStyle(
    package: 'ui_package', 
    fontFamily: 'Circular Air Pro',
    color: Colors.green,
  );

It would look something like this :

Html(
        data: mockData,
        style: {
          'body': Style(
            package: 'ui_package',            // specify font package here 
            fontFamily: 'Circular Air Pro',
            margin: EdgeInsets.zero,
            padding: EdgeInsets.zero,
          ),
        },
      ),

Additional request

It would also be nice to be able to use TextStyle( ) rather than Style( )

A picture of a cute animal (not mandatory but encouraged) 🐹

AristideVB avatar Jul 25 '22 11:07 AristideVB

This would be helpful for GoogleFonts as well. At the moment, we can't really set the style (e.g. fontWeight) for a Google font inside the Html widget, can we? Additionally, if I set a Google font as standard font in the TextTheme of the app, some letters look really strange (see screenshot). This is just on Android! On iOS everything looks good. Is there a way to fix this?

screenshot

hschk avatar Oct 04 '22 09:10 hschk

Thanks for the feedback @AristideVB! I agree, font package support definitely seems like a valid use case. I'll look into what it will take to get that added. As for using TextStyle instead of Style, have you looked into the Style.fromTextStyle constructor?

@hschk That is certainly strange. I've used Google Fonts myself and haven't seen the issue. Do you have a reproducible example?

Sub6Resources avatar Oct 20 '22 18:10 Sub6Resources

I'm also looking for global customization of font family from GoogleFonts for Html widget. Would love to use it.

pumano avatar Oct 18 '23 16:10 pumano

I'm also looking for global customization of font family from GoogleFonts for Html widget. Would love to use it.

It's possible to use Google Fonts like this image

triay0 avatar Feb 21 '24 14:02 triay0