Skip to content

Conversation

@GaryQian
Copy link
Contributor

@GaryQian GaryQian commented Nov 27, 2018

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.

@GaryQian GaryQian added a: text input Entering text in a text field or keyboard related problems a: typography Text rendering, possibly libtxt work in progress; do not review labels Nov 27, 2018
@zoechi zoechi added the framework flutter/packages/flutter repository. See also f: labels. label Nov 28, 2018
@GaryQian GaryQian requested review from HansMuller and Hixie December 10, 2018 19:14
@GaryQian
Copy link
Contributor Author

GaryQian commented Dec 10, 2018

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.

Copy link
Member

@xster xster left a 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.

@GaryQian GaryQian merged commit f8964ae into flutter:master Dec 18, 2018
@GaryQian
Copy link
Contributor Author

Filed an issue to benchmark the text field. #25523

@GaryQian
Copy link
Contributor Author

Reverting for now as it causes an unforeseen and untested iOS issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

a: text input Entering text in a text field or keyboard related problems a: typography Text rendering, possibly libtxt framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cursor always at the front when typing emojis pls help, Can't remove khmer unicode from textform field

5 participants