zrender
zrender copied to clipboard
Made the wrapping algorithm more closely align with Unicode Standard
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.
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.
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.