Search Unity

  1. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  2. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Participate with students all over the world and build projects to teach people. Join now!
    Dismiss Notice
  5. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

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

Discussion in 'Unity UI & TextMesh Pro' started by sorencoder, Jun 12, 2018.

  1. sorencoder

    sorencoder

    Joined:
    Mar 27, 2017
    Posts:
    44
    Hi. I finally created a plugin to add Persian and Arabic support to TextMeshPro.

    Github link: https://github.com/sorencoder/RTLTMPro

    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:
    https://github.com/sorencoder/RTLTMPro

    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)

    @Stephan_B Would you make `text` property virtual in the source code so users don't have to make it virtual everytime they update? Would you gift a "virtual" keyword to all of users that want to use RTL languages?

    Have fun!
     
    Last edited: Jun 12, 2018
  2. GrassWhooper

    GrassWhooper

    Joined:
    Mar 25, 2016
    Posts:
    37
    i am using it for arabic, and i must say, you sir are a legend :) this worked like magic.
     
    sorencoder likes this.
  3. stgs73

    stgs73

    Joined:
    Mar 23, 2015
    Posts:
    44
    would love it if this could get officially incorporated.
     
    sorencoder and GrassWhooper like this.
  4. classicalguss

    classicalguss

    Joined:
    Apr 15, 2018
    Posts:
    5
    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.
     
  5. sorencoder

    sorencoder

    Joined:
    Mar 27, 2017
    Posts:
    44
    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?
     
  6. classicalguss

    classicalguss

    Joined:
    Apr 15, 2018
    Posts:
    5
    The newest version of TextMeshPro is 1.2.2 though
     
  7. sorencoder

    sorencoder

    Joined:
    Mar 27, 2017
    Posts:
    44
    I'm referring to the PackageManager version:
    upload_2018-10-9_18-36-41.png
     
  8. classicalguss

    classicalguss

    Joined:
    Apr 15, 2018
    Posts:
    5
    Alright thanks, I'll check it out
     
  9. classicalguss

    classicalguss

    Joined:
    Apr 15, 2018
    Posts:
    5
    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.
     
  10. classicalguss

    classicalguss

    Joined:
    Apr 15, 2018
    Posts:
    5
    I forced it to always be false from the Library, and it's working now.
     
  11. LukasA

    LukasA

    Unity Technologies

    Joined:
    Aug 19, 2016
    Posts:
    4
    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
     
    sorencoder likes this.
  12. Amin_Shiravand

    Amin_Shiravand

    Joined:
    Aug 1, 2018
    Posts:
    2
    Hi
    Dear @sorencoder 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>" + یونیتی+ "</color>";
    don't display correctly.
    could you please have a check and help me if possible.
     
  13. bsweileh

    bsweileh

    Joined:
    Jun 1, 2018
    Posts:
    3
    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.
     
  14. sorencoder

    sorencoder

    Joined:
    Mar 27, 2017
    Posts:
    44
    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.
     
  15. Amin_Shiravand

    Amin_Shiravand

    Joined:
    Aug 1, 2018
    Posts:
    2
    Thank u so much @sorenc for your help
    I wish best for you.