You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cursor too high/short for non-alphabetic scripts such as Chinese, emojis, and others. #24182
The cursor for text fields is the wrong size/height for the text when typing non-alphabetic/english-like scripts.
This has been confirmed to affect Chinese (and other chinese-like scripts), emojis, Arabic (and arabic-like scripts), but probably impacts more.
Example with Chinese:
It is interesting to note that highlighting the text works properly and covers the full vertical extent of the text. The cursor positions seems to be calculated from the same properties, but is coming up with a different result.
GetBoxesForRange() also seems to be outputting expected values.
in text_painter.dart get preferredLineHeight, we are laying out a ' ' (space) and using the line height. There is probably a better, more consistent way of doing this...
I was able to improve the behavior by changing the space character to a ▓ character, which takes up more vertical space.
Spaces in some languages and fonts are significantly shorter than the character itself. One solution is to use the current method before layout, and switch to true values after.
A problem with this is that may be varied heights within one paragraph (example, english and chinese) which require different cursor heights.
It seems that more than just the cursor depends on the preferredLineHeight value, which does not always reflect the actual line height, which can cause other issues as well. This may be the root cause of the text clipping bugs reported at #20183 since relating the preferredLineHeights to the character index causes the entire box to expand/shrink depending on the height of the character selected.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
GaryQian commentedon Nov 10, 2018
in text_painter.dart get preferredLineHeight, we are laying out a ' ' (space) and using the line height. There is probably a better, more consistent way of doing this...
I was able to improve the behavior by changing the space character to a ▓ character, which takes up more vertical space.
Spaces in some languages and fonts are significantly shorter than the character itself. One solution is to use the current method before layout, and switch to true values after.
A problem with this is that may be varied heights within one paragraph (example, english and chinese) which require different cursor heights.
GaryQian commentedon Nov 12, 2018
It seems that more than just the cursor depends on the preferredLineHeight value, which does not always reflect the actual line height, which can cause other issues as well. This may be the root cause of the text clipping bugs reported at #20183 since relating the preferredLineHeights to the character index causes the entire box to expand/shrink depending on the height of the character selected.
xster commentedon Nov 12, 2018
I suspect our current text painter's preferredLineHeight doesn't take into account the actual height TextStyle property of the TextSpan either.
We should use your new get box for range API for the cursor too.
CaiJingLong commentedon Nov 14, 2018
In the 0.11.4 version, the height of the cursor seems to be acceptable, but the position is still not aligned.

Many lines of text also have problems, which may be caused by the same reasons. Part of the last line will be covered.
code is
And as maxlines becomes larger, the problem will be more obvious.
And there will be no such problem in English.

flutter --version
zoechi commentedon Nov 14, 2018
Dup of #23934
longwayto commentedon Apr 2, 2019
TextField ( style: TextStyle(height: 1.2) )height :1.2 solve the problem
GaryQian commentedon Jul 18, 2019
I will close this now, as we have landed fixes that
github-actions commentedon Aug 29, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.