My game has support for two languages, English and Hindi. I created 4 fonts atlases with one for bold fonts and one for regular fonts and this for both languages.
I want to show bold fonts from the Hindi language wherever I am having bold fonts in the English language and the same for regular fonts. If I change all the text labels from English to Hindi, then all the text labels are replaced with fonts that are first in the list and setting bold does not have any effect except for increasing some padding. Whatever sequence I put in the fallback font assets in the TMP_Settings, the fonts that are first in the list get placed even when I have set the text to be bold in the component.
Somebody, kindly tell me how to load bold font where there is bold option set and use the regular font if it is not bold? I want to get this done using fallback font assets only as I want to add support for more than 2 languages.
If I am doing this incorrectly, please highlight how can I do it more efficiently.
Are you using the Font Weights table to define what font asset should be used when Bold or other font weights are requested?
The Font Weights table (as seen below) allows you to define font assets for each of the possible font weights. You should assign the Bold font asset and its Italic counterpart (if using Italic) to both of your Primary English and Hindi font assets.
This is exactly what I was looking for. Thanks, @Stephan_B !
Now one more thing related to this, when I add the bold font asset in the font-weight table of the regular font asset and build Asset Bundle, it shows the bold font asset added automatically in the asset bundle due to its dependency in the regular font asset. But when I load the asset bundle in my game, the regular font’s weight table appears to be empty.
Does adding bold fonts in weights table not work in case of asset bundles? How should I solve this?
Just FYI, I am using Unity version 2019.2.0f1 and Text Mesh Pro 2.0.1
I think it does work with Asset Bundles but requires reapplying the corresponding shader to the fonts added in the font-weight table as well. I created such a generic co-routine to reapply shader for every font loaded from the asset bundle and it appears to be working for now.
Now I am not sure about the performance implications due to this, but I do see small framedrop in the editor while loading the font assets to the fallback fonts and reapplying the shaders. I still need to test this in a device.
Questions:
Is the requirement of reapplying shaders to the font assets after loading from an asset bundle by design or is it an issue with Unity? Is there anything I can do while building asset bundles such that I won’t have to do this step?
Am I looking at a bigger framedrop in case if I use more fonts in the asset bundle? If I use the above co-routine to reapply shaders and as it is using Shader.Find() for every font asset and its dependents, could this add to lower performance if I use more than 10 font assets for different languages?
Just FYI, I am using Unity 2019.2.0f1 and TextMeshPro 2.0.1.