[Bug Label 1.5] Label word wrap not working on words with accents

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:

deberí
a

or

deber
ía

Example test project: Dropbox - File Deleted

Screenshot:

@nantas @pandamicro is this a know issue?

Edit: tested with 1.5 Beta 3 and Im having the same issue.

Hi @jrosich,

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?

Best regards,
Zsolt

1 Like

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!

1 Like

Have you made this work @jrosich , I’m dealing with same problem

@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?

Thanks!

Hi @jrosich,

thank you for your confidence. Sorry, I am still on 1.4. I will install 1.5 in some weeks, please ask me then again, if it is not already fixed.

And here are the famous german letters ÄÖÜäöüß for testing.

Take care and all the best

Michael

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.

Thanks!

Hi @jrosich, @MikeFromMars,

we should collect all missing special characters to avoid such bugs in the future. Some of the Hungarian characters are also missing (ÁÉÍÓŐÚŰáíóőúű).

All German characters (ÄÖÜäöüß) are supported.

By the way, why don’t they use the space as word separator? I don’t really understand the fragmentText function.

Best regards,
Zsolt

Thats a great idea!

Could you make a PR to add all the missing characters? thanks.

Yes I can. I will work on it later today.
Thanks!

I’ve already made a pull request so I guess it will be fixed on next build.
As a workaround, update the code below in this file:

CC root folder: resources\engine\cocos2d\core\label\CCTextUtils.js

label_lastWordRex : /([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõ-яА-ЯЁё]+|\S)$/,
label_lastEnglish : /[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõ-яА-ЯЁё]+$/,
label_firsrEnglish : /^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõ-яА-ЯЁё]/,

This fix includes: Spanish, Catalan, Hungarian, French and Portuguese (and should be fine for the rest of romance languages).

All credit to @PZsolt27 for finding the library and how to fix it. Thanks!! :slight_smile:

1 Like

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)$);

Hey, I have the same problem with Czech acccents, could you please add these as well?
ěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤ?

These are for Polish:
żźśóńłę湯ŹŚÓŃŁĘĆĄ

Hi,

maybe add a comment here:

Best regards,
Zsolt

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.

Pending:
-Czech
-Polish

1 Like

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.

This is not fixed yet so I tried to fix it again at the source. But now its not working for me. How did you got this fixed?

editing: I managed to fix it adding this to my loading screen:

cc.TextUtils.label_lastWordRex = new RegExp(’([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõ-яА-ЯЁё]+|\S)$’);

Edit2: it will be added in 1.6 (https://github.com/cocos-creator/engine/issues/1671)

cc.TextUtils is not available in version 2.x, some Vietnamese characters are missing (ừ, ờ…), how to change the label_lastWordRex property ? :cry: