Digital Native Studios

TextMeshPro => Feature Requests => Topic started by: cdes on May 10, 2015, 01:02:12 PM

Title: RTL Support in auto line breaks/wrapping
Post by: cdes on May 10, 2015, 01:02:12 PM
Hello,

I'm using Text Mesh Pro with Arabic Support (https://www.assetstore.unity3d.com/en/#!/content/2674).
Everything is working fine.  Except for the "auto line breaks/wrapping".

The problem is, for Arabic Support to work, it has to do 2 things:
1. reverse all the characters.
2. reshape characters with proper ones

(A single character in Arabic has multiple shapes.
1. the isolated shape. (ع)
2. when it comes in the beginning of the word (عـ).
3. when it comes in the middle. (ـعـ)
4. when it comes in the end. (ـع)

As a result of "reversing", the first word is now the last (because Arabic is a Right-to-left language).
When doing "wrap" with the resulted Arabic text, the "first" Arabic word will travel to the next line, breaking the sentence.

I think that if there was a way to just "flip" how the wrapping works... it might solve it.

Thanks

I hope I've explained it thoroughly.

Looking forward for your feedback :D
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Stephan B. on May 11, 2015, 07:14:54 PM
Hello,

I'm using Text Mesh Pro with Arabic Support (https://www.assetstore.unity3d.com/en/#!/content/2674).
Everything is working fine.  Except for the "auto line breaks/wrapping".

The problem is, for Arabic Support to work, it has to do 2 things:
1. reverse all the characters.
2. reshape characters with proper ones

(A single character in Arabic has multiple shapes.
1. the isolated shape. (ع)
2. when it comes in the beginning of the word (عـ).
3. when it comes in the middle. (ـعـ)
4. when it comes in the end. (ـع)

As a result of "reversing", the first word is now the last (because Arabic is a Right-to-left language).
When doing "wrap" with the resulted Arabic text, the "first" Arabic word will travel to the next line, breaking the sentence.

I think that if there was a way to just "flip" how the wrapping works... it might solve it.

Thanks

I hope I've explained it thoroughly.

Looking forward for your feedback :D

Let me give this some thoughts and see if I can come up with some simply way to reverse the wrapping direction.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: GrimmGames on June 09, 2015, 12:42:38 PM
Any word on support for Arabic and other script languages? I am unable to use TMP for my current contract because it includes arabic localization.  Thanks!
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Stephan B. on June 11, 2015, 03:28:00 PM
Any word on support for Arabic and other script languages? I am unable to use TMP for my current contract because it includes arabic localization.  Thanks!

What level of support do you need on Arabic. I am curious if the option posted above with a revised word wrapping could work?
Title: Re: RTL Support in auto line breaks/wrapping
Post by: cdes on July 14, 2015, 04:11:51 PM
Hello,

I'm using Text Mesh Pro with Arabic Support (https://www.assetstore.unity3d.com/en/#!/content/2674).
Everything is working fine.  Except for the "auto line breaks/wrapping".

The problem is, for Arabic Support to work, it has to do 2 things:
1. reverse all the characters.
2. reshape characters with proper ones

(A single character in Arabic has multiple shapes.
1. the isolated shape. (ع)
2. when it comes in the beginning of the word (عـ).
3. when it comes in the middle. (ـعـ)
4. when it comes in the end. (ـع)

As a result of "reversing", the first word is now the last (because Arabic is a Right-to-left language).
When doing "wrap" with the resulted Arabic text, the "first" Arabic word will travel to the next line, breaking the sentence.

I think that if there was a way to just "flip" how the wrapping works... it might solve it.

Thanks

I hope I've explained it thoroughly.

Looking forward for your feedback :D

Let me give this some thoughts and see if I can come up with some simply way to reverse the wrapping direction.

Hey Stephan,

Any news on this issue  :-[ ?
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Stephan B. on July 14, 2015, 04:26:10 PM
Hello,

I'm using Text Mesh Pro with Arabic Support (https://www.assetstore.unity3d.com/en/#!/content/2674).
Everything is working fine.  Except for the "auto line breaks/wrapping".

The problem is, for Arabic Support to work, it has to do 2 things:
1. reverse all the characters.
2. reshape characters with proper ones

(A single character in Arabic has multiple shapes.
1. the isolated shape. (ع)
2. when it comes in the beginning of the word (عـ).
3. when it comes in the middle. (ـعـ)
4. when it comes in the end. (ـع)

As a result of "reversing", the first word is now the last (because Arabic is a Right-to-left language).
When doing "wrap" with the resulted Arabic text, the "first" Arabic word will travel to the next line, breaking the sentence.

I think that if there was a way to just "flip" how the wrapping works... it might solve it.

Thanks

I hope I've explained it thoroughly.

Looking forward for your feedback :D

Let me give this some thoughts and see if I can come up with some simply way to reverse the wrapping direction.

Hey Stephan,

Any news on this issue  :-[ ?

I don't have an update for you yet but this is high on my priority list.

Edit - I'll put aside what I was planning on working on tomorrow and see if I can come up with something.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Stephan B. on July 15, 2015, 03:56:57 PM
I am going to need some input on how best to implement support for Right to Left. It looks like there are a few ways this could be implemented.

1. I can modify the text component to layout the text Right to Left. So as you type each character, they flow right to left and word wrapping works as expected. However, given the Unity text input box is left to right, the text in it for Right to Left languages is backwards. If you only paid attention to the text output on screen, this would behave as expected (minus) potential character substitution rules.


[attachimg=1 width=1024]

2. Alternatively, the Arabic Support plugin could be used which re-formats the text where you can read it in the text input box however, this makes parsing the text and doing layout and warping more complex since the characters in the string are not sequential. Ie. the first character in the string is the last character of the first line and as more lines are displayed and wrapping needs to occur this gets more complex.

It seems to me that method 1 where the characters are entered right to left and flow naturally along with wrapping is the better choice. It seems like implementing some editor script that flips the text in the text input box to mirror the Right to Left while keeping the source input intact might be a better choice.

Update - Just for testing I added a Text Box showing the Source text reversed.

[attachimg=2 width=512]

This means that text input filtering for character substitution would also have to be implemented.

What do you guys think?

Can you provide me with a few short lines and sentences and text to work with? I would like to be able to copy paste those. Please also include some visual references.


Update 2 I guess I could use the Right to Left Text Input Box to make it possible to paste text from the Arabic Support plugin. Since this plugin expects the layout to be done Left to Right and reverses the text, I would have to re-reverse his text. Do you know if there is a way to get the text from this plugin not reversed (ie. Right to left sequence)?

[attachimg=3 width=1024]

Bottom image is from the Arabic Support plugin, Top is in TextMesh Pro and word wrapped.

(https://lh3.googleusercontent.com/FqS-EBxpUncJjs2EeoXuwMSsCyj0zgnL12XXBtUbDcY=w1280-h348-no)
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Brain on July 31, 2015, 02:31:59 AM
I too am going to be needing Arabic support soon. Any developments on this or are you still waiting for user examples (I don't have any yet, just wondering how it's going)?
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Stephan B. on July 31, 2015, 02:43:17 AM
I too am going to be needing Arabic support soon. Any developments on this or are you still waiting for user examples (I don't have any yet, just wondering how it's going)?

Been waiting for user feedback and examples.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: iamsam on August 16, 2015, 09:45:32 PM
Hey,

I may be able to help as I am currently using it extensively for Right to Left languages. I am using an asset from the store (Raymon RTL) to get the letters in the correct order and then use them with TextMeshProUGUI Text. However I am currently limited to a single line of text (I could do multiple lines using REGEX expressions but it became too complicated). I am using beta2.2, is the functionality shown about included in it? If not would it be possible to get a beta version so that I can provide feedback on how it holds up.

Thanks.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: iamsam on August 16, 2015, 09:51:11 PM
I forgot to mention, in case you cannot yet provide the beta, I can send you some examples in an excel sheet too.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Stephan B. on August 16, 2015, 11:29:33 PM
Hey,

I may be able to help as I am currently using it extensively for Right to Left languages. I am using an asset from the store (Raymon RTL) to get the letters in the correct order and then use them with TextMeshProUGUI Text. However I am currently limited to a single line of text (I could do multiple lines using REGEX expressions but it became too complicated). I am using beta2.2, is the functionality shown about included in it? If not would it be possible to get a beta version so that I can provide feedback on how it holds up.

Thanks.

The functionality shown here is in Beta 2.2 but only available in the normal TMP component (since I am still working on this (real alpha stuff)). Left, Center and Right alignment should work but justified doesn't yet.

Once you enable RTL in the inspector panel, the two input box will show up. You can input text in either of them as well as copy / paste. I don't know if that is workable but going back and forth does kind of allow to use LTR text as well as RTL in the same text (I think).

Anyway, give this a shot and please provide example of correct short samples of text. Like I said, I can't read any of the RTL languages so it is really hard to test lol.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: iamsam on August 17, 2015, 04:39:51 AM

Anyway, give this a shot and please provide example of correct short samples of text. Like I said, I can't read any of the RTL languages so it is really hard to test lol.

Incredibly outstanding work, it performs amazingly well!!  :) I threw everything I had at it and it passed every test. I will try and post a few screenshots by the end of the day. How long would it take to incorporate this in the UGUI component, this is really a game changer for us.

The only thing I found is that the ASCII code corresponding to the character you want to print must be there in the font created or else it adds a few extra spaces and the alignment gets jumbled up. So for example if you have a "-" in there and you did not incorporate it in your font, the whole alignment after the "-" part shifts (I believe it left aligns itself, however I have not yet extensively tested this bug). I can also post the list of ASCII codes if anyone is interested.

Thanks for this incredible asset.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Brain on August 17, 2015, 08:13:25 AM
What about rich text tags and mixed RTL and LTR text (like Arabic with a HTML link or a Latin name in the middle), will those work? Do I need to use the Unicode LTR and RTL marks or is that handled automatically?

I didn't update to Beta 2.2 and only quickly checked out the Arabic Support plugin with Unity 5.1.2p3 to notice that the demo scenes of that asset were quite broken.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Stephan B. on August 17, 2015, 12:28:27 PM
What about rich text tags and mixed RTL and LTR text (like Arabic with a HTML link or a Latin name in the middle), will those work? Do I need to use the Unicode LTR and RTL marks or is that handled automatically?

I didn't update to Beta 2.2 and only quickly checked out the Arabic Support plugin with Unity 5.1.2p3 to notice that the demo scenes of that asset were quite broken.

I think in the editor, you'll be able to handle the mixed types. However, in a string you would have to handle the reformatting (reversing) yourself. That is until I get around to having this handled automatically.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: iamsam on August 21, 2015, 07:01:06 PM
How do we access the RTL function through script? If I enable it in the editor, does it enable the corresponding method in code? It would be great if you could let me know an ETA on the beta that incorporates this in code and UGUI component. From my testing this is really working well, so you could include it as is in the next beta. If I can test it using scripts it will help me see how it holds up as most of my text is using localization from scripts and I rarely use the editor to set the text.

Thanks again for this amazing asset.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Stephan B. on August 21, 2015, 10:05:37 PM
How do we access the RTL function through script? If I enable it in the editor, does it enable the corresponding method in code? It would be great if you could let me know an ETA on the beta that incorporates this in code and UGUI component. From my testing this is really working well, so you could include it as is in the next beta. If I can test it using scripts it will help me see how it holds up as most of my text is using localization from scripts and I rarely use the editor to set the text.

Thanks again for this amazing asset.

I would love to get a bunch of test strings / sentences showing me how they are suppose to look with proper word wrapping and line breaking. I need strings / text that I can copy paste to compare. It really sucks not to be able to read certain languages for testing.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Brain on August 22, 2015, 07:55:36 AM
Could you just test with whatever sentences you can find from the web and compare to how the browser renders them? For example http://www.omniglot.com/language/phrases/arabic.php (dragging the window smaller lets you see them on multiple lines).

Edit: My use case will be 100% through scripts (translations), gonna need to use Arabic in maybe 2-3 months.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: iamsam on August 22, 2015, 12:22:47 PM
I would love to get a bunch of test strings / sentences showing me how they are suppose to look with proper word wrapping and line breaking. I need strings / text that I can copy paste to compare. It really sucks not to be able to read certain languages for testing.

Sure Stephan, I can send you two or three sentences along with screenshots in Unity, is there a way I can IM you here? I am currently on a trip and don't have access to Unity so will message them to you tomorrow.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Stephan B. on August 22, 2015, 01:14:17 PM
I would love to get a bunch of test strings / sentences showing me how they are suppose to look with proper word wrapping and line breaking. I need strings / text that I can copy paste to compare. It really sucks not to be able to read certain languages for testing.

Sure Stephan, I can send you two or three sentences along with screenshots in Unity, is there a way I can IM you here? I am currently on a trip and don't have access to Unity so will message them to you tomorrow.

You can PM me here or just email the Support@DigitalNativeStudios.com
Title: Re: RTL Support in auto line breaks/wrapping
Post by: iamsam on August 22, 2015, 02:03:46 PM
Thanks  :). Sent you PM, let me know if you need ASCII codes for those letters.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Brain on September 07, 2015, 02:31:32 AM
Any progress on this?

I was also thinking if there should/could be some automated way to change left aligned text to right aligned string when using RTL strings since my case will be shared scenes and prefabs with dynamically localized strings.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Stephan B. on September 07, 2015, 02:37:41 AM
Any progress on this?

I was also thinking if there should/could be some automated way to change left aligned text to right aligned string when using RTL strings since my case will be shared scenes and prefabs with dynamically localized strings.

I haven't had time to revisit the RTL support since I am working on the Multi Font & Material support.

In terms of changing the alignment automatically, I think it would be safer to manually select the appropriate alignment or use the <align=right> tag in the localized strings. That way you can set and be certain the alignment is correct for any given string.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Brain on September 07, 2015, 05:49:40 AM
I was reading about the ICU BiDi implementation and the way they do things is that there's global text direction flag that can be overridden. There are Unicode BiDi characters to mark the text direction, but I guess tags like <dir=RTL> would work better with TMP.

Anyway, I think a global flag for a project is important, since then you'd have to only add tags to LTR text parts instead of everything, if a project is mostly using RTL. It should then be easy for me to add custom code to change the alignment too.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Brain on September 30, 2015, 02:09:21 AM
I know you're busy since Unity 5.2 is such a hot mess, but do you have an idea when you'll have time to work on this? I will be needing RTL support in early-mid November both for regular objects and UI. I can hack around stuff if necessary and am also willing help in any way I can. I won't need any of the extra stuff I've suggested at that point - just working RTL text objects (with script access).
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Stephan B. on September 30, 2015, 02:55:23 PM
I know you're busy since Unity 5.2 is such a hot mess, but do you have an idea when you'll have time to work on this? I will be needing RTL support in early-mid November both for regular objects and UI. I can hack around stuff if necessary and am also willing help in any way I can. I won't need any of the extra stuff I've suggested at that point - just working RTL text objects (with script access).

I am hoping the Unity 5.2 patch on Friday will address the remaining masking issues. If that is the case, I'll be able to resume working on new features.

Have you played with the current RTL implementation using the normal TextMeshPro component?
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Brain on October 01, 2015, 02:08:39 AM
I've tried it out with 0.1.5 Beta 2.2. and Unity 5.1.3. Used the RTL support asset too and with some manual fiddling the Arabic text displays properly as far as I can see (I have a JPG of the text as a comparison). Copy pasting the processed string to a UI TMP object also works. Mixed LTR/RTL in a text is problematic, but maybe I won't need that.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: daterre on February 10, 2016, 03:58:21 AM
Hi,

2 questions:
1. Does the RTL beta work for the UGUI component as well?
2.Is a version of the RTL beta for Unity 4.7 or 5.2+, I'd be happy to provide some feedback, I need it for Hebrew which I believe is more straightforward than Arabic.

Thanks!
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Stephan B. on February 10, 2016, 12:28:01 PM
Hi,

2 questions:
1. Does the RTL beta work for the UGUI component as well?
2.Is a version of the RTL beta for Unity 4.7 or 5.2+, I'd be happy to provide some feedback, I need it for Hebrew which I believe is more straightforward than Arabic.

Thanks!

RTL will be available for both text components in the next release for Unity 5.0 ~ 5.1 and Unity 5.2 ~ 5.4.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: ARafay on March 24, 2016, 05:01:13 AM
I am going to need some input on how best to implement support for Right to Left. It looks like there are a few ways this could be implemented.

1. I can modify the text component to layout the text Right to Left. So as you type each character, they flow right to left and word wrapping works as expected. However, given the Unity text input box is left to right, the text in it for Right to Left languages is backwards. If you only paid attention to the text output on screen, this would behave as expected (minus) potential character substitution rules.


(Attachment Link)

2. Alternatively, the Arabic Support plugin could be used which re-formats the text where you can read it in the text input box however, this makes parsing the text and doing layout and warping more complex since the characters in the string are not sequential. Ie. the first character in the string is the last character of the first line and as more lines are displayed and wrapping needs to occur this gets more complex.

It seems to me that method 1 where the characters are entered right to left and flow naturally along with wrapping is the better choice. It seems like implementing some editor script that flips the text in the text input box to mirror the Right to Left while keeping the source input intact might be a better choice.

Update - Just for testing I added a Text Box showing the Source text reversed.

(Attachment Link)

This means that text input filtering for character substitution would also have to be implemented.

What do you guys think?

Can you provide me with a few short lines and sentences and text to work with? I would like to be able to copy paste those. Please also include some visual references.


Update 2 I guess I could use the Right to Left Text Input Box to make it possible to paste text from the Arabic Support plugin. Since this plugin expects the layout to be done Left to Right and reverses the text, I would have to re-reverse his text. Do you know if there is a way to get the text from this plugin not reversed (ie. Right to left sequence)?

(Attachment Link)

Bottom image is from the Arabic Support plugin, Top is in TextMesh Pro and word wrapped.

(https://lh3.googleusercontent.com/FqS-EBxpUncJjs2EeoXuwMSsCyj0zgnL12XXBtUbDcY=w1280-h348-no)

Hi Stephan,

Can you please tell me how did you generate this Arabic Text?
- What font and Range did you use to generate font asset
- In short, how can i achieve same thing?
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Stephan B. on March 24, 2016, 12:05:41 PM
I can't remember the font but the Arabic character set is from Unicode Range (Hex) 600-6FF, 750-77F. For simple test if often use the Custom Characters option and copy paste them in the editor window.

Here is an example of the settings I used with Arial. Notice how Arial is missing several glyphs for Arabic.
[attachimg=1]
Title: Re: RTL Support in auto line breaks/wrapping
Post by: ARafay on March 24, 2016, 12:38:01 PM
Thanks to you im able to create font asset with arabic letters, now when i try to render a text it gets broken unlike your example which has complete words in it. Can you please guide here
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Stephan B. on March 24, 2016, 01:21:42 PM
Thanks to you im able to create font asset with arabic letters, now when i try to render a text it gets broken unlike your example which has complete words in it. Can you please guide here

Can you post examples of what you have? Since I am not fluent with Arabic, i need you to provide an example of what you have vs how it should be to be correct.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: ARafay on March 24, 2016, 01:42:09 PM
Same here, Arabic is not my language as well.
But this image shows a working example and thats what i need.

Can you please find it or recreate it as unity project and share?
(https://lh3.googleusercontent.com/FqS-EBxpUncJjs2EeoXuwMSsCyj0zgnL12XXBtUbDcY=w1280-h348-no)
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Stephan B. on March 24, 2016, 04:17:04 PM
If I recall correctly, I used this free asset which converts the text correctly since Unity's editor has issues. https://www.assetstore.unity3d.com/en/#!/content/2674

With this tool, I would copy the text from the internet and paste it into their Fix3D Text input. This would return a new string in the TextMesh editor. I would grab this new text and copy / paste in the lower Text Input Box of TextMesh Pro when RTL is enabled. I guess this is all needed to handle character substitution. Since this only involves altering the source text from the original text to this other format perhaps a TMP user fluent in the language could provide a script to handle this in a simpler manner. I also possibly could integrate that into TMP when RTL is selected.

Seems like the range for characters is larger than what I previously posted. Here is the latest range which includes all the Arabic characters. See https://en.wikipedia.org/wiki/Arabic_script_in_Unicode

New range 600-6FF,750-77F,8A0-8FF,FB50-FDFF,FE70-FEFF,10E60-10E7F,1EE00-1EEFF

Keep in mind that most fonts do not contain all or even most of those characters. ARIAL for instance only contains 540 of the potential 1520 characters.

(http://i.imgur.com/RMSUqLq.png)

This is a 1024 X 1024 with decent sampling point size of 61. I guess I could have increased the size to 2048 X 1024 and added the ASCII set plug punctuation in there too or simply use a ARIAL as Fallback which would be fine too.

Using this new font asset and process outlined above, I grabbed some text from the BBC sports page. Something about Soccer and here are the results.

(http://i.imgur.com/8I6LOOB.png)
Title: Re: RTL Support in auto line breaks/wrapping
Post by: ARafay on March 25, 2016, 03:34:20 AM
Thanks, you are awesome :)

how can i set text programmatically? as now 2 text boxes appear when i set RTL enabled.
Should i simply use .text property of TMPUGUI?
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Stephan B. on March 25, 2016, 04:06:57 AM
You will need to use the API of that Arabic tool until I incorporate similar functionality in TMP.

Code: [Select]
void Start()
{
     TMP_Text obj = GetComponent<TMP_Text>();
     obj.text = ArabicSupport.ArabicFixer.Fix("فَتَعَالَى اللَّهُ الْمَلِكُ الْحَقُّ ۗ وَلَا تَعْجَلْ بِالْقُرْآنِ مِن قَبْلِ أَن يُقْضَىٰ إِلَيْكَ وَحْيُهُ ۖ وَقُل رَّبِّ زِدْنِي عِلْمًا ", true, true);
}

Make sure RTL is enabled and I believe the text might end up backwards but if you take the string and reverse it, it should work correctly. I simply forgot about the API part of this.

I'll work on this tomorrow as I now have another user who is fluent in Arabic who can provide feedback to make sure the is correct.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: ARafay on March 26, 2016, 11:04:39 PM
You will need to use the API of that Arabic tool until I incorporate similar functionality in TMP.

Code: [Select]
void Start()
{
     TMP_Text obj = GetComponent<TMP_Text>();
     obj.text = ArabicSupport.ArabicFixer.Fix("فَتَعَالَى اللَّهُ الْمَلِكُ الْحَقُّ ۗ وَلَا تَعْجَلْ بِالْقُرْآنِ مِن قَبْلِ أَن يُقْضَىٰ إِلَيْكَ وَحْيُهُ ۖ وَقُل رَّبِّ زِدْنِي عِلْمًا ", true, true);
}

Make sure RTL is enabled and I believe the text might end up backwards but if you take the string and reverse it, it should work correctly. I simply forgot about the API part of this.

I'll work on this tomorrow as I now have another user who is fluent in Arabic who can provide feedback to make sure the is correct.


Awesome, i know you are already busy with TextInput so what we can do is make progress using that other asset for text reversing etc while you spare some time to render that text fine (which is already rendering fine in your example). I just started and let you know result soon. Meanwhile can you please invite other user here and ask what Arabic font should we use which will have all the elements.


EDIT
Text is working AMAZINGLY fine, Thanks Man :D
Now all i need to know where we can find fonts which support all the arabic unicode characters (no more missing characters issue)
Title: Re: RTL Support in auto line breaks/wrapping
Post by: ARafay on March 27, 2016, 01:04:41 AM
Just wanted to Say Thank You once again:)
Cant wait for Input Component that support export/import in HTML
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Stephan B. on March 28, 2016, 11:54:22 PM
Since I never added a property for RTL, one will need to be added.

First, you will need to modify the TMP_Text.cs file to add the new isRightToLeft property. I added this right below the text property.

Code: C#
  1. /// <summary>
  2. ///
  3. /// </summary>
  4. public bool isRightToLeftText
  5. {
  6.     get { return m_isRightToLeft; }
  7.     set { if (m_isRightToLeft == value) return; m_isRightToLeft = value; m_havePropertiesChanged = true; m_isCalculateSizeRequired = true; m_isInputParsingRequired = true; SetVerticesDirty(); SetLayoutDirty(); }
  8. }
  9. [SerializeField]
  10. protected bool m_isRightToLeft = false;
  11.  

Next, since the m_isRightToLeft field already exists so you will have to remove the duplicate declaration.

Lastly, create the following script and attached it to either type of TextMeshPro object.

Code: [Select]
using UnityEngine;
using System.Collections;
using TMPro;


public class SandBox_12 : MonoBehaviour {

    void Start()
    {
        TMP_Text textComponent = GetComponent<TMP_Text>();
        textComponent.isRightToLeftText = true;
        textComponent.alignment = TextAlignmentOptions.TopRight;

        string sourceText = ArabicSupport.ArabicFixer.Fix("فَتَعَالَى اللَّهُ الْمَلِكُ الْحَقُّ ۗ وَلَا تَعْجَلْ بِالْقُرْآنِ مِن قَبْلِ أَن يُقْضَىٰ إِلَيْكَ وَحْيُهُ ۖ وَقُل رَّبِّ زِدْنِي عِلْمًا ", true, true);

        textComponent.text = ReverseText(sourceText);
    }



    string ReverseText(string source)
    {
        char[] output = new char[source.Length];
        for (int i = 0; i < source.Length; i++)
        {
            output[(output.Length - 1) - i] = source[i];
        }
        return new string(output);
    }
}

Let me know if this works. This is a rough solution to allow you to get some text going.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: ARafay on March 29, 2016, 12:52:32 AM
Thanks :), thats what i needed. You Rock
Title: Re: RTL Support in auto line breaks/wrapping
Post by: ARafay on April 16, 2016, 08:41:34 AM
Hi Steph,

For now Arabic support is working fine however there is only one issue remaining that require your attension,

Arabic character http://unicode.scarfboy.com/?s=U%2B0622 is not rendered properly because TextMesh doesnt know where to place that extra character on/over "I" like shape.

When i try to render this text
آم

it doesnt appear. Can you please take a look
Title: Re: RTL Support in auto line breaks/wrapping
Post by: ARafay on April 17, 2016, 04:59:30 AM
BUMP
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Stephan B. on April 17, 2016, 08:05:37 AM
I'll take a look later today and let you know what I find.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: ARafay on April 18, 2016, 04:21:28 AM
I'll take a look later today and let you know what I find.

Any update?
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Stephan B. on April 18, 2016, 02:25:00 PM
I'll take a look later today and let you know what I find.

Any update?

I am still trying to get to this. Will give you an update today regardless.

Update
Is this how it is suppose to appear?
(http://i.imgur.com/9X0If1M.png)
Title: Re: RTL Support in auto line breaks/wrapping
Post by: ARafay on April 18, 2016, 10:45:17 PM
I'll take a look later today and let you know what I find.

Any update?

I am still trying to get to this. Will give you an update today regardless.




Update
Is this how it is suppose to appear?
(http://i.imgur.com/9X0If1M.png)

Yes, thats what i want.
I think you have solved it [almost], now i dont know if its Font issue or not, but usually that Sine shape come with same gap over I shape.
In your example, its just sitting on top of I shape without any gap.
It should appear like this
http://baask.com/sayadganj/img/alif_mad_aa.gif

BUT again, im not sure if its font issue or not.


Secondly can you please tell me which font and which Hex Character Range you used to display it? So i'm able to show it atleast.

Thanks
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Stephan B. on April 18, 2016, 11:55:11 PM
I used the following string with the ARIAL font with the character ranges below.

Code: C#
  1. string sourceText = ArabicSupport.ArabicFixer.Fix("&#1575;&#1619;&#1605;", true, true);
  2.  

600-603,60B-615,61B,61E-61F,621-63A,640-65E,660-6FF,750-76D,FB50-FBB1,FBD3-FBE9,FBFC-FBFF,FC5E-FC62,FD3E-FD3F,FDF2,FDFC,FE80-FEFC

Title: Re: RTL Support in auto line breaks/wrapping
Post by: ARafay on April 19, 2016, 12:32:00 AM
I used the following string with the ARIAL font with the character ranges below.

Code: C#
  1. string sourceText = ArabicSupport.ArabicFixer.Fix("&#1575;&#1619;&#1605;", true, true);
  2.  

600-603,60B-615,61B,61E-61F,621-63A,640-65E,660-6FF,750-76D,FB50-FBB1,FBD3-FBE9,FBFC-FBFF,FC5E-FC62,FD3E-FD3F,FDF2,FDFC,FE80-FEFC


You are AWESOME, its working fine on my side.
Can you please tell me from where you got that range? Because i was using following range
0600-06FF,0750-077F,08A0-08FF,FB50-FDFF,FE70-FEFF,10E60-10E7F,1EE00-1EEFF
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Stephan B. on April 19, 2016, 12:39:51 AM
I used the following string with the ARIAL font with the character ranges below.

Code: C#
  1. string sourceText = ArabicSupport.ArabicFixer.Fix("&#1575;&#1619;&#1605;", true, true);
  2.  

600-603,60B-615,61B,61E-61F,621-63A,640-65E,660-6FF,750-76D,FB50-FBB1,FBD3-FBE9,FBFC-FBFF,FC5E-FC62,FD3E-FD3F,FDF2,FDFC,FE80-FEFC


You are AWESOME, its working fine on my side.
Can you please tell me from where you got that range? Because i was using following range
0600-06FF,0750-077F,08A0-08FF,FB50-FDFF,FE70-FEFF,10E60-10E7F,1EE00-1EEFF

The initial range was done by taking a look at the ranges for Arabic from the unicode chart available at unicode.org (which appears to be down for me). Maybe the font you were using was missing those characters as you range appears to be the same.

The ranges I posted came from pulling the characters from my previously generated font asset using the soon to be released new feature I added yesterday http://digitalnativestudios.com/forum/index.php?topic=863.msg7861#msg7861

Title: Re: RTL Support in auto line breaks/wrapping
Post by: ARafay on April 19, 2016, 01:33:15 AM
I used the following string with the ARIAL font with the character ranges below.

Code: C#
  1. string sourceText = ArabicSupport.ArabicFixer.Fix("&#1575;&#1619;&#1605;", true, true);
  2.  

600-603,60B-615,61B,61E-61F,621-63A,640-65E,660-6FF,750-76D,FB50-FBB1,FBD3-FBE9,FBFC-FBFF,FC5E-FC62,FD3E-FD3F,FDF2,FDFC,FE80-FEFC


You are AWESOME, its working fine on my side.
Can you please tell me from where you got that range? Because i was using following range
0600-06FF,0750-077F,08A0-08FF,FB50-FDFF,FE70-FEFF,10E60-10E7F,1EE00-1EEFF

The initial range was done by taking a look at the ranges for Arabic from the unicode chart available at unicode.org (which appears to be down for me). Maybe the font you were using was missing those characters as you range appears to be the same.

The ranges I posted came from pulling the characters from my previously generated font asset using the soon to be released new feature I added yesterday http://digitalnativestudios.com/forum/index.php?topic=863.msg7861#msg7861

I'll have to use 2 fonts to cover all the characters (nice timing for Fallback Fonts)

Now i have another feature request. Currently i can either render RTL or LTR. I cant use both.
Can you please introduce a tag support or something like that where i can do something

"english sentence is starting and its meaning is <rtl>long arabic word which render perfectly when it become multiline</rtl> and then remaining english text"

This is i guess the last step for it to work completely fine.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Stephan B. on April 19, 2016, 02:16:22 AM
I used the following string with the ARIAL font with the character ranges below.

Code: C#
  1. string sourceText = ArabicSupport.ArabicFixer.Fix("&#1575;&#1619;&#1605;", true, true);
  2.  

600-603,60B-615,61B,61E-61F,621-63A,640-65E,660-6FF,750-76D,FB50-FBB1,FBD3-FBE9,FBFC-FBFF,FC5E-FC62,FD3E-FD3F,FDF2,FDFC,FE80-FEFC


You are AWESOME, its working fine on my side.
Can you please tell me from where you got that range? Because i was using following range
0600-06FF,0750-077F,08A0-08FF,FB50-FDFF,FE70-FEFF,10E60-10E7F,1EE00-1EEFF

The initial range was done by taking a look at the ranges for Arabic from the unicode chart available at unicode.org (which appears to be down for me). Maybe the font you were using was missing those characters as you range appears to be the same.

The ranges I posted came from pulling the characters from my previously generated font asset using the soon to be released new feature I added yesterday http://digitalnativestudios.com/forum/index.php?topic=863.msg7861#msg7861

I'll have to use 2 fonts to cover all the characters (nice timing for Fallback Fonts)

Now i have another feature request. Currently i can either render RTL or LTR. I cant use both.
Can you please introduce a tag support or something like that where i can do something

"english sentence is starting and its meaning is <rtl>long arabic word which render perfectly when it become multiline</rtl> and then remaining english text"

This is i guess the last step for it to work completely fine.

That is definitely something that I plan on supporting although potentially tricky to implement. No ETA yet on when I can work on this but certainly on the list.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: ARafay on April 19, 2016, 11:10:20 PM
That is definitely something that I plan on supporting although potentially tricky to implement. No ETA yet on when I can work on this but certainly on the list.

Please consider it on your top 5 list ;)
This is the only remaining piece of puzzle thats not allowing us to launch the app.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: MAG on April 19, 2016, 11:13:07 PM
I'm waiting as well  and keeping my eyes on this thread  :D
+1  8)
Title: Re: RTL Support in auto line breaks/wrapping
Post by: MirzaBeig on May 10, 2016, 10:47:24 PM
Just wanted to say how awesome the support is for this asset. I had some trouble (I was really out of the loop) on rendering Arabic along with the transliteration and Stephan helped me out really quick with that.

The conversation was on the Unity forums, and for future reference, starts from this post onward:

http://forum.unity3d.com/threads/text-mesh-pro-the-ultimate-text-solution-for-unity-powerful-flexible-advanced-text-rendering.248636/page-21#post-2629815
Title: Re: RTL Support in auto line breaks/wrapping
Post by: jvo on July 08, 2016, 02:44:16 AM
Like we talked about on the Unity forum, I'm trying to get some justified Arabic to look correctly. Working with Release 0.1.54 Beta 3b and I made the adjustments to the TMPro_Private and TMPro_UGUI_Private scripts to enable right aligning the last line of a justified block if RTL is enabled. It seems however that m_isRightToLeft is never true and I'm unable to find it as setting in the editor. The project also uses TMP to show justified English text, so just hardwiring m_isRightToLeft to true doesn't provide an easy fix.

I'm using a different plugin to fix the arabic by the way, RTL Plugin. (Because this plugin can also add line breaks, so it works with text display that doesn't handle RTL text.) But that should make no difference. I have things justified now, but the last line is still left aligned.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Stephan B. on July 08, 2016, 04:06:44 AM
Like we talked about on the Unity forum, I'm trying to get some justified Arabic to look correctly. Working with Release 0.1.54 Beta 3b and I made the adjustments to the TMPro_Private and TMPro_UGUI_Private scripts to enable right aligning the last line of a justified block if RTL is enabled. It seems however that m_isRightToLeft is never true and I'm unable to find it as setting in the editor. The project also uses TMP to show justified English text, so just hardwiring m_isRightToLeft to true doesn't provide an easy fix.

I'm using a different plugin to fix the arabic by the way, RTL Plugin. (Because this plugin can also add line breaks, so it works with text display that doesn't handle RTL text.) But that should make no difference. I have things justified now, but the last line is still left aligned.

The enable RTL via script, you have to use the isRightToLeftText property as follows:

Code: C#
  1. textComponent.isRightToLeftText = true;
Title: Re: RTL Support in auto line breaks/wrapping
Post by: jvo on July 08, 2016, 07:52:45 AM
Ah, so that's why I didn't see it in the editor. Better, but it seems the RTL plugin I use already reverses the characters sentence by sentence, so that doesn't work.

I'll try the other Arabic fixer plugin. Ok, that works better. If I have newlines in there though, it also reverses the paragraphs, so I had to update the ReverseText method a bit to maintain the paragraph order:

private string ReverseText (string source)
{
   char [] split = { '\n' };
   string [] paragraphs = source.Split(split);
   string result = "";
   foreach (string paragraph in paragraphs)
   {
      char [] output = new char [paragraph.Length];
      for (int i = 0; i < paragraph.Length; i++)
      {
         output [(output.Length - 1) - i] = paragraph ;
      }
      result += new string (output);
      result += "\n";
   }
   return result;
}

And then I used it like:

string convertedText = ReverseText(ArabicSupport.ArabicFixer.Fix (inputText));
textPro.isRightToLeftText = true;
textPro.text = convertedText;
Title: Re: RTL Support in auto line breaks/wrapping
Post by: tosiabunio on December 06, 2017, 12:07:08 PM
What is the current status of mixed RTL/LTR texts? I'm facing my Farsi localization and I don't see how I could that. All 11 localizations (including Russian, Japanese, Chinese and Korean) so far have been done with rich text tags only which helped me a lot as I didn't have to change anything with TMP components. I don't see any tags related to RTL and mixed directions.
Title: Re: RTL Support in auto line breaks/wrapping
Post by: Stephan B. on December 06, 2017, 01:36:09 PM
What is the current status of mixed RTL/LTR texts? I'm facing my Farsi localization and I don't see how I could that. All 11 localizations (including Russian, Japanese, Chinese and Korean) so far have been done with rich text tags only which helped me a lot as I didn't have to change anything with TMP components. I don't see any tags related to RTL and mixed directions.

Support for bidirectional text (BIDI) is not currently supported.

This is planned for the new text system / integrated version of TMP. I don't have an ETA yet on this.

P.S. As I have stated before, if there are opportunities to add some of the new functionality into TMP before the release of the new system, I will certainly consider it.