Author Topic: RTL Support in auto line breaks/wrapping  (Read 44054 times)

cdes

  • Newbie
  • *
  • Posts: 15
RTL Support in auto line breaks/wrapping
« on: May 10, 2015, 01:02:12 PM »
Hello,

I'm using Text Mesh Pro with Arabic Support.
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

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: RTL Support in auto line breaks/wrapping
« Reply #1 on: May 11, 2015, 07:14:54 PM »
Hello,

I'm using Text Mesh Pro with Arabic Support.
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.

GrimmGames

  • Newbie
  • *
  • Posts: 2
Re: RTL Support in auto line breaks/wrapping
« Reply #2 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!

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: RTL Support in auto line breaks/wrapping
« Reply #3 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?

cdes

  • Newbie
  • *
  • Posts: 15
Re: RTL Support in auto line breaks/wrapping
« Reply #4 on: July 14, 2015, 04:11:51 PM »
Hello,

I'm using Text Mesh Pro with Arabic Support.
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  :-[ ?

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: RTL Support in auto line breaks/wrapping
« Reply #5 on: July 14, 2015, 04:26:10 PM »
Hello,

I'm using Text Mesh Pro with Arabic Support.
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.
« Last Edit: July 14, 2015, 04:47:39 PM by Stephan B. »

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: RTL Support in auto line breaks/wrapping
« Reply #6 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.


[ Guests cannot view attachments ]

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.

[ Guests cannot view attachments ]

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)?

[ Guests cannot view attachments ]

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

« Last Edit: July 15, 2015, 05:35:21 PM by Stephan B. »

Brain

  • Beta User
  • Full Member
  • *
  • Posts: 128
Re: RTL Support in auto line breaks/wrapping
« Reply #7 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)?

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: RTL Support in auto line breaks/wrapping
« Reply #8 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.

iamsam

  • Newbie
  • *
  • Posts: 6
Re: RTL Support in auto line breaks/wrapping
« Reply #9 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.

iamsam

  • Newbie
  • *
  • Posts: 6
Re: RTL Support in auto line breaks/wrapping
« Reply #10 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.

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: RTL Support in auto line breaks/wrapping
« Reply #11 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.

iamsam

  • Newbie
  • *
  • Posts: 6
Re: RTL Support in auto line breaks/wrapping
« Reply #12 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.

Brain

  • Beta User
  • Full Member
  • *
  • Posts: 128
Re: RTL Support in auto line breaks/wrapping
« Reply #13 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.

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: RTL Support in auto line breaks/wrapping
« Reply #14 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.