Search Unity

TextMesh Pro Arabic Support

Discussion in 'UGUI & TextMesh Pro' started by Zilk, Jul 28, 2019.

  1. Zilk

    Zilk

    Joined:
    May 10, 2014
    Posts:
    333
    I've been adding Arabic support to my game lately through Text Mesh Pro and I must say that the support currently available is.. terrible.

    TMPro has support to enable RightToLeft which is good. However it also flips latin numbers which isn't correct. It also doesn't correct the font for Arabic so it is unreadable. There are some great open-source plugins out there but those require changing all components away from Unitys default TMProLabels which isn't ideal.

    What would be needed to get great Arabic support:
    • Automatic recognition of Arabic characters and if found, enable RightToLeft and a manual bool to force RightToLeft.
    • Automatic correction of character offsets (similar to how Easy Alphabet Arabic plugin has a function to correct it).
    • No flipping of latin numbers. Also Easy Alphabet Arabic has a nice feature to convert latin to arabic numbers.
    • All this above handled whenever text in the label changes so developers don't need to worry about it.

    My current solution to handle this is so terribly hacked to get it working with TMPro that I want to cry.
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I do plan on improving / adding proper support for Arabic text in TextMesh Pro but that is a longer term undertaking.

    In the meantime, I do recommend taking a look at the following free plugin. As per your point, this requires using another component but that is something that I am discussing with the author of the plugin to try to avoid. I'll try to provide an update on this later this week.
     
    Sami_AlEsh likes this.
  3. Zilk

    Zilk

    Joined:
    May 10, 2014
    Posts:
    333
    TMPro is amazing so I really look forward to it. And yes, the free plugin handles it brilliantly but requires swapping components and I know from experience that this always ends up biting one in the ass sooner or later :D

    Something that could go a long way in TMPro would be a callback for when text is being changed (with the changed text in the callback) so one could format it however one wanted. Then it would be easy to say input Easy Arabic or something similar to fix most issues.

    Right now I ended up in a race condition thing where things weren't updated after I tried to fix the arabic characters etc :D
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    That is something that I am considering in the short term.
     
    DoN2kcz likes this.
  5. Zilk

    Zilk

    Joined:
    May 10, 2014
    Posts:
    333
    That would be awesome. Then one could just pass the text through the RTLTMPro open source code functions if the current language is Arabic, even handle the setting of the RightToLeft bool there with help from RTLTMPro functions.

    Do it! I'll give you a gold star.
     
  6. syduelist

    syduelist

    Joined:
    Nov 13, 2020
    Posts:
    2
    Are there any updates on adding Arabic support to TMPro?
    A current workaround solution is:
    * enable `isRightToLeftText`
    * set `alignment` to `TextAlignmentOptions.TopRight`
    * Use ArabicFixer.Fix on the text
    * Reverse the text and output it.
    But if the game is multilingual, doing this to each text would be overkilling.
    It would be great if you can support Arabic naively.
     
    nickfourtimes likes this.
  7. nickfourtimes

    nickfourtimes

    Joined:
    Oct 13, 2010
    Posts:
    219
    If nothing else, thank you for this – it worked like a charm.
     
  8. ahmadgml32

    ahmadgml32

    Joined:
    May 29, 2020
    Posts:
    4
    It doesn't show Arabic letters it's just squares even when I changed the font to Arabic font
     
    afshin_a_1 and danialaddin66 like this.
  9. SolenopsisCampo

    SolenopsisCampo

    Joined:
    Jun 1, 2020
    Posts:
    6
    I know this isnt ideal but until they fix it you can just type the text you want in an external image editor like paint.net with the font you want with no background then sav eit as an image and import that without any compression and setting the filter mode to point, gave me decent quality text, ofcourse its a hassle because you will need to have an app open but its not gonna take 30 seconds more than it would of taken with tmp (issues do arise when you dont want just regular black text without effects tho)
     

    Attached Files:

  10. Starbox

    Starbox

    Joined:
    Sep 17, 2014
    Posts:
    467
    That's a comically good solution, if any. I suppose one could push the enveloppe and add an alpha channel.