How to get `Label::createWithTTF` to support RTL languages such as arabic

753 views Asked by At

Firstly, I'm using Cocos2d-x v3.6, Visual Studio 2013 uses(UTF-8 without signature option) and C++.

When using Label::createWithTTF method to write Arabic text, It appear like the following.

The previous arabic text has not been written correctly, It was supposed to look like this السلام عليكم, and it also supposed the Arabic language belong to Unicode encoding.

My code:

auto label = Label::createWithTTF("السلام عليكم", "fonts/arial.ttf", 34);

Is there is any way to solve that problem ?


Edit:

I have applied what in this link [ Right-to-left mark ] and the result was disappearance the Arabic text as in the following picture.

The code:

auto label = Label::createWithTTF("\u200fالسلام عليكم", "fonts/arial.ttf", 34);
label->setAlignment(TextHAlignment::RIGHT);

The problem still exists.

1

There are 1 answers

1
Hamed Afshar On

Try using Label::createWithSystemFont instead of Label::createWithTTF. This solved my problem with RTL.