cocos2d-html5 icon indicating copy to clipboard operation
cocos2d-html5 copied to clipboard

Add correct line breaks support for non-latin languages

Open seagullua opened this issue 9 years ago • 2 comments
trafficstars

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:

Привіт як в 
тебе справи

seagullua avatar Jul 10 '16 20:07 seagullua

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.

pandamicro avatar Jul 18 '16 07:07 pandamicro

Here is my attempt. https://github.com/cocos2d/cocos2d-html5/pull/3450

ntrrgc avatar Jan 31 '17 17:01 ntrrgc