[engine] WebUI engine's TextLayoutService doesn't handle TextAlign.justify correctly for Chinese text #148486
Labels
a: internationalization
Supporting other languages or locales. (aka i18n)
a: typography
Text rendering, possibly libtxt
engine
flutter/engine repository. See also e: labels.
P2
Important issues not at the top of the work list
platform-web
Web applications specifically
team-web
Owned by Web platform team
triaged-web
Triaged by Web platform team
Steps to reproduce
Test this widget:
And I just checked the webui engine.
I think the problem is because of:
https://github.com/flutter/engine/blob/a1994d326c83751b504481f0399d5f3622faf7e5/lib/web_ui/lib/src/engine/text/layout_service.dart#L184
and
https://github.com/flutter/engine/blob/dd8840d74d8b713549949861f8b3ec6a02787e14/lib/web_ui/lib/src/engine/text/layout_fragmenter.dart#L339
Quote:
The above codes adjust the spaces between fragments, which is correct for English words which are separated by spaces.
However, Chinese words in sentences are rarely separated by spaces, so the code ends here:
So when laying out Chinese paragraph, TextAlign.justify is the same as TextAlign.left in ltr direction. Please check the image below.
And I think there's a simple solution to this: every fragment should be treated as having at least one traling space except for the last fragment in each lines.
Expected results
macOS result:
Actual results
Chrome result:
Code sample
Test this widget:
Screenshots or Video
No response
Logs
No response
Flutter Doctor output
Doctor output
The text was updated successfully, but these errors were encountered: