Unity UI Text dynamic font vs TMP

What is the best for performance on mobile?

Since the Legacy text system used by UI Text will eventually be deprecated, I would recommend using TextMesh Pro.

In terms of performance, TextMesh Pro allows you to use both static and dynamic font assets for achieving best performance with all the known text which should be contained in static font assets whereas user input should be coming from a dynamic font asset assigned as fallback.

Since only characters and glyphs coming from user input will be added dynamically (assuming you setup / use it this way) the performance overhead will not be noticeable by users.

In raw performance, you also have to consider that the legacy system needs to add the same characters / glyphs for each point sized used whereas the Dynamic SDF system only needs to add the glyph once.

So with the ability to use a mixture of static and dynamic font assets, signed distance field and soon to be added multi atlas texture support, I would strongly recommend you use TextMesh Pro. The TMP components offer a lot more functionality as well in terms of layout and formatting, etc.

Thanks for feedback. I try to use TMP in some places and this i got from my debug android build

I am afraid that it can be worse if i change the rest elements from Text to TMP.
Also could you clarify some aspects?
1)Should i use latest Unity version for getting latest TMP ? Now i am on 2017.4.
2)What with localization? Seems it’s kind of tricky, especially with asian ones.

The new Dynamic SDF system is only available in the for Unity 2018.3 or newer. The latest version of TMP is 1.4.1-preview.1 for Unity 2018.3 and 2.0.1-preview.1 for Unity 2019.1. Version 1.4.1 and 2.0.1 (will be out this week. Those are identical to the preview version).

LastUpdate() is used for SDF Scale tracking. This is no longer the case with the latest releases.

With regards to localization, this is where the new dynamic system provides increased flexibility. As per my previous post, you should still create a static primary font asset that contains all the known characters used in the project for any given language or groups of language. Known characters are those used menus, UI, dialogue, etc. This would exclude character from from user input.

Obviously, for Latin based languages where the character is fairly small, including all Extended ASCII is fine but for Chinese, Japanese and Korean (CJK) where their characters sets are much larger, you should create a static primary for each of those language the only includes the known characters and then create and assign a dynamic fallback to the primary which is designed to handle all other CJK characters coming from user input.

I have made several posts about this topic.

1 Like

Thanks a lot for answers! I will definitely try TMP. But if we compare only dynamic versions of both, which would be faster for mobile, ui text or tmp?

It all depends on how you use it. The old system doesn’t give you the option to use a mixture of static and dynamic. As such the new system is more flexible and will provide better performance.

More importantly, the TMP text components offer so much more functionality in terms of text formatting, layout, styling, etc. Furthermore the old system is going to be replaced by the internal TextCore which is based on TMP. So if you are starting something new, use TMP.

TMP would definitely be the way to go. Back in Unity 5.X, UGUI dynamic text had a flaw where it needed to generate separate sprites for glyphs in a text component when the size property changes. This could really hurt memory usage and performance when you use a lot of text with varying sizes, especially when the atlas is full and expands (I have experienced hang up to 1 second on iPad 4). I stopped using it and switched to TMP ever since.

1 Like

I use ttf files without Chinese characters to generate TMP dynamic font files. Chinese cannot be input in the TMPinput box, but Chinese can be input using dynamic ttf files with the unity text. Is this a normal situation, or there is an error in my handling. If I have no problem, does the important function of text dynamic font TMP not support?

When a character is requested and not available in the primary font asset or in the source font file if the font asset is dynamic, TMP will then search through all potential fallbacks and font files (if dynamic) to locate the character. If not available anywhere, it will then display the missing glyph character (square). With TMP, as a developer you have to be specific and define what font asset / font file get used and when. You have full control and made aware via the missing glyph symbol of what font asset / font files are missing characters used in the project.

Similarly, the legacy text system will check the primary font where in the event if does not find the requested character, it will then (behind the scene / magically) search through potential system / OS fonts to find this character. Although this may seem convenient at first, most users are unaware this is happening and that the font they selected does not contain those characters. Users have no control over what font ends up being selected and there is no guarantee this font will be present on the target platforms. Most of the time, developers uncover this as they begin testing on those other platforms or worst after publishing when users report these issues.

Short answer: If you are planning on supporting CJK, you will need to choose what font file to use and to create static or dynamic font assets for those. Setting up a primary font asset with fallback to support CJK takes is very simple and takes just a few minutes.

See the following two videos which explains the above along with suggest workflows to handle localization.

https://www.youtube.com/watch?v=NY1xKqCIj3c

https://www.youtube.com/watch?v=pLW2B98W5AU

1 Like

Thanks a lot for answers!
6323700--701208--test.png I just said that When a character is requested and not available text which use dynamic font will show it by operating system font, while TMP not. LiberationSans SDF come from LiberationSans.

Correct. TMP does not magically without the users knowledge switch to using some random OS / system font.

I will be adding support for OS / System fonts but it will still require the user to pick the system font they wish to use.

The above is deliberate to avoid having everything appear to work fine in the Editor because some random OS / system font was select where when you publish your project, a similar font is not available resulting in the text having lots of missing glyph symbols which as a developer you never got a change to fix or address because TMP was using some OS / System font without your knowledge.

So right now, the is not support for OS / System fonts in the editor. It is possible to use system fonts via scripting / API.

I will be adding a new font asset type which will be “Dynamic OS”. So when creating font assets, you will have the option of creating “Static”, “Dynamic” or “Dynamic OS” font assets.

The way Dynamic OS font assets will work is that in the Editor, you will still pick the OS font file to use as source which TMP will use.

In a build, the OS font file will not be included. When the first dynamic OS font asset is loaded, TMP will find all OS fonts available on the platform and using the name of the font file you specific in the Editor, will try to find a system font with the same name and then use it.

1 Like