Loading -unity-font-definition font asset different results using url() vs resource()

Using Unity 2022.3.22f1, WebGL target. In our USS, we load our font asset using -unity-font-definition.

If we use:

-unity-font-definition: url('project:/Assets/UI Toolkit/CSPS themes/FontAssets/Roboto-Bold.asset');

The font is a blurry mess.
9729097--1390981--upload_2024-3-26_16-29-15.png

If we use:

-unity-font-definition: resource('FontAssets/Roboto-Bold');

The font is fine.
9729097--1390972--upload_2024-3-26_16-28-30.png

Only in-editor. No issues when deploying.

Edit: Wondering if it has to do with TMP/TextCore being hardcoded to use /resources folder or breaking in adressables? TextMeshPro & Addressables (Asset Bundles)

9729097--1390972--upload_2024-3-26_16-28-30.png

Hi! First time I hear about this issue. Would you mind logging an issue ? (See how to report a bug)

We’ve been trying to track it down and it seems to have something to do with assigning a TSS in runtime from an addressable.

We’ve been using;

GameObject.Find("UITK").GetComponent<UIDocument>().panelSettings.themeStyleSheet = m_loadThemeHandle.Result;

And we can see it being set in the panel - but with the results you see. While in play-mode, if we re-assign manually the same theme to the panel in the inspector, it renders properly.

I’m not too familiar with addressable and how it could impact FontAssets. What if you clear the FontAsset data before bundling the Addressable asset. Select “Clear Dynamic Data on Build” on the Font Asset. Does it help ?

Negative on the “Clear Dynamic Data on Build”
it was actually set to Static atlas population method, but swapped it to dynamic to be able to test that option with no luck

1 Like

It’s hard to tell without having a deeper look into it. Would you mind logging a ticket ?

Issue has been logged
Incident number:
IN-72704

The bug report @sjompheCSPS_1 submitted contains a minimal repro project. Don’t hesitate if you need more info.

Cross posted it on the Unity 6 forums as well as it will be our next production version: https://forum.unity.com/threads/font-in-ui-toolkit-theme-loaded-from-addressables-doesnt-render-properly.1573618/

and to make it more official