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

Issue 19659 fix 3b

Open mnievas opened this issue 4 years ago • 1 comments

The current implementation based the decision of which char is a word separator on the location of the device but some games let the user decide the language from a settings, so it is good to let them the choice.

I added these option for the developer to choose from:

WordSeparatorBasedOnDevice: current implementation WordSeparatorSpaceSlashNotHighUnicode: Spaces and '-' will be consider words separators. Recommended for Korean WordSeparatorSpaceSlashAndKCJ: Spaces, '-' and KCJ unicodes will be consider words separators. Recommended for Spanish

You can see the test on: Node:UI > GUI Dynamic Create Test > RichTest Test > language

The function findSplitPositionForWord receives the parameter wordSeparatorMode and chooses the inline function (charWrappableFunctionPointer) to be use in getNextWordPos and then in std::find_if to look for a good spot to but the sentence.

To make the decision I use these facts:

  • space (32) as word separator for Spanish, English, Russian, etc.
  • char '-' (45) is also a separator for English
  • CJK unicodes has a len of 3 or more. (named as HighUnicode)
  • Chinese has CJK but no separator
  • Korean has CJK but space is a separator

mnievas avatar Feb 06 '21 11:02 mnievas

Original issue https://github.com/cocos2d/cocos2d-x/issues/19659

mnievas avatar Feb 06 '21 11:02 mnievas