Word wrap is not working on Labels in version 1.3.2. Is this a known bug? Does this work in newer versions?
Edit: I found out whats going on: the problem is with Spanish words that have accents like “debería”. If the word is at the end of the line it might end up doing something like this:
some special characters are missing from the “English” alphabet, this is why the word wrap works in an unexpected way. You can check it if you place a breakpoint in the fragmentText function.
Open the following file in your CC root folder: resources\engine\cocos2d\core\label\CCTextUtils.js
Add the character “í” to the following variables:
label_firsrEnglish
label_lastEnglish
label_lastWordRex
After this quick fix, the editor works fine. There are several other missing special characters as well. Somehow this fix should be included in the next release. But how?
Hi @PZsolt27, thank you for the detailed explanation!! I will look into it. With this information I might be able to create a workaround for my game. I hope the Dev team will fix it in a more permanent way.
Thanks!!!
Edit: I already submitted an issue at Github. Thanks @PZsolt27 for your help!
@PZsolt27 solution is correct. I’m planning to add the characters for Spanish and Catalan later this afternoon. I believe this should fix most of romance languages.
I’ve got greenlight from dev team to do a pull request on Github, so this should be fixed in the next version. I will publish here the 3 variables so you can patch your own version.
But my concern is about other languages. @MikeFromMars would you mind to take a look and check if word wrap works for German?
Hi @MikeFromMars! the problem avctually happens in 1.5 and all lower versions, so it should happen in 1.4 too (it happens on 1.3.2). But this actually helps. I will add those characters to the fix.
Let me know the result, I tried modifying them in cc.TextUtils but not success, must override it on our splash scene, as following cc.TextUtils.label_lastWordRex = new RegExp(([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõ-яА-ЯЁё]+|\S)$);
Hi, as I said on github, I will wait a few days in case more people wants to add more languages before doing a new PR.This is only for Latin alphabets.
Checked so far:
-Catalan
-Spanish
-Portuguese
-Hungarian
-French
Should work: Italian
I believe German was already included. English works well.
I can confirm that my pull requests with this bugfix has not been added to 1.5.2 and the problem is still there. @pandamicro@owen@nantas Do you know when this will be added to release?
The pull request was accepted nearly 2 months ago.