Skip to content

fix the widget span layout when text scale factor != 1 - #59711

Merged
fluttergithubbot merged 2 commits into
flutter:masterfrom
chunhtai:issues/59316
Jun 18, 2020
Merged

fluttergithubbot merged 2 commits into
flutter:masterfrom
chunhtai:issues/59316

Conversation

@chunhtai

Copy link
Copy Markdown
Contributor

Description

The widget span is laid out with original size but enlarged after paint. This cause the content to flow out of the box.

Related Issues

Fixes #59316

Tests

I added the following tests:

Replace this with a list of the tests that you added as part of this PR. A change in behaviour with no test covering it
will likely get reverted accidentally sooner or later. PRs must include tests for all changed/updated/fixed behaviors. See Test Coverage.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

@fluttergithubbot fluttergithubbot added the framework flutter/packages/flutter repository. See also f: labels. label Jun 17, 2020
@chunhtai
chunhtai requested review from GaryQian and justinmc June 17, 2020 21:20
// The content will be enlarged by textScaleFactor during painting phase.
// We reduce contraint by textScaleFactor so that the content will fit
// into the box once it is enlarged.
BoxConstraints(maxWidth: constraints.maxWidth) / textScaleFactor,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GaryQian I wonder why do we need _textPainter.inlinePlaceholderScales? aren't they always the same as textScaleFactor?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that in actual use cases, it is indeed true, but it is also possible (at lower levels) to independently set them. This may or may not be necessary at this level, I can look into it to see if it is safe to remove.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scales are added into the list through WidgetSpan.build() which gets its value from the textScaleFactor. I couldn't find a possible way to have a different textscalefactor.

@justinmc justinmc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked out this branch and ran the code in the issue and it didn't seem to fix the problem for me. I still saw different sizes when I increased the font size in the phone settings. Let me know if I messed something up and you don't see the same thing.

Screen Shot 2020-06-17 at 2 33 23 PM

@chunhtai

Copy link
Copy Markdown
Contributor Author

I checked out this branch and ran the code in the issue and it didn't seem to fix the problem for me. I still saw different sizes when I increased the font size in the phone settings. Let me know if I messed something up and you don't see the same thing.

Screen Shot 2020-06-17 at 2 33 23 PM

I think the size scaling is correct (wrapping a RichText inside a RichText will make scaling^2), and the main issue this pr tries to solve is Text wrapping for the inner RichText.
See the text was cut of before the change
image

@justinmc justinmc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see, thanks for the clarification. I do see the overflowing without this PR and it goes away on your branch. LGTM 👍

@GaryQian GaryQian left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks!

@thenexus00

Copy link
Copy Markdown

Wanted to confirm on a real world app that with what effectively is the flutter_html where the html_parser sees the scale factor implemented that. it does not wrap:
https://www.dropbox.com/s/kr72vlx4ij9tiqn/image007.png?dl=0

When will we see the layout flow fix in the master branch?

@chunhtai

chunhtai commented Jul 7, 2020

Copy link
Copy Markdown
Contributor Author

This may take a while, we are seeing a large number of test failure in our internal tests. we are in the middle of sorting this out.

@thenexus00

Copy link
Copy Markdown

This may take a while, we are seeing a large number of test failure in our internal tests. we are in the middle of sorting this out.

How is it going on the the tests on this one? If there is a build in master happy to do any tests and report back if you need.

mingwandroid pushed a commit to mingwandroid/flutter that referenced this pull request Sep 6, 2020
mingwandroid pushed a commit to mingwandroid/flutter that referenced this pull request Sep 6, 2020
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jul 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nested RichText objects apply textScaleFactor multiple times

6 participants