Using line break in RTL languages rendered the lines backwards

More
1 month 1 week ago #4174 by Shirly7
Hi,

I'm using TextMeshPro objects for my texts. I've added a term with translation that has line breaks.
The Hebrew (RTL language) translations is as follows:
אני שורה 1
אני שורה 2
אני שורה 3

But, it renders the lines in the wrong order (last to first) - see attached image:


Regular Text object (not TextMeshPro) seems to work fine.

Are you aware of this issue? or am I doing something wrong?

Thanks,
Shirly
Attachments:

Please Log in or Create an account to join the conversation.

More
1 month 3 days ago #4176 by Lavi
Hi,

I have found the problem, when you reverse the final text to RTL you don't consider '\n'.

I changed ReverseText() to this and it seems to be working.

public static string ReverseLine(string line)
{
var len = line.Length;
var output = new char[len];
for (var i = 0; i < len; i++)
{
output[(len - 1) - i] = line;
}
return new string(output);
}

public static string ReverseText(string source)
{
var len = source.Length;
var outputString = "";
string[] stringSeparators = new string[] { Environment.NewLine };
string[] strSplit = source.Split(stringSeparators, StringSplitOptions.None);
foreach (var line in strSplit)
{
outputString += ReverseLine(line) + Environment.NewLine;
}
return outputString.Remove(len);
}

Please Log in or Create an account to join the conversation.

Time to create page: 0.157 seconds
Template by JoomlaShine