-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Iterate through potential grapheme cluster lengths in text painter #24797
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
Conversation
|
The whitespace hadnling responsibility has been shifted to LibTxt in flutter/engine#7164. This PR can focus on just the emoji/grapheme clusters only. Will require an engine roll once it lands for the tests in here to pass. |
xster
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Doesn't have to be in this PR but it would be great to add a benchmark test for text operations so we have a baseline and changes are quantifiable.
|
Filed an issue to benchmark the text field. #25523 |
…inter (flutter#24797)" This reverts commit f8964ae.
|
Reverting for now as it causes an unforeseen and untested iOS issue |
Since we cannot yet access the extended grapheme clusters in a dart string, we cannot know how much to offset the index such that we can draw a minimal rectangle around the nearest character.
This uses a loop to double the size of the index offset when it cannot find a glyph within the range when the glyph is defined by an extended grapheme cluster.
We also perform the same search when the current code unit is whitespace. LibTxt may truncate the layout early on trailing whitespace in order to properly align text (particularly centered text), so we need to obtain the last drawn character in order to find a bounding box.
Fixes #24266, #24456
Partially fixes #24203, #22627, #24802
Overall, this fixes the inability to move the caret into emoji/zwj strings on the first line. On the second+ lines, the caret still has a different bug where you are able to move it within a single glyph and edit the individual components of a zwj glyph.