Skip to content

In the 1.0 version, the line height and font spacing(letterSpacing) I defined have no effect at all. Why is this? #212

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

Closed
sliverRing opened this issue Jan 13, 2020 · 5 comments

Comments

@sliverRing
Copy link

In the 1.1 version, the line height and font spacing(letterSpacing) I defined have no effect at all. Why is this?
`import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_html/style.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:literature/common/common.dart';

class HtmlText extends StatelessWidget {
final String content;
final double fontSize;
final fontH = ScreenUtil().setWidth(3.5);

HtmlText({this.content, this.fontSize = 0.0});

@OverRide
Widget build(BuildContext context) {
double fontSuzie = ScreenUtil().setSp(SLiverCommon.readContent);
if (fontSize != 0.0) {
fontSuzie = ScreenUtil().setSp(fontSize);
}
return Html(
data: content,
shrinkWrap: false,
style: {
"div": buildStyleDive(),
"html": buildStyleHtml(fontSuzie, context),
"em": buildStyleEm(),
"body": buildStyleBody(),
"p": buildStyleP(),
"p":Style.fromTextStyle(
TextStyle(wordSpacing: 0.0)
),
"strong": buildStyleStrong(),
"blockquote": buildStyleBlockquote(),
},
);
}

Style buildStyleDive() =>
Style(display: Display.BLOCK, margin: EdgeInsets.only(bottom: 10.0));

Style buildStyleStrong() {
return Style(
color: Colors.black,
alignment: Alignment.center,
display: Display.BLOCK);
}

Style buildStyleP() {
return Style(
whiteSpace: WhiteSpace.PRE,
margin: EdgeInsets.only(top: 5.0),
color: Color(0xFF535353),
width: double.infinity);
}

// DT
Style buildStyleEm() {
return Style(
color: Color(0xFF535353),
display: Display.INLINE_BLOCK,
height: fontH,
margin: EdgeInsets.only(top: 5.0),
fontStyle: FontStyle.normal);
}
Style buildStyleBlockquote() {
return Style(
fontFamily: 'Zkwyt',
margin: EdgeInsets.only(top: 10.0, bottom: 10.0),
border: Border(left: BorderSide(width: 2.0, color: Colors.grey[800])),
backgroundColor: Colors.grey[200],
padding: EdgeInsets.only(
left: ScreenUtil().setWidth(15.0),
right: ScreenUtil().setWidth(15.0),
top: 5.0,
bottom: 5.0,
),
);
}

Style buildStyleBody() {
return Style(
width: double.infinity,
color: Color(0xFF535353),
padding: EdgeInsets.only(left: 0.0, top: 0.0),
margin: EdgeInsets.only(left: 0.0, top: 0.0));
}

Style buildStyleHtml(double fontSuzie, context) {
return Style.fromTextStyle(TextStyle(
fontSize: fontSuzie,
inherit: false,
height: fontH,
fontFamily: 'FZSSJW',
wordSpacing: 0.0,
color: Color(0xFF535353),
letterSpacing: 2.5));
}
}
`

@sliverRing sliverRing changed the title In the 1.1 version, the line height and font spacing(letterSpacing) I defined have no effect at all. Why is this? In the 1.0 version, the line height and font spacing(letterSpacing) I defined have no effect at all. Why is this? Jan 13, 2020
@sliverRing
Copy link
Author

Can anyone help me, in the state of Chinese, it is difficult to see without spacing and line height.
This problem has troubled me for a day.

@Sub6Resources
Copy link
Owner

Currently spacing and line height aren't supported by the Style tag, so they are ignored. When the final version of 1.0.0 is released, they will be supported. We apologize for the inconvenience in the meantime.

@FullstackJack
Copy link

FullstackJack commented May 11, 2020

@Sub6Resources I needed letterspacing and other missing attributes as well. Why even have an intermediary Style class? Why not pass through TextStyle for text widgets and BoxDecoration for container views? I think you should change this interface to match the rest of the Flutter styling ecosystem as it will simplify usage. If you still want a Style class for handling CSS stylesheet code, that's fine.

@FullstackJack
Copy link

Okay, I see that you've added letterSpacing and wordSpacing to new-parser branch. Would you mind releasing a new version?

@erickok
Copy link
Contributor

erickok commented Feb 8, 2021

Duplicate of #210

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants