Supporting non english languages and RTL languages

Hello everybody. How can I use non english languages like persian(farsi/and other RTL languages) in a game? Thanks

1 Like

Hi! Defold text labels and text nodes in a gui always present their content in a left-to-right order. You would have to reverse the string yourself before setting it on the text node or label. Like this:

local some_rtl_text = "...."
gui.set_text(node, some_rtl_text:reverse())
label.set_text("#mylabel",  some_rtl_text:reverse())

As for the actual font there are really no limitations to which characters to use. When you create a .font file it will by default include the standard ascii range, but you can either specify Extra Characters or more likely in the case of a whole new alphabet instead check the All Chars checkbox.

5 Likes

thanks to your reply.I will test it

1 Like

one week ago I wanted defold just to make html5 games in english but now I prefer to use it for my next mobile game in native language ( persian ) instead of unity ( if i can use persian )
anyone able to write persian in defold? Regardless of typing direction my problem is rendering persian text itself. I have tried some persian fonts using All Chars checked but I still can’t see any persian chars in my label.
i have tried these fonts unsuccessful: “LMN Homa”, “LMU Homa”, “B Homa”. ( all ttf format )
I’m not sure if it’s because of fonts or not, i just want to write some persian to start, not much different what font works for me.
Thanks

homa.zip (29.4 KB)
i made this bitmap font using Hiero, but still can’t see anything. does it mean my char id’s are not in “fnt” table? I’m not familiar with font system and condings.

edited 2 hours later: I’m getting some promising results. I’ll share if i get final result :grinning:

I’m not sure but maybe first time we see persian in defold:


I need more time to get used to persian in defold because of RTL and line breaks but it’s good point for me :+1: :smiley:

4 Likes

Happy to hear you got it working! What was the actual problem? And error with the font?

I have a note to investigate native RTL support. I can’t promise anything yet though.

3 Likes

I’m not sure yet but it seems char ids in persian typing are not those should be on fnt, or ttf.
when i write persian directly using my keyboard ( i see persian in text property field ) nothing happens on game label ( empty text or something strange). but if i write english using my keyboard and persian font i see some persian character, so i found i need a converter, look at text property of my label in that picture, those characters are not persian and not english too, i have used a converter to get them from persian text. ( i use that converter for poor texts in unity too, but in unity there is some persian plugins which i can write persian directly with my keyboard when i use them ) maybe you don’t understand what i mean and what happens because my english is not good enough and I’m not sure what happens yet, but i got that persian text using a converter and persian font.

thats great, I’m new to Defold and Lua, and it’s long time i have not used C++ too, so i can’t do it myself now, but I’m interested to learn more to do something usefull with defold.

2 Likes

Added ticket: https://github.com/defold/defold/issues/4900

2 Likes

:+1: I Love You :smiley:

1 Like

Hi lovely guys
After about two years I’m here again with Defold. Anything usefull happend to Defold RTL from those days?

1 Like

Unfortunately as of 26 April 2021 not, as evidenced by this comment on GitHub and the silence of the ticket.
However, this user got some bodge working for Arabic (Which is also RTL), and I hope it might be useful.

1 Like

Correct, no work on RTL support unfortunately, but we recently talked about it a bit in the team after seeing this user sharing a project with RTL text in Defold: https://twitter.com/TheTallWitch/status/1537053792184721409

1 Like