Skip to content

Default text scale #344

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
Aoi-hosizora opened this issue Jun 30, 2020 · 1 comment
Closed

Default text scale #344

Aoi-hosizora opened this issue Jun 30, 2020 · 1 comment

Comments

@Aoi-hosizora
Copy link

Aoi-hosizora commented Jun 30, 2020

Android 8 / 10
flutter_html: ^1.0.0-pre.1
Flutter: 1.19.0-2.0.pre.83

I use Html widget to display some html text. But I set my phone's text scale small, so text scaling is strange.

Later, I found a solution related to #308. Although the text is still small, but it is better if I use Html directly. I really want to solve this problem. Here is my code:

final fontSize = Theme.of(context).textTheme.bodyText2.fontSize / MediaQuery.of(context).textScaleFactor; // divide by scale factor
// ...
Html(
  data: item,
  style: {
    '*': Style(fontSize: FontSize(fontSize)),
  },
),
// ...

Small scale factor: (0.85)

Before: image (too small)
After: image (small yet)

Normal scale factor: (1.0)

Before: image
After: image

Large scale factor: (1.15)

Before: image (too large)
After: image

Control panel:

image

Addition:

If I divide by scale * scale, it seems to be right? (0.85, text with shadow is Text and below is Html)

image

final scale = MediaQuery.of(context).textScaleFactor ?? 1.0;
final fontSize = Theme.of(context).textTheme.bodyText2.fontSize / (scale * scale);
@Aoi-hosizora
Copy link
Author

I see this bug has been fixed in 1.0.2 so I close this issue :)

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

1 participant