Bug fix for TextMesh pro and RTL

More
2 years 5 months ago - 2 years 5 months ago #2139 by mcmorry
Hi,

I found and fixed a bug connected with Text Mesh Pro and Arabic text.
Wen Text Mesh Pro try to wrap an RTL fails if the isRightToLeftText property is not set.
What I did to resolve it, was to change inside the LocalizeTextMeshPro file, the two methods DoLocalize_TMPLabel and DoLocalize_TMPUGUILabel.

After setting the alignment I also set the isRightToLeftText property of TMP.
The issue is that after doing this TMP expects to receive the text reversed. I don't know why, but I found this solution in his forum: forum post

Here is the code for the two metods:
mTarget_TMPLabel.alignment = LocalizationManager.IsRight2Left ? mAlignmentTMPro_RTL : mAlignmentTMPro_LTR;
mTarget_TMPLabel.isRightToLeftText = LocalizationManager.IsRight2Left;
if (LocalizationManager.IsRight2Left) MainTranslation = ReverseText(MainTranslation);

I also added somewhere in the file the ReverseText method:
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 you foresee some issue after this change and if you can integrate it in next versions.
Last edit: 2 years 5 months ago by mcmorry.

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

More
2 years 5 months ago #2140 by Frank
Hi,
Thanks a lot for finding a solution to this.
I verified it and added the fix to v2.6.11b4, which is now in the beta folder.

Thanks!
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out
The following user(s) said Thank You: mcmorry

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

Time to create page: 0.153 seconds
Template by JoomlaShine