Font localization problem NGUI/Asian
9 years 4 months ago - 9 years 4 months ago #930
by cedtat
Font localization problem NGUI/Asian was created 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
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: 9 years 4 months ago by cedtat.
Please Log in or Create an account to join the conversation.
9 years 4 months ago #932
by Frank
Are you Give I2L 5 stars!
Are you Please lets us know how to improve it!
Replied by Frank on topic Font localization problem NGUI/Asian
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:
Hope that helps,
Frank
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.
9 years 4 months ago #933
by cedtat
Replied by cedtat on topic Font localization problem NGUI/Asian
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.
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.
9 years 4 months ago #935
by Frank
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".
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!
Replied by Frank on topic Font localization problem NGUI/Asian
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.
8 years 6 months ago #1541
by yeahus
Replied by yeahus on topic Font localization problem NGUI/Asian
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!
"[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.
8 years 6 months ago #1544
by Frank
Are you Give I2L 5 stars!
Are you Please lets us know how to improve it!
Replied by Frank on topic Font localization problem NGUI/Asian
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
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.195 seconds