zrender icon indicating copy to clipboard operation
zrender copied to clipboard

Made the wrapping algorithm more closely align with Unicode Standard

Open Wetterquarz opened this issue 1 year ago • 0 comments

Brief Information

This pull request is in the type of:

  • [x] bug fixing
  • [ ] new feature
  • [ ] others

What does this PR do?

Spaces are now treated according to Unicode Standard (https://www.unicode.org/reports/tr14/#SP). It now correctly reads in all characters as a single character.

Fixed issues

Fixes apache/echarts#18583

Details

Before: What was the problem?

It is possible for a wrapped line to start with a space, which may not happen if the line break was not intentional. And breaks to happen within characters.

image image

After: How does it behave after the fixing?

Line breaks are now only inserted after the last space and trailing spaces are ignored for line breaking, as required by the Unicode standard. Characters which consist of two chars in JavaScript are now treated as one.

image

Documentation Info

One of the following should be checked.

  • [x] This PR doesn't relate to documentation changes
  • [ ] The documentation should be updated later
  • [ ] The documentation changes have been made in ecomfe/zrender-doc#xxx

Misc

Related test cases or examples to use the new APIs

/test/text-overflow.html

Others

Merging options

  • [x] Please squash the commits into a single one when merging.

Wetterquarz avatar Apr 12 '23 15:04 Wetterquarz