Localize Font Size of TextMesh Pro

5 years 3 weeks ago #442 by haikugames
Absolutely love the plugin. I was wondering if there is a way to localize the font size of TextMeshPro labels.

Also, in general how does the community deal with some text strings being much longer than others? We have some simple English words like "Skip" that have been translated to much longer Germany/French words which spill outside of our buttons, etc. Other times the text fits in the box nicely. Do go through every text string and see if it fits?

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

5 years 3 weeks ago #443 by Frank
There is no build-in way to preset a font size per language.

However, you can easily add a script function that does it by using the Translation Modifier callback that the plugin provides.
Everytime that a translation is about to be used, the Localize component allows you set a method that gets called. That method can be used to modify the text of the translation.

That method can also be set to apply changes to the object it self. Like changing the font based on the language. Or you could even store your translations with parameters, for example: "{FONT=13}Custom Text" and the method could see if there is a {FONT=xx} in the text and if so, could remove that section and apply the font size in there.

But normally, you don't need to go that far.

All supported labels provide a way to constraint the font size based on the text.
So, if you have "skip" and "├╝berspringen" you could set the text boundaries to be of the height of the text, and the width to cover the button width.
Then set the label to be constrained (auto-size in TextMesh Pro).
That will make that both texts expand to the height you specified but with different widths.

If the text is way too large to fit in the button with that height, then the TextMeshPro constraint feature will make the font smaller so that it doesn't go outside the width.

Also be aware that the plugin provides a "previewing". So, if in the editor, you are changing the text of a translation in the Localize component, the text of the label is changed to show that translation.
If you select another translation and modify it, then the label will show the language you are modifying. That way you could know while editing if the text fits in the buttons.

In version 2.4.0 f2 that feature was improved, and now you don't even need to change the translation to see it. You just select a label, and then click on the languages. As you click, the text of the label is changed to that translation so you can see how it compares in size with the other languages.

Hope that helps!

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: haikugames, fiveamp

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

Time to create page: 0.242 seconds
Template by JoomlaShine