Search Unity

TextMesh Pro TMP 2.0 and Arabic

Discussion in 'UGUI & TextMesh Pro' started by SolutionsGameDev, Apr 23, 2019.

  1. SolutionsGameDev

    SolutionsGameDev

    Joined:
    Apr 3, 2019
    Posts:
    3
    Hello,

    I've heard that TMP 2.0 in 2019.1 will bring more support to RTL languages like Arabic, so I gave it a try.

    I made a new SDF using the Calibri font and the following Unicode ranges: 600-6FF,750-77F,0020-007F
    This is the text I am trying to write: "هذا نص عربي". (Link on google translator).
    This is the result:
    t1.png

    The upper is using TMP normal text editor, and the lower is using the RTL editor. Both cases are not accurate, as the letters appear correctly but separately. In Arabic, the letters has to be connected, not shown separately.
    The upper case is a bit more correct though, as it shows the letter ordered correctly from Right to Left. The lower (RTL editor) shows the letters in reverse order.

    Now using an RTLTMP package, (Link to forum thread) this is the result:
    t2.png

    Same letters, but in correct order, direction and letter connections.

    I tried using the SDF attached with the RTLTMP package with TMPro, but it didn't work. I am using TMP 2.0 in a 2019.1 project, and RTLTMP in a 2018.3 project.
    For some reason, I am getting random crashes (in both projects) whenever I try making a new Arabic SDF (same steps as I used before).

    I don't know how Arabic and RTL support in TMP 2.0 was tested, but the results in the first image usually happen on PC's that do not have full Arabic support installed or have a partial support, so the letters will appear correctly (which may give the impression that Arabic is fully supported), but their direction and connections are actually incorrect.

    @Stephan_B

    Arabic support is a really huge help to thousands of devs. Please let me know if I missed something :)
    Thanks.
     
    Last edited: Apr 24, 2019
  2. StefanoCecere

    StefanoCecere

    Joined:
    Jun 10, 2011
    Posts:
    211
    we have a big unity arabic game (opensource) https://vgwb.github.io/Antura_arabic/ where i hooked the TMP engine to render perfectly the diacritics and everything.

    now we have a ported the project to 2018.3 but still using the old TMPro lib.. it's not super easy to upgrade to 1.3.0 but we'll do soon.. i'll write here the results
     
    SolutionsGameDev and Stephan_B like this.
  3. SolutionsGameDev

    SolutionsGameDev

    Joined:
    Apr 3, 2019
    Posts:
    3
    That would be helpful, thanks :)
     
  4. Keita-kun

    Keita-kun

    Joined:
    Aug 20, 2017
    Posts:
    36
    I used the instruction on your site to make arabic font asset well the result is as always since I found about Text Messh Pro 1.0 "absolute no support for arabic" I don't even know why the author kept the RTL check box? other so called RTL languages can be written then aligned to right not as complexe script language like Arabic where letter connection and other particular stuff comes to play needs to be really processed from right to left not mirrored. Still waiting for a buit in solution for now using basic arabic text display like a dinosaur with RTL TMPro at least user can read it.
    I had high hopes when Unity acquired Text mesh Pro but seems only RTL support offered is for asian languages.:(
     
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Adding full support for OpenType font features which is require to properly support non Latin based languages like those using RTL is still in the plan / in the works.

    I still don't have a firm ETA but I am working in it and it will happen. Until then please take a look at the free RTL plugin.
     
  6. Keita-kun

    Keita-kun

    Joined:
    Aug 20, 2017
    Posts:
    36
    Thanks for your replay, looking forward for it.
     
  7. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Me too :)
     
  8. StefanoCecere

    StefanoCecere

    Joined:
    Jun 10, 2011
    Posts:
    211
    Stephan hi. our Antura game is still using TMPro 1.4 and we developed a custom hack to fix the rendering of diacritics (modifying the xy offsets)
    did you develop a native solution for diacritics in following releases? i could not find anything related

    thank you!
     
  9. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Support for Diacritical Marks will be in the next preview release which will be version 1.6.0 which I would like to have available in the next few weeks.
     
    StefanoCecere likes this.
  10. StefanoCecere

    StefanoCecere

    Joined:
    Jun 10, 2011
    Posts:
    211
    oh thank you! we have to improve the rendering.. but now i'll wait for the native solution :)
    will it still work on unity 2018?
     
  11. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The new Mark to Base and Mark to Mark tables will be available in 2018.4 but will need to be manually populated as the ability to extract the data for these tables from the font file will only be available in 2019.4 or newer and require an updated version of Unity for each.
     
    StefanoCecere likes this.
  12. StefanoCecere

    StefanoCecere

    Joined:
    Jun 10, 2011
    Posts:
    211
    hallo. sorry to ask: any idea if 1.6.0 preview will be available soon? thx
     
  13. Morphus74

    Morphus74

    Joined:
    Jun 12, 2018
    Posts:
    174
    Any update on that? I see that version of TMP that support Mark 2 Mark and Mark 2 Base are in Pre Release, but will that also bring native support for RTL language like arabic?
     
  14. StefanoCecere

    StefanoCecere

    Joined:
    Jun 10, 2011
    Posts:
    211
    hallo @Stephan_B , we updated to 2020 and TMPro 3.2 beta to check the new diacritics system.. it works in the editor, but the runtime seems to be hardcoded to recognize just a few diacritics (so Arabic doesn't work!!)
    how can we go on? thank you

    Code (CSharp):
    1. internal static bool IsDiacriticalMark(uint c)
    2. {
    3.     return c >= 0x300 && c <= 0x36F || c >= 0x1AB0 && c <= 0x1AFF || c >= 0x1DC0 && c <= 0x1DFF || c >= 0x20D0 && c <= 0x20FF || c >= 0xFE20 && c <= 0xFE2F;
    4. }
    5.  
    6. internal static bool IsBaseGlyph(uint c)
    7. {
    8.     return !(c >= 0x300 && c <= 0x36F || c >= 0x1AB0 && c <= 0x1AFF || c >= 0x1DC0 && c <= 0x1DFF || c >= 0x20D0 && c <= 0x20FF || c >= 0xFE20 && c <= 0xFE2F ||
    9.         // Thai
    10.         c == 0xE31 || c >= 0xE34 && c <= 0xE3A || c >= 0xE47 && c <= 0xE4E ||
    11.         // Hebrew
    12.         c >= 0x591 && c <= 0x5BD || c == 0x5BF || c >= 0x5C1 && c <= 0x5C2 || c >= 0x5C4 && c <= 0x5C5 || c == 0x5C7
    13.         );
    14. }