Arabic/RTL/I18N support

I made a quick PoC with Defold to see if it supports Arabic text. It looks like it doesn’t.

Repro steps:

  • Create a new empty Defold project
  • Add a label, set the text to Hello World, run it and make sure it shows up
  • Download a font with full Arabic/Unicode character sets, like this one.
  • File > New > Font
  • Edit font, set the Font to the .ttf file and the size to 72
  • Check the All Chars check-box. (Without this, most of the characters don’t appear.)
  • Change the label font to the new Arabic font
  • Set the text to القرآن الكريم
  • Run the game

I was hoping the text would work. Alas, the letters appear backward (left-to-right instead of right-to-left) and disjointed:

image

Are there any plans to support RTL/I18N/Arabic/etc.?

6 Likes

Thank you for such a clear and concise report, excellent! We currently don’t support this out of the box. There’s no RTL checkbox or anything like that on labels and text nodes.

By disjointed do you mean the spacing between the individual glyphs or something else?

For a serious project supporting multiple languages you likely want a system on top of Defold that takes care of setting the label or text node texts. This system could reverse the text before setting it on a label or text node to properly deal with RTL vs LTR languages. The same system could also set the right or left align property on the node. For gui text nodes you could perhaps even put the translation key in the text node and get it before translation.

3 Likes

I tested too with this font. I don’t know how it should look though.

2018-07-02%2001_50_18-Particle%20Pack

2018-07-02%2001_51_50-Kawkab%20Mono%20Arabic%20Monospaced%20Font%20%D8%AE%D8%B7%20%D9%83%D9%88%D9%83%D8%A8%20%D9%85%D9%88%D9%86%D9%880%20-%20Particle%20Pack

Tried reversing order of chars

2018-07-02%2001_54_10-Particle%20Pack

3 Likes

Lots of languages has diacritics that are specified in a particular order. Those are lost or get wrong when just doing a plain reverse.

5 Likes

Reversing the characters is a good start. In my quest to find a 2D game engine that supports Arabic text natively, I came across a lot of details (some of which weren’t mentioned here, sorry).

There are several pieces that need to be in place for this to work properly:

  • Unicode support for non-ASCII characters (so you don’t see boxes)
  • Right-to-Left support (Chinese/Japanesse/Korean, Arabic, Urdu, etc.)
  • Glyph shaping. In languages like Arabic, Thai, and others I can’t remember, the letter appears differently depending on if it’s the first, last, or middle letter in the word.

All of the game engines that I’ve found seem to use HarfBuzz to implement this. It’s not a small library, but it handles all of the different languages well. I think it’s some sort of C++ library.

@Pkeod how did you generate your second image (this one)?:

This is how the text is supposed to look.

4 Likes

That image is the text in the editor. So we know at least there it’s supported.

1 Like

We need Arabic language support
I was frustrated

in properties > text
You write in a correct way


But in the editor screen is used in the opposite way
And not tangled

1 Like

Why does the font seem to be trimmed? I’ve tried different fonts, letter spacing and line spacing, but the result is the same.
image_2023-03-16_15-36-18
Left-Defold, right - google font site

1 Like

It’s not trimmed, it’s incorrect shaping.

In Arabic, letters change their shapes depending on whether they’re at the beginning, middle, or end of the word. The letter taa (two dots smiley face) at the end of the word should look like a smiley-face (Google screenshot). Defold is showing the version of taa that’s in the middle of two other letters.

1 Like

What do we do now? Is there a solution?

Please take a look at my previous post here. Arabic (and languages like Thai) require several features: left-to-right, diacratic marks, and glyph shaping.

My understanding from other game engines and frameworks that support this (Godot 4.0+, Lime/OpenFL) do so by integrating the HarfBuzz library, or something similar. I don’t have any personal experience in this area.

3 Likes