flutter_html
flutter_html copied to clipboard
[QUESTION] How do I set font family with Google Fonts?
I want to set font family for my HTML widget using Google Fonts. Here's what I've tried:
TagWrapExtension(
tagsToWrap: {'body'},
builder: (child) {
return DefaultTextStyle(
style:
GoogleFonts.robotoFlex(letterSpacing: 0),
child: child,
);
}),
That approach caused my HTML to display without any wrapping (the whole horizontal width of the content is displayed), like so:
While the desired result is something like this:
Is there another approach I can use to use Google Fonts with the HTML widget? Any ideas would be very appreciated.
Any updates? or any work around to support custom fonts?
final fredokaFamily = GoogleFonts.fredoka().fontFamily;
Then
Html(
data: content,
style: {
"body": Style(
fontFamily: fredokaFamily,
margin: Margins.zero,
padding: HtmlPaddings.zero,
color: appColorText,
fontSize: FontSize(fs14()),
lineHeight: const LineHeight(1.6),
),
...)