Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 896
Lion King Avatar asked Sep 12 '25 09:09

Lion King


1 Answers

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

like image 163
Hamed Afshar Avatar answered Sep 14 '25 23:09

Hamed Afshar