Using Arabic Text with a custom Font - Cocos2DX

Using Arabic Text with a custom Font - Cocos2DX

I have a use-case involving Arabic text in a game, with custom font. I am currently using the createWithTTF API call, and selecting the Font file that I would need.

However, since Arabic is a Right to Left(RTL) language instead of a Left to Right(LTR) language, the texts are getting printed incorrectly. Apparently, the best solution for this is to use the createWithSystemFont API call. However with this call, I would not be able to use a custom font and I would have to resort to a system font.

Is there any way that you guys know in Cocos2DX to use a custom font, with Arabic text? I did look into this Github issue( I tried the Arabic Writer( out, but this gives glitchy output in certain cases. I know that editing the source JSON/Plist file is an option, and I have tried using reversed Arabic strings in the source. However, since Arabic is a language that has combined characters, the result that I get on my UI is not 1:1 with the expected result, and some characters are disjointed(which are supposed to form a special character after getting merged).I understand that Cocos does not have a proper Shaping Engine with FreeType font to get reversed Arabic texts work as they should, so are there any workaround to overcome this(Other than using SystemFont)?

Looking for suggestions on how to tackle this. I have looked into almost all open threads related to this, and could not find anything conclusive. Thanks!



Label characters should be added as child nodes, you could access them and rearange them after creation. (idk how arabic text looks like, but maybe this helps instead of the reverse string method)

If the characters itself are mirrored on creation you could give the label a X-Scale of -1



Thanks for the reply.
Could you give me the names of the files/APIs that I could edit in the Engine to achieve this? It would be very helpful. Thanks!