RTL Text Mesh Pro. Free and Open-Source plugin to add Persian and Arabic support to TextMeshPro

Hi. I finally created a plugin to add Persian and Arabic support to TextMeshPro.

GitHub

Features
Realtime RTL Text
You don’t need to convert, copy and paste texts. Start writing and texts will be converted right away.

Rich Text
All Text Mesh Pro’s tags are available in RTL Text Mesh Pro

RTL InputField (See known issues)
Realtime InputField is supported.

Multiline
Yes, This plugin has no problem with multiline RTL texts.

AutoSize
Auto Font Size is fully supported.

English, Farsi and Arabic digits are supported

Arabic Tashkeel
Arabic tashkeel are supported. Also you can turn them off or on for every RTL Text Mesh Pro object.

To see usage instructions visit github page.

Known Issues

  • Multiline has issues with English text.

  • InputField (and anything that was designed to work with TextMeshProUGUI script) will not work.
    Why it doesn’t work? We need to override the text property of TextMeshProUGUI. But the text property is not defined virtual. You need to manually make the property virtual.

  • Open TMP_Text.cs from TextMeshPro source code

  • add virtual keyword to text property.

  • Open RTLTextMeshPro.cs and uncomment the top line where it says //#define RTL_OVERRIDE

  • Now you can use InputFields (and Dropdowns in future)

Have fun!

17 Likes

i am using it for arabic, and i must say, you sir are a legend :slight_smile: this worked like magic.

1 Like

would love it if this could get officially incorporated.

6 Likes

Our Input Fields are not working. I followed your steps of making the text virual in TMP_ Text.cs
And then proceed to enable
#define RTL_OVERRIDE
on the file RTLTextMeshPro.cs

We keep getting this error when we want to write something on the input field.
IndexOutOfRangeException: Index was outside the bounds of the array.
TMPro.TMP_InputField.GenerateCaret (UnityEngine.UI.VertexHelper vbo, UnityEngine.Vector2 roundingOffset) (at /Users/ghassanbarghouti/Library/Unity/cache/packages/packages.unity.com/com.unity.textmeshpro@1.2.4/Scripts/Runtime/TMP_InputField.cs:2817)
TMPro.TMP_InputField.OnFillVBO (UnityEngine.Mesh vbo) (at /Users/ghassanbarghouti/Library/Unity/cache/packages/packages.unity.com/com.unity.textmeshpro@1.2.4/Scripts/Runtime/TMP_InputField.cs:2771)
TMPro.TMP_InputField.UpdateGeometry () (at /Users/ghassanbarghouti/Library/Unity/cache/packages/packages.unity.com/com.unity.textmeshpro@1.2.4/Scripts/Runtime/TMP_InputField.cs:2716)
TMPro.TMP_InputField.Rebuild (UnityEngine.UI.CanvasUpdate update) (at /Users/ghassanbarghouti/Library/Unity/cache/packages/packages.unity.com/com.unity.textmeshpro@1.2.4/Scripts/Runtime/TMP_InputField.cs:2670)
UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate () (at /Users/builduser/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/CanvasUpdateRegistry.cs:150)
UnityEngine.Canvas:SendWillRenderCanvases()

Kindly advise.

Which version of the library are you using?
Can you please check if the same thing happens with TextMeshPro 1.3 and RTLTMPro 3.1.1?

The newest version of TextMeshPro is 1.2.2 though

I’m referring to the PackageManager version:

Alright thanks, I’ll check it out

Thank you, it’s working almost correctly. One problem I’m having is that I want to display the Arabic ي but instead I’m getting this ى (It’s probably Persian). The Farsi checkbox can’t be turned off, and I’m trying to disable it from the code but it also doesn’t work (It only does when I re-click it while on play mode and on the editor).

Kindly advise.

I forced it to always be false from the Library, and it’s working now.

Hi,

Thank you for providing a plugin which fixes the issue of certain fonts not working correctly with TextMesh Pro.

I have created a bug report about these fonts not being rendered out-of-the-box with TextMesh Pro.
The progress of the report can be followed here: https://issuetracker.unity3d.com/product/unity/issues/guid/1090143/

Regards,
Lukas A.
Unity QA Team

3 Likes

Hi
Dear @ the plugin you have written has an issue with HTML tags in Arabic and Persian Texts.
For example texts like the one below:
“سلام” + “<color=#A7DF40FF>” + یونیتی+ “”;
don’t display correctly.
could you please have a check and help me if possible.

This looks great! I have a question though:

When typing Arabic text into the RTL text input box (as shown above), is it possible to make the Arabic text input appear joined together? My question is referring to how the text appears in the Unity editor inspector window - not the rendered TextMeshPro element in the scene view. Please advise. Thanks.

Hi guys,
Sorry for late reply, I have been very busy these days.

There’s a bug in tag detection that it doesn’t detect tags with uppercase characters. It means that you need to write your color codes as #a7df40ff instead of #A7DF40FF.
This bug will be fixed in next release.

No. It’s really hard and complicated to fix the text as you write it.
In order for it to work, we need to track which characters have been fixed and which characters have not so we don’t refix characters.

Thank u so much @sorenc for your help
I wish best for you.

Hi Dear,

Thanks for creating this marvelous plugin.

I had followed all the steps but couldn’t find any RTLTMP menu in GameObject/UI/*****

Kindly help me to sort out this.

Hi ,
Thanks for this great plug.
If I have a specific cheater that don’t connect to the other character’s, what can be the problem? is it a missing Unicode? Or something else?
Thanks Dror

Hi,
Please check if you have any compile errors or not. Compilation error causes unity to stop compiling RTLTMPro files.
However, You can add RTLTextMeshPro script to an empty gameobject to turn it into a text gameobject.

If it shows the character as a box it means that the unicode is missing, otherwise it’s more likely that plugin doesn’t know that character. Post the whole sentence and a picture of the character shown correctly.

the sentence is “اضغطوا على المفتاح الطويل.” . As you can see the " على." isn’t connected.


@drordoit I have tried to solve the linked “Alef Maqsora” problem, the only thing that worked is using a font that the fontAssetCreator can generate the linked Alef Maqsoora character from, the following fonts have worked for me:
-Changa
-Markazi
I think this has to do with the range you set in the fontAssetCreator, so don’t forget to set the following range for the Arabic language:
0600-06FF,0750-077F,08A0-08FF,FB50-FDFF,FE70-FEFF,10E60-10E7F,1EE00-1EEFF

@
Thanks for providing this plugin for free and open sourcing it.
I have a question: how did you manage to get the Auto Font Size feature to work?
Updating the text whenever the Rect-Transform size changes didn’t work for me.
I just wanna know since I’m trying to build a custom solution while relying on the default TMPro component.
Any help would be appreciated.

1 Like