Hi All, I just wondered if someone could give me a brief best practice for fonts in UIElements. Is it best to use a Font or Font Asset? What are the pros and cons of each? What’s the use case for either?
Cheers
Chris
Back in the day, UI Toolkit used TextNative for its TextEngine, which is the same text engine used by IMGUI. After Unity acquired TextMesh Pro, we slowly started to deprecate TextNative (now also known as the Legacy TextSystem) and replace it with TextCore. TextCore is a copy of the TextMesh Pro engine adapted to support all of Unity’s UI Fameworks (IMGUI, UGUI and UITK).
To answer your question, the -unity-font USS style was introduced while UITK was still on the legacy text system. When we switched to TextCore, we kept the -unity-font property and converted Font to FontAsset automatically in the background to ensure a seamless transition and backward compatibility.
The recommended way is to use -unity-font-definition with a FontAsset. There’s indeed a lack of official information, but here are a few places where you can find information on this new TextEngine. This forum post highlights the new changes and it includes a Getting Started Guide . As for the creation of FontAsset here’s a good guide
Hi! Thank you for the clarification. I went ahead and created a new blank project and reproduced the issues reliably with multiple different fonts files (.ttf and .otf). I also submitted a bug report with all the necessary information: CASE IN-14580
Noted on the transition to the TextCore engine. It seems that it is recommended to create a Font Asset and use that within UI Builder, but can you clarify whether we should be creating a Font Asset via the “Text” or “TextMeshPro” system? Thanks.
Thanks for logging the issue, we’ll look into it!
We want to consolidate our Text Assets and ensure that TMP and TextCore use the same asset type. If this is what you are looking for, look at com.unity.textmeshpro : 4.0.0-pre.1. Note that this is still a preview version. With this version of TMP, you can use all Text Assets in both TMP and TextCore. If you are using an earlier version of TMP, and want to add FontAsset to the UI Builder, you must create them through TextCore. TextCore Text assets are under the Create/Text menu item.