Cannot initialize label, the accents are show as little squares

Cannot initialize label, the accents are show as little squares
0

Hello there,
i’m using cocos 3.17 on Xcode 11. I’m reading the string from a executable called Localized_it but something goes wrong because special character as “ù” are not visualized in the text, there is a little square on a “u” instead. This is how I initialized my label:

TTFConfig labelConfig;

labelConfig.fontFilePath = "Trebuchet MS.ttf";

labelConfig.fontSize = fontText;

labelConfig.glyphs = GlyphCollection::DYNAMIC;

labelConfig.outlineSize = 0;

labelConfig.customGlyphs = **nullptr** ;

labelConfig.distanceFieldEnabled = **false** ;

**const** **char** * kk = GetLocalizedString(descDinosauro.str().c_str(), "");

//Label* prova = Label::createWithTTF(kk, "Trebuchet MS.ttf", fontText);

Label* prova = Label::createWithTTF(labelConfig, kk);

prova->setColor(COLOR_LABEL_DESC);

prova->setPosition(Vec2(0, screenSize.height/2));

prova->setAnchorPoint(Vec2(0,0));

**this** ->addChild(prova, 100);

There is something wrong?

Look at the .ttf does it contain these special characters that you need?

Yes. The problem is that the “ù” I use it’s a 8-bit character (the number ASCII is > 127) because it is from a complex text editor. I don’t know how I can display it.

ps. sorry for my English

Does your TTF have this character? If not, you could make it and use your own custom font.

I cannot modify the font, sorry. And I cannot retype the faulty character. In the file.ttf have the character.

The original project it’s cocos 2.2.6 and I made a porting to cocos 3.17. Xcode 11

The character that cannot be visualized in the correct way from the file is “ù”. The strange thing it’s that not all the “ù” in the text have the problem and I discover the reason of this in the HEX file. There are two kind of “ù”:

  • one “ù”, coded in HEX as 75 CC 80. This is the one with the problem, I think that’s why this part of the text it’s from a complex text editor

  • other “ù”, coded in HEX as C3 B9, it’s visualize in the correct way, and it’s the same if I type it from the keyboard

I need to see both characters, or with a conversion of those that don’t work, or a label definition that reads both characters, special and simple ones.

Try to use SystemFont instead.

Label::createWithSystemFont("text", "Arial", 14);

1 Like

sorry I cannot change font.

Same problem here, two different code for the character ù:
75 CC 80
C3 B9

Both seems UTF-8 encode

With Cocos2d-x 2.2.6 both characters are shown correctly
With Cocos2d-x 3.17.2 the 3 bytes one is not shown correctly, but a square symbol appears next to the “u” (not accented)

This happens also with Arial or Trebuchet MS, only using method setSystemFont avoid this behavior, but I need to use custom font.

I would like to ask if anyone knows how to correctly show both characters, or if there is a converter that can convert the “extended” character to the “reduced” version

Any information can be useful
For example? Do you know if both characters are UTF-8?
If so, why are there two encodings for the same character?

@coulsonwang do you have any thoughts on this issue?

I will take a look.

@ele_elion As I can see you use Trebuchet MS.ttf font to initiate your label, but there is no a special character ù in it. Which font do you use, and how can i reprocude it?

thks for your repling. You’re right, I use Trebuchet MS.ttf but I cannot modifiy the font to add the special character ù, sorry. I assume you can use the vanilla version of Trebuchet MS.ttf to reproduce the error.

you can use
https://www.rapidtables.com/convert/number/hex-to-ascii.html
to create two version of character ù
typing in the hex box
75 CC 80
C3 B9
and select UTF-8 encode

@coulsonwang, What do you mean by special character ù?
As you saw in my post there are two UTF-8 versions of ù

Actually, Trebuchet MS does not have the character 75 CC 80 while the Arial has it.
Both instead have the character C3 B9
Both of these characters correspond to the accented u “ù”

Schermata 2020-03-24 alle 10.51.37 Schermata 2020-03-24 alle 10.52.08

I would like to ask:

  • Why in cocos 2.2.6, the Trebuchet MS font reproduced both characters correctly?
  • In the cocos forum editor if I copy and paste the two variants of ù and then check in the preview, both are encoded into C3 B9.
    Here, I need a way to turn 75 CC 80 into C3 B9 programmatically or with an editor

Thank you
Regards

Hi, any suggestions?