Search Unity

TextMesh Pro Arabic only displaying isolated forms

Discussion in 'UGUI & TextMesh Pro' started by tristydee, Apr 24, 2018.

  1. tristydee

    tristydee

    Joined:
    Jul 19, 2014
    Posts:
    7
    Hi,

    I'm developing a game with Arabic support and TMPro seems to be displaying the Arabic incorrectly.

    The text input box displays it correctly, but it doesn't appear correctly in game. I presume this is a bug and I'm not just missing something.

    Thanks very much in advance for any help!

     
  2. tristydee

    tristydee

    Joined:
    Jul 19, 2014
    Posts:
    7
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Any chance you could provide me / copy paste the text used in your example?

    The following thread might prove useful to you as well.
     
  4. tristydee

    tristydee

    Joined:
    Jul 19, 2014
    Posts:
    7
    Hi Stephan,

    here's the Arabic text:
    يجب أن تتكللّمي إلى الأرنب.

    The characters are isolated in both the text input box and in game. Thanks for the link, I see that that person is using a UPersian asset. Should Arabic work out of the box with TMPro or are there additional assets / ways I should parse the text before giving it to TMPro.

    Thanks again
     
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The text should be parsed before giving it to TMP with something like UPersian.
     
  6. tristydee

    tristydee

    Joined:
    Jul 19, 2014
    Posts:
    7
    Ok, thanks for the tip. Unfortunately, I'm still having no luck.

    If I use the ArabicFixer mentioned in the post linked above:

    "txt.text = ArabicFixer.Fix(txt.text, tashkeel, hinduNumbers);"

    This makes Unity's standard TextMesh change the sentence from its isolated form to the proper form. However, TextMeshPro appears to be missing the characters, even though I'm using the 600-6FF hex range for the font. Both the standard TextMesh and TextMeshPro gameobjects use the same font.

    This image is before I press play:
    https://s9.postimg.cc/t4mr3zl8v/Screen_Shot_2018-04-26_at_14.48.46.png

    And after:
    https://s9.postimg.cc/6365y8tb3/Screen_Shot_2018-04-26_at_14.48.55.png
     
  7. tristydee

    tristydee

    Joined:
    Jul 19, 2014
    Posts:
    7
    and this is the Arabic text:

    حتى ٣٠ السفن اليابان،, الساحل بلديهما الإتفاقية أضف قد, بقعة.
     
  8. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I suspect those characters might be missing from the source font file you are using. Those glyph would appear to be available when using UI.Text because it ends up picking some other random system font for those.

    Can you provide a link to the font you are using?
     
  9. tristydee

    tristydee

    Joined:
    Jul 19, 2014
    Posts:
    7
  10. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    thedrhax14 likes this.
  11. tristydee

    tristydee

    Joined:
    Jul 19, 2014
    Posts:
    7
    Hi Stephan,

    is it possible for you to give me an update on this? It'd be important for me to know whether you were able to replicate the issue and whether a fix is on the horizon.
     
    thedrhax14 likes this.
  12. GrassWhooper

    GrassWhooper

    Joined:
    Mar 25, 2016
    Posts:
    109
    @tristydee
    hey, how did it go with you, did you manage to fix it?
     
  13. tencnivel

    tencnivel

    Joined:
    Sep 26, 2017
    Posts:
    39
    Here is my contribution to isolate the problem. NOTE: I'm also using Noto Naskh Arabic and I set the content of the text programmatically with the ArabicFixer package (
    Code (CSharp):
    1. textMesh.text = ArabicFixer.Fix(textInArabic);
    ).

    It seems that the problem happens when Font asset creator gets its input of characters. It's as if it looses the linkage of the characters right at the input.

    I've tried the following methods:
    • using the range '600-6FF,750-77F': DOES NOT WORK
    • using 'Characters from file': DOES NOT WORK
    • using 'Custom Characters' and copy/pasting the characters from an external editor: DOES NOT WORK (the characters get unlinked when pasting them in the input field)
    • using 'Custom Characters' and copy/pasting the characters from Unity (eg. a copy paste of the characters from the console, after doing a Debug.Log(ArabicFixer.Fix(allMyCharactersInArabic))): WORKS !!!!
     
    Last edited: Dec 4, 2018
  14. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Do you mean when trying to create the font asset these characters are not included in the asset?

    I just tested this font file with the above range and they are getting generated correctly as seen in the image below.

    upload_2018-12-4_13-33-38.png
     
  15. tencnivel

    tencnivel

    Joined:
    Sep 26, 2017
    Posts:
    39
    Yes, same for me but we're missing the ligatures.

    Try this text (صفر), on a textmesh with content set programmatically with the ArabicFixer.Fix, using the font atlas you generated, you will not get the characters.

    From https://en.wikipedia.org/wiki/Arabic_script_in_Unicode the ligatures probably come from the following ranges:
    But when giving these ranges (600-6FF,750-77F,8A0–8FF,FB50–FDFF,FE70–FEFF) to the font asset creator we only get 301 characters (i.e. same as when we give the ranges 600-6FF,750-77F)
     
  16. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Most glyphs used in OpenType features such as Ligatures are not mapped to any Unicode values. As such they can only be accessed via glyph index as they are referenced by those features.

    Short term, these can't be added into a font asset. However, once the next release of TMP is available with Dynamic SDF support, I will be focusing on adding support for colored glyphs (Emojis) in addition to initial support for OpenType features such as Ligatures, Diacritical Marks and Advance glyph positioning. Ligature support will also give us support for Emoji modifiers. Then after those features are available, continue to add support for the rest of OpenType features.
     
  17. tencnivel

    tencnivel

    Joined:
    Sep 26, 2017
    Posts:
    39
    Thank you Stephan, I'll stay tuned to the new release.

    And In the meantime I'll use the workaround of copy/pasting the characters from the console to the font asset creator.
     
  18. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    If they show up via copy / paste then they have a unicode value assigned to them so you should be able to include them in the font asset.
     
  19. fcloss

    fcloss

    Joined:
    Dec 1, 2011
    Posts:
    192
    @Stephan_B is it planned for TMP to have an automatic System Fallback font as happens on Unity's UI Text?

    A quick additional question: Is there a programatically way to know if there are unsupported characters on a TMP Text?

    Thanks and excuse me for joining this thread from nowhere.
     
  20. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    A new Dynamic system will be introduced in the next release of TMP. This will make it possible to add new glyphs in font asset and fallbacks in the editor and at runtime.

    the TMP_FontAsset class has utility methods like public bool HasCharacter(char character) with several overloads to check if the asset contains certain characters.
     
    fcloss likes this.
  21. fcloss

    fcloss

    Joined:
    Dec 1, 2011
    Posts:
    192
    Thanks very much.
     
  22. drordoit

    drordoit

    Joined:
    Sep 7, 2013
    Posts:
    36
    Hi,
    I'm also trying yo use am Arabic font in Text mesh Pro (1.3) and I'm getting separated letters.
    I was wandering if there is something new in the subject.
    I don't really know about Arabic fonts, what is the best practice for working with Arabic and Text mesh pro?
    How should I import the font ? (custom characters or index range?)
     
  23. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    There are several posts above and links that will provide most of the information you need. In addition, check out the following thread.
     
  24. paatz04

    paatz04

    Joined:
    Aug 1, 2013
    Posts:
    38
    How am I supposed to use TMPro with ArabicFixer ?

    When RTL is turned on - the string seems to be rendered correctly and the lines break correctly but the characters are not connected. When I use ArabicFixer.Fix -> the characters are connected, but now each character is mirrored twice and therefore it's overall mirrored again. At least that's what it looks like to me.

    Any tipps ?
     
  25. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    See the following updated plugin.

    Please provide feedback in that plugin's thread if you run into additional issues.
     
  26. paatz04

    paatz04

    Joined:
    Aug 1, 2013
    Posts:
    38
    This plugin would require me to refactor the whole game though? Or am I missing something? That's a humongous task. I do not have an abstraction layer in between my scripts and TMPro.

    I've now tried to revert the characters - and it seems like it is working as it should on multilines as well, but not sure until I can have someone proofreading it.
     
    marie-hmm likes this.
  27. RahmatAli_Noob

    RahmatAli_Noob

    Joined:
    Sep 13, 2022
    Posts:
    74
    Hi, late Reply this Package resolve my issue. I can Write the English and Arabic both in the textMeshPro Input field With the help of Above mentioned Package.