Font Asset Issues

When I tried making a font asset with a font in my project using UITK, it created it with only a few characters. I deleted it and try recreating it again, but now it creates it without any characters.

However, I made a font asset with the same font using TMP about a year and a half ago.

I submitted a case with the TMP font asset, the font, and the UITK font asset.

Case #: 1293307

Thanks for filing a bug! We’ll take a look.

1 Like

It did the same for me, default font asset had no characters. When I saw the character set was set to Unicode Range (Hex) I changed it to ASCII and re-generated the Font Atlas and it worked.

Works like a charm! Thanks for pointing it out. What is the different between Unicode Range (Hex) and ASCII?

Character Set
The characters in a font file aren’t included in the font Asset automatically. You have to specify which ones you need. You can select a predefined character set, provide a list of characters to include, or include all of the characters in an existing font Asset or text Asset.

Character Set Options

  • ASCII - Includes the visible characters in the ASCII character set.

  • Extended ASCII - Includes the visible characters in the extended ASCII character set.

  • ASCII Lowercase - Includes only visible lower-case characters from the ASCII character set.

  • ASCII Uppercase - Includes only visible upper-case characters from the ASCII character set.

  • Numbers + Symbols - Includes only the visible numbers and symbols from the ASCII character set.

  • Custom Range Includes a range of characters that you define.

Enter a sequence of decimal values, or ranges of values, to specify which characters to include.

Use a hyphen to separate the first and last values of a range. Use commas to separate values and ranges (for example 32-126,160,8230).

You can also choose an existing font Asset to include the characters in that Asset.

  • Unicode Range (Hex) Includes a range of characters that you define.

Enter a sequence of unicode hexadecimal values, or ranges of values, to specify which characters to include.

Use a hyphen to separate the first and last values of a range. Use commas to separate values and ranges (for example 20-7E,A0,2026).

You can also choose an existing font Asset to include the characters in that Asset.

  • Custom Characters Includes a range of characters that you define.

Enter a sequence of characters to specify which characters to include.

Enter characters one after the other, with no spaces or delimiting characters in between (for example abc123*#%).

You can also choose an existing font Asset to include the characters in that Asset.

  • Characters from File Includes all the characters in a text Asset that you specify.

Use this option when you want to save your character set.

Note that you can also create and use dynamic font assets, these are created by selecting a font file in the project and then using the context menu create option as seen below.

6542152--739684--upload_2020-11-19_16-44-6.png

3 Likes

Thank you for the beautiful explanation!

7785783--982764--unity_font.png
I’m using unity 2021.2 and there is this menu in the inspector. Both “Create Font Asset” and “TMP Font Asset” lead to the same window. And sometimes, it bugs.
Using Create>Text>Font Asset from the project view works fine but I wonder why the two behave differently

Hi @vejab !

While the two windows are identical, the resulting asset type isn’t. The “Create TMP FontAsset” menu item will create a TMP_FontAsset that is compatible with TextMeshPro while the “Create Font Asset” menu item will create a FontAsset that is compatible with TextCore, the text engine used by UI Toolkit.

We plan to unify the Text assets in the future to have them work in both Text Engine. However, we don’t want to rush this as doing so with the current infrastructure will have major drawbacks for TMP users.

I hope it’s clearer!

1 Like

I am slightly confused. I thought this was already here? I haven’t updated yet to 2022.1 beta because of bugs, but it seems its already possible unless I misread stephan?

https://discussions.unity.com/t/820526 page-2#post-7708504

Yes, you are right @MousePods , there is a preview version of TMP that supports sharing Text Assets across TMP and TextCore. This version is useful for users who want to use both TMP and UI Toolkit in their projects. However, like Stephan pointed out in his post, this version comes with important drawbacks for TMP users and we are still looking to mitigate those before releasing it out of preview.

1 Like

Are there any updates in regard to using TextMeshPro Font Asset for text in the UI Builder?

My current versions:
Unity 2021.2.13f1
TextMeshPro Package 3.0.6

I like to use my Pixel Art font with the new UI Toolkit. The font asset is a TextMeshPro Asset with the Atlas Render Mode Raster_HINTED. And this is currently not possibel because it can not be seleceted in the UI Builder / Inspector for a Label / Text / FontAsset. When I use the way described above (Rightlick on font /Create/Text/TextAsset) I get a SDF FontAsset, hence no sharp edges (corners get rounded). It would be awesome if I could use this again :).

Currently the only way to set custom fonts (not FontAssets) is described here , but are all corners of my pixel font get rounded as well (see attached file).

This is the style part of text labels .uxml line from the text in the attached image:

style="font-size: 48px; color: rgb(0, 0, 0); -unity-font: url('project://database/Assets/Fonts/Font_Files/PatientSower_12px.ttf?fileID=12800000&guid=e9a9130fc4755b24ba24f0c0a3774a12&type=3#PatientSower_12px'); margin-left: 0; margin-right: 0; margin-top: 0; margin-bottom: 0; -unity-text-align: middle-center; -unity-font-style: normal; -unity-font-definition: none;"

Hi @BusyRoots_1 !

It indeed seems like BitMap Atlas Render Modes are broken in trunk. Thanks for bringing this up, we’ll do our best to fix it in a timely manner.

Could you please log a fogbugz for this? This would help track it and backport the fix to earlier versions of Unity.

Hi @HugoBD-Unity ,
no problem. The bug report is sent!

1 Like