Font localization problem NGUI/Asian

More
8 years 8 months ago - 8 years 8 months ago #930 by cedtat
Hello,

I have found a weird problem using I2.

When I use NGUI, I sometimes need to add color parameters at the beginning of the localized sentence like in english "[279ad7]Entercode" or in Thaï "[279ad7]ใส่รหัสที่"

On PC and Android, no problem, but on iOS, it seems to use my default font and not the localized font.
If I remove the color code [279ad7] at the beginning of the sentence, no problem, the correct font is used.

Is there any particular reason it won't use the font provided in localize component secondary tab ? I was wondering if you have some code trying to detect the font ?

Thank you,
Cedric
Last edit: 8 years 8 months ago by cedtat.

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

More
8 years 8 months ago #932 by Frank
Hi,
Yes, the plugin allows to override the font used by placing its name at the beginning of the text.
e.g. "[ARIAL] This is a text"

The problem is that it was not detecting that [279ad7] was not a valid secondary translation and that instead is meant to be part of the primary text.

I modified the code to allow overriding the secondary translation, only if the override is a valid one.
The change is part of 2.6.0 b6.

If you want to modify your copy without upgrading to the latest beta, you just need to replace the function GetSecondaryTranslatedObj in file Localize.cs line 279
by this two functions:
		T GetSecondaryTranslatedObj<T>( ref string MainTranslation, ref string SecondaryTranslation ) where T: Object
		{
			//--[ Allow main translation to override Secondary ]-------------------
			string secondary = null;
			DeserializeTranslation(MainTranslation, out MainTranslation, out secondary);

			T obj = GetObject<T>(secondary);
			if (obj==null)
				obj = GetObject<T>(SecondaryTranslation);

			return obj;
		}

		T GetObject<T>( string Translation ) where T: Object
		{
			if (string.IsNullOrEmpty (Translation))
				return null;
			T obj = GetTranslatedObject<T>(Translation);
			
			if (obj==null)
			{
				// Remove path and search by name
				int Index = Translation.LastIndexOfAny("/\\".ToCharArray());
				if (Index>=0)
				{
					Translation = Translation.Substring(Index+1);
					obj = GetTranslatedObject<T>(Translation);
				}
			}
			return obj;
		}

Hope that helps,
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

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

More
8 years 8 months ago #933 by cedtat
Working perfectly !

So with this modification I can also override the font by inserting [MyFont] at the beginning of the text ? This functionnality os interesting because in my Thai localization I obviously have some labels in plain english and it could help choose another font for a particular label.



Working with exotic font I have also noticed that size are varying depending of the fonts. It could be really helpfull being able to provide a different font size for a font/term pair. Actually I have made a simple modification on DoLocalize_UILabel for NGUI target to multiply font size with a ratio but more control could be helpful.

Thank you for your help on the first point.

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

More
8 years 8 months ago #935 by Frank

So with this modification I can also override the font by inserting [MyFont] at the beginning of the text ?


Yes, you can add the font name (if the font added to the References tab in the Localize component or the Language Source or is in the root of the Resource folder).

You can also add [Folder/fontName] if the font is at "Resources/Folder".

Working with exotic font I have also noticed that size are varying depending of the fonts. It could be really helpfull being able to provide a different font size for a font/term pair


Initially I thought using a more complex tag (e.g. [fontName(32)]) to specify the font and the size, however, it could get confusing.
Most GUIs support rich text tags (uGUI, NGUI, TextMesh Pro, etc). So, you could do "[fontName] text "

That should be the cleanest way to make it work for specific labels/terms.

Hope that helps,
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

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

More
7 years 10 months ago #1541 by yeahus
Hi, Sorry to revive a dead thread but I'm having a similar problem. If I use color tags with NGUI, e.g:

"[c][ed2a45]KEEP PRESSING[-][/c] to go faster"

Then the beginning of the string ('[c][ed2a45]') is being stripped before being passed to NGUI. Is there a fix / workaround / trick I'm missing here?

Thanks!

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

More
7 years 10 months ago #1544 by Frank
Hi,
Thanks for reporting this issue, I added a fix for it in version 2.6.6 b1.
You can download that version from 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

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

Time to create page: 0.220 seconds
Template by JoomlaShine