Problem with TextMeshPro and font switching

More
6 years 11 months ago #2231 by johnnemann
Hi!

I followed the steps here for changing font per-language: www.inter-illusion.com/assets/I2Localiza...alizationManual.html

I am using Text Mesh Pro, so instead of creating a Font I created a Text Mesh P Font, and set it up so that it uses another font for Russian.




I added that secondary term to my TMP objects.






However, when I switch to Russian, the font doesn't change.




I can manually change the font, and see that it works, but it will not happen automatically.




Any ideas?

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

More
6 years 11 months ago #2232 by Frank
Hi,
What's happening is that the plugin can't find the fonts.
See how it shows "None (TMP_Font_Asset)" and the font name in red? That means that it tried to look for the font, but couldn't find it, so it uses None, but shows you that the font that should be there is the one in red.

The plugin uses two methods to locate the font, depending on where the font is located.

1- If the font is in a Resources folder, then its path is used.
2- If the font is not in a Resources Folder, then the font name is used, and a reference to the font is stored in the Localize or LanguageSource.

If your font is in a Resource folder (recommended), then the path should match exactly. In your case, the Red text showing the font, doesn't have any path, so it will look for the font in the root of a Resources folder
(e.g. this will work: "Assets/Resources/Aleo-Regular SDF.asset"
but this wont: "Assets/Resources/SUB FOLDER/Aleo-Regular SDF.asset")

If you don't want to store the font in Resources, then make sure the font is listed in the References / Assets section of the I2Languages.prefab.

After the setup is corrected, the font will be shown in the inspector (first image) and the red text will be hidden.

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
6 years 11 months ago #2233 by johnnemann
Yep, moving the fonts to the root of the Resources folder worked, thank you!

Putting them in Resources/Fonts didn't work, strangely...

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

More
6 years 11 months ago #2236 by dcheglakov
Hi,

We've faced with the same problem, almost a year we're using Text Mesh Pro and I2 Localization and fonts are located in Assets/Blocks/Fonts/...
But after update - 2.6.11 f1 I2L can't find fonts. We've tried to add fonts again but nothing happen.



Funny thing, if we tried to add another font, for example, Text Mesh Pro default font is assigned perfectly.



In the version 2.7.0 a3 everything is OK.

Attachments:

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

More
6 years 11 months ago #2237 by Frank
Aggrrr I hate these kind of issues! haha

I have been trying different things over the last day or so, and haven't been able to make it misbehave like that!
I know there is a problem, because there has been a couple reports about it, but I just can't find a way to reproduce it.

Its great to know that v2.7.0 fixed it for you. I will have to speed up and release that version without waiting for finishing the plural support, so that no one else get the font problem.

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
6 years 11 months ago #2238 by Frank
Hey hey hey! found the issue!

the problem was that in version 2.6.11 there was a typo in the function that finds the referenced asset.
Instead of "Name.EndsWidth(", that version had "name.EndsWidth"

This was fixed in the following release, but that didn't made into the store and instead branched into 2.7.0

To fix the problem, just open the file Assets\I2\Localization\Scripts\LanguageSource.cs line 592-601
replace the FindAsset function with this one:
		public Object FindAsset( string Name )
		{
			if (Assets!=null)
			{
				for (int i=0, imax=Assets.Length; i<imax; ++i)
					if (Assets[i]!=null && Name.EndsWith( Assets[i].name, System.StringComparison.OrdinalIgnoreCase))
						return Assets[i];
			}
			return null;
		}

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
The following user(s) said Thank You: dcheglakov

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

Time to create page: 0.366 seconds
Template by JoomlaShine