Skip to content
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

Add the textScaleFactor parameter #6

Closed
timbotimbo opened this issue Apr 22, 2021 · 5 comments
Closed

Add the textScaleFactor parameter #6

timbotimbo opened this issue Apr 22, 2021 · 5 comments

Comments

@timbotimbo
Copy link

A Text widget scales the font based on the textScaleFactor * fontSize.
If you never set this scale, it uses the value from the context, which is usually determined by the accessibility settings in android.

RichText doesn't seem to do use the context textScaleFactor by default, which makes simple_rich_text ignore it too.
So on some phones the rich text is a different size from any other text widgets.

Using a mediaquery RichText follows the behavior of normal Text widgets.

RichText(
    text: ,
    textScaleFactor: MediaQuery.of(context).textScaleFactor,
);

Can you add this parameter to the simple_rich_text constructor, and pass that to RichText?

Here is how you can manually set the global textScaleFactor in main to do some testing.

return new MaterialApp(
      //set global text scale factor in builder
      builder: (BuildContext context, Widget child) {
        final MediaQueryData data = MediaQuery.of(context);
        return MediaQuery(
          data: data.copyWith(textScaleFactor: 1),
          child: child,
        );
      },
@remoteportal
Copy link
Owner

Thank you for the thorough explanation!

@remoteportal
Copy link
Owner

Version 2.0.45 (2021-04-22)

@timbotimbo
Copy link
Author

timbotimbo commented Apr 22, 2021

Thanks for fixing it so quickly.

The current fix is fine for my use case, so you don't need to change anything. But for more flexibility in the future you might want the textScaleFactor to be customizable like the overflow and maxLines.

Something like
textScaleFactor: this.textScaleFactor ?? MediaQuery.of(context).textScaleFactor

@remoteportal
Copy link
Owner

Thank you for your feedback!

@remoteportal
Copy link
Owner

I added it for completeness.

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

2 participants