cocos2d-html5
cocos2d-html5 copied to clipboard
Add correct line breaks support for non-latin languages
Without this patch, the Cyrillic and other non-latin languages had an issue with line breaks in LabelTTF. The world was broken in any place.
Before in LabelTTF the string "Привіт як в тебе справи" will be shown next way:
Привіт як в те
бе справи
The word тебе was cut into pieces
After the patch it works ok:
Привіт як в
тебе справи
Hi, this fix will break the current behavior with some Oriental languages (Chinese / Japanese), because all characters in these Oriental languages are aligned together, no space to separate them, the line break can be added anywhere in between. ex:
中文语句中是不包含空格的
If the Label width is short, this should be convert to
中文语句中是
不包含空格的
But with this PR, it can't break lines correctly.
The problem with the current engine implementation is that it haven't included many non-latin languages into the line break algorithm, you can overwrite the regular expressions manually in your game like you do here, but I'm sorry that we can't do it this way in the engine.
Here is my attempt. https://github.com/cocos2d/cocos2d-html5/pull/3450