Hi!
I am currently working on localizing and discovered that it’s quite impossible to match fonts in different languages so that the common glyphs blend naturally with fallback glyph fonts.
I saw this thread:
and was wondering if there’s any plan on implementing an option to force fallback font to override all glyphs. Since the game is using a ton of different material presets, it’d be hard to dynamically swap out the font asset and material presets on every GameObject with TMP in runtime, unless there is a way to pair each material presets in different languages.
Making sure different font assets blend well together from a “metrics point of view” can be done by adjusting / normalizing their face metrics like Ascent and Descent lines.
Making sure these blend from a visual design standpoint is a different story and comes down to font selection which can be tricky for some languages.
Then we have the part of Material Presets which are affected by Sampling Point Size to Padding Ratio as well as visual design differences. We can certainly match the Sampling Point Size to Padding Ratio, which will allow different fonts of “similar design weight” to work nicely together. However, the same cannot be said for going from a heavy weight looking font like Impact to a skinny / thin font.
Providing for the ability to potentially match material presets used between primary font assets and fallback might be an option.
Forcing a fallback to override could be another option but it quickly becomes problematic if this forced fallback is also missing characters. Do we then switch to force this third one or do we limit this to just a single override?
General Note:
I think when localization becomes more complex where a simple structure of font assets and fallbacks is no longer sufficient or becomes too restrictive, it is time to consider moving to a more robust and flexible solution which is to use some localization tool / framework to manage and track objects and resources affected by language selection. Such tools would allow you to define and use specific sets of resources for any given language or groups of languages. These language specific resources could be part of your package / app or loaded as needed based on language selection, etc.
Many studios and users have build their own tooling to manage localization. There are also localization tools available on the AssetStore suchs as I2 Localization and others.
Currently, fallback fonts look pretty close in terms of outline thickness, drop shadow, etc., which is great! But the style differ significantly since we could only have one Chinese font, as the font asset was already 40mb by itself. It’s quite difficult to find similar style font in different languages…
One thing I wish was possible is to match material preset when the font is swapped out, like it naturally does for fallback. It would remove dependencies between default font and fallback and can load only when needed.
This is something that has been requested before which also falls along the lines of another need which is to improve tracking / management of Material Presets which was referenced in this post from yesterday that I have been thinking about but didn’t reply to yet.
Adding a list of Material Presets to Font Assets would make it easier to manage them and could also be used for Material Preset Matching.
For management of Material Presets, this list would have only been serialized in the Editor to avoid having all material presets included in builds. However, to use this list for Material Preset Matching it would then need to be normally serialized which would result in all these materials getting included. Materials on their own are pretty small.
The atlas texture they reference is the one from the font asset so that would not increase the build size. Some Material Presets may reference textures for the face or outline of the text, these would get pulled in. I could always add the ability to define which of these presets get included in a build via some toggle. Maybe these get sorted based on those included in a build where their index in this list / array defines what they get matched to… so index 1 with index 1 of fallback, etc…
Since the project is using Latin alphabet font asset, which is tiny, as default, having other languages to have reference to it would not be a problem. If all the other languages use the default material preset as reference and swap with the appropriate material preset whenever they get replaced, it would be like a dream come true…
Do you have an example of visual differences / treatment between your material presets?
In terms of the feature, we already have Match Material Presets in the TMP Settings which would remain.
The default behavior when a fallback is used would be to check what preset index the current font asset is using and then use the material preset index if the fallback font asset has it otherwise synthesize the Material Preset like it does today.
Two new lists would be added to Font Assets. The first would include all Material Presets for the given font asset and be Editor serialized only. The 2nd list would include only those Material Presets used for Matching and wold be manually ordered by the user.
Material presets being matched have no problem (thank you so much for that feature), the root cause was that each language had such a different styled font (it’s hard to find rounded Chinese font or pen calligraphy style Korean font).
If I can fetch the index from current material preset and swap accordingly when the Font Asset is being replaced with the language setting after the language asset bundle has been loaded, it would fix all the problems I am currently having without any issue.
Yes! Having material preset list on each Font Asset would make it so much easier.
Thank you so much for all the answers.
I have a similar request. I use a font for my game which I don’t want to change, but it doesn’t include some Polish characters. I have a fallback font which supports all Polish characters, but it doesn’t look good to have the characters from the fallback font inserted into words which are mostly rendered in the normal font.
All I want is a boolean in TMP_FontAsset which would allow me to turn a particular font “off” and thus force it to always use fallbacks. I would set the bool to true on the normal font when switching to Polish, and false otherwise.
Does anything like this exist or could it be added?
I was surprised that TMP doesn’t include any built-in way to enable/disable fonts. I was in the exact same situation of Polish looking weird because it mixed fonts within the same word. TMP should have a similar project-wide per-font .enabled property IMO to let us force/choose a consistent fallback font when we need to (set per font). A second option to force one-font per text would also be useful for this (set per text), but not as essential. I manage my own loc, so I don’t want to pull in some whole other loc package to do what I already do – I just need to be able to have more control over the font selection.
Anyway, to @bob_the_pr_bot - Thanks much for this code workaround! I’m using it now