How do I use default system font?

My game targets mobile (iOS and Android) and I’m in the process of migrating from legacy UGUI Text to TMP.
However my game has a huge amount of user generated content which includes CJK characters; a big part of my game also works more like a browser where you browse user generated content (think a forum/social media), and I would like to use the default system font (Android user can even change this themselves) rather than forcing a specific font style.
In UGUI Text it’s as simple as just setting the font face to Arial, and it will pull the default system font at runtime no matter what. I could not find any information regarding how to do this in TMP.
Dynamic OS font asset apparently requires a reference font which it finds the closes font at runtime (but that’s not what I want! I don’t want closest matching family, I just want the default); Font.GetPathsToOSFonts doesn’t tell you which one is the default; TMP_FontAsset.CreateFontAsset wants you to specific a family. I’ve looked everywhere and could not find a satisfying answer.
I understand that a lot of these features are designed with a traditional game in mind, where you want font to match rest of your game UI style, but in my case I do not care and want my game to use the default system font so that users are comfortable reading content with their preferred system font.
Any help is appreciated.

The Legacy text system uses an internal hardcoded list of potential fonts to use on different platforms. Although this magic functionality may appear convenient to users at first, it provides no control over font what font is used and on which platform.

Dynamic OS font assets do require that you import the font you are expecting to use on the target platform. Although this is an extra step in theory, this is something that you should do from a quality assurance point of view as it will enable you to see exactly what you will get on the target platform. In the Editor, the import reference font will be used as a source. In a build, this reference font will not be included. At runtime on the target platform we will search for a font file with the same family name and style name. This is not closest but the same font file.

For example, if I import NotoSansCJK - Regular in my project and create a dynamic OS font asset from it using the “Noto Sans CJK JP - Regular” face as seen below. Note this is a TrueType Collections (TTC) which contains multiple faces.

8020580--1032899--upload_2022-4-4_13-53-56.png

Like I explained above, when I create a build for Android for instance, the source font file will not be included. The dynamic os font asset will be included. When trying to add characters dynamically at runtime on the target platform (Android), TMP will search for this exact font face which is Noto Sans CJK JP - Regular. Again not the closest or something else but that exact font file (if it exists). This of course requires that you know what fonts are available on the various platforms you are targeting. This information is published by the various manufacturers. Plus you can also test it yourself using the Font.GetPathsToOSFonts()

In order to target multiple platforms (iOS and Android) for instance, you would simply import NotoSansCJK - Regular which is the default on Android and PingFang - Regular which is the default on iOS. You would assign both of these as local fallback to your primary font asset. Then on Android for example, since NotoSansCJK - Regular is present, it would use that font asset as fallback. On iOS since NotoSansCJK - Regular is not present, it would use PingFang.

As per the above, you have complete control over what font will be used. Once you know what font you want to use, this take less than a minute to setup. The steps are (1) find the font. (2) import the font. (3) create font asset and set as dynamic OS. (4) assign as fallback to your primary. That is it.

P.S. I you have not already done so, take the time to watch the following two videos as although they do not specifically cover Dynamic OS font assets, they do cover dynamic font assets (which behave the same way in the editor). These videos also cover localization and the fallback system which is used by Dynamic OS font assets.

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

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

2 Likes

Appreciate the reply, but I’m not looking to control exactly what font to use, I WANT it to use the default system font because my game is half a “browser,” and user expects the game UI to use their system font.
On Android for example, user can modify their system font to something completely different for ease of reading, and I want my game to use that, instead of finding the exact Noto CJK. This works with the legacy UGUI Text, and I simply want to achieve the same in TMP.

1 Like

I will need to verify if the Legacy text system does in fact change font selection based on what default is set on that platform. As far as I know the list of fonts and their order is hardcoded but I’ll will double check.

1 Like

Any update?

So in my testing on windows in unity 2021.3.10f1 with TMP 3.2.0-pre.3 the source font files attached to TMP Assets marked as Dynamic OS do indeed still get included with builds.

First build is with OS Fallback fonts configured on windows with the following fonts:

Overall if this is the case this basically makes the OS Fallback support completely useless in it’s current state since for me the main usecase here is to not have 170mb of CJK fonts shipped with our game build taking up 1/3rd of our game file size.

Here’s a screenshot of one of my TMP_Font Assets as well:

They should not get included but you are right that there might be an issue here. I’ll try to test this over the next day or so.

BTW: Assuming the source font file is present on your system, deleting the source font file from the project would still enable the font asset to work in the Editor. This is not the intended workflow but that would most certainly preclude the source font file from being included in the build.

P.S. If you were to switch the Inspector to Debug mode, do you still see a reference to the source font file?

As seen below, you should still have an Editor Ref to the source font file but no other reference should be present for Dynamic OS font assets.

8457362--1122446--upload_2022-9-22_2-20-49.png

So the assets do only seem to have the editor ref and the Source Font FIle on all of them are set to none

Any update?

Stephan_B, hi! What will be the best approach if we have to deal with international user input? Let’s say we’re making a social community or a chat system. Currently I had to download ‘Arial Unicode MS Regular’ at runtime (as I don’t want to include it in builds) and create TMP_FontAsset from it. The font is huge and I don’t have a license, so it’s just for test purposes. I also considered a Unicode font called ‘Code2000’, it’s much lighweight and has unrestricted license.
Overall, I don’t understand how to deal with random texts on different platforms (Android, iOS, Windows) except having such uber-fonts.

It would be super cool to create TMP_FontAsset from the default Unity’s ‘Arial’ legacy font, but it’s not possible at the moment, as it doesn’t “Include Font Data”. And I actally don’t want to know how all the magic inside the legacy font system works, I mean how you’re resolving Arial on different platforms. But once you’ve did this, it should be possible to create a TMP_FontAsset from it at runtime. Sorry if I’m dumb ass)

This setting controls the packaging of the font when used with Dynamic font property. When selected the TTF is included in the output of the build. When not selected it is assumed that the end user will have the font already installed on their machine.

Any update?

I never found any option “Dynamic OS”, just “Static” and “Dynamic”

Hello, DynamicOs works ok in iOS which version is less than iOS 18; But recently, we found DynamicOs does not work in iOS 18 ;I found some related post in Other website ,such as Apple ios18 pinging missing . So we really need your help to give some advise. Thanks

I don’t see Dynamic OS option either and i have 3.0.9 using Unity 2021.

Is this still a “preview” feature? its 2025!

1 Like

@Stephan_B any update on this?

@Stephan_B any updates?

TMP is truly a flexible and powerful text solution. Regarding Dynamic OS fonts, I need to know the target platform—for example, what fonts are included in Android—and then locate that specific font. If I use an arbitrary font, it might not display correctly on Android.

Additionally, even if I find a font that works on my test devices (such as a specific brand of Android phone or a certain version of iPhone), and it displays correctly there, I’m still concerned that the font might not exist on unknown devices. In such cases, users’ devices could encounter display errors.

If TMP could at least fall back to a final default system font when the target font isn’t found, it would help ease my concerns. Thank you!