How do you use TextCore?

I’m trying to get my project setup to use new(ish) TextCore , but I’m confused how it’s meant to be used.

  1. What is the difference between a Font and FontAsset? I see the option for both in the UI Builder, and in the sample projects they are both filled out with the same font. What’s the difference between the two (other than one is an asset and one is a raw font)? When would I use a Font Asset over just a font, since it seems I can use either in the UI Builder just fine. If a Font Asset is the ‘better’ version of a raw font and adds more capability, why are both selected in the sample projects?

  2. In the text panel settings, there’s a “Path” field, which by default points to “Fonts & Materials”. What is the purpose of this box? Am I meant to put my raw fonts in there? The assets? I can pick the fonts in the editor just fine without it, so that is this used for? If I’m using Addressables, shouldn’t I be avoiding using the Resources folder?

  3. In the explorer when I select a font, I see options for “Font Weights”, with the ability to drag in several other font assets. Am I meant to be making one font asset which links to all my other font assets?

Thanks!

Hi @boolean01_1 !

We are aware of the lack of documentation surrounding TextCore and we are looking to improve this. In the meantime, since TextCore is directly coming from TextMesh Pro, you could look at TextMesh Pro’s documentation. There are a few differences as TMP works with UGUI whereas UI Toolkit works with TextCore, but the majority of the content should still be relevant.

1- The preferred way of doing things in UI Builder and UI Toolkit is to use FontAssets. Fonts are mostly there for backward compatibility. We are aware this is confusing for new users we are looking to clarify this. More information on why we introduced FontAssets can be found here: TextMesh Pro: Font Asset Creation - Unity Learn

2- TextCore allows you to have multiple FontAssets inside one TextElement by using the tag. More information on richText tags can be found here: Rich Text, TextMesh Pro Documentation

3- It is briefly covered in the unity learn article I mentioned above, but in short you can either use the “synthetic bold” that is automatically generated by TextCore or use another FontAsset. The way to link another FontAsset for the various weight is through the Font Weight Table.

I hope this helps, and don’t hesitate if you have more questions!

The following videos should also prove useful. These cover additional workflows available to create font asset in this case Dynamic Font Assets.

The videos also cover potential workflows to deal with localization.

Perfect, thanks Stephan_B!

Can I achieve the same text animation effect in TextCore as I used to do by modifying TextMeshPro’s vertices in the past?

Hi @giresharu ! We are looking to expose a similar API, but it’s unfortunately, it’s not the case yet.

Hope your development goes smoothly!
By the way, there have been some comments on forums or communities about potential GC problems with TextMeshPro due to frequent array resizing during text creation and modification. Is this alleviated in Text Core?

Yes, this has been improved in TextCore and UI Toolkit. There’s a caching system that’s been implemented to minimize the impact on memory.

Does this have anything to do with the massive memory leak for UIToolkit especially in safari on webgl?

https://discussions.unity.com/t/932346

Let’s see once QA opens the ticket, but I don’t believe this is related. We’ve recently fixed a similar memory leak in 2022.3, it might be worth testing with the latest version.

Are you referring to 2022.3.12f1? I sm on that currently and have found the issue on all version of unity from LTS to beta to alpha. Is there a way I could work around this issue?