Sorry, we don't support your browser.  Install a modern browser
This post is closed.

Custom fonts in XML UI#41

Support for custom fonts in XML UI.

I think the most straight-forward implementation would be to extend CustomAssetState to have a (nullable) string type field, which for backward compatibility defaults to ‘image’.

We could have type ‘font’. However, that’s a pain as users are likely going to expect standard font file formats (ttf, otf etc.) to work. Where as most likely only TextMeshPro SDFs would be acceptable, and getting those as standalone files is not easy. So, it’s probably a lot easier just to have type ‘bundle’, as in asset bundle.

Then TTS can load all the resources (or all the ones you want to support) in the bundle and register those resources with XmlLayout. Whilst fonts are name of the game here, if expanded upon, there’s some other nice wins to be had e.g. sprite assets where we can specify the rects/bounds such 9-slice UIs work, and so forth.

Since Unity acquired TextMeshPro, I’m not sure how tight the integration is - may need to explictly load the SDF into a dynamic TMP asset. Fortunately, XmlLayout already has support for TextMeshPro (https://www.digital-legacy.co.za/XmlLayout/Documentation#TextMeshPro), so for us users, it ought to be pretty straight forward as long as we can reference the fonts somehow.

3 years ago
Changed the status to
Research
3 years ago
B
Changed the status to
Planned
3 years ago

Ohh, and have the fonts support translation tags. Translations sometimes are longer so could use arial narrow, while the shorter ones have arial for example.

3 years ago
B
Changed the status to
In Progress
3 years ago
3

Any update on this?

2 years ago
1
Changed the status to
Completed
2 years ago

This is awesome. Has this already been released? Can you link to the documentation that explains how to do this?

2 years ago
1

I would also be interested. I HATE the UI default font T.T

2 years ago

Can we get a documentation update for this? No one seems to be able to explain how to use it.

2 years ago

Basic howto:
In unity import the fonts you need and create a asset bundle for them
In the UI configuration add an elements, and reference the asset bundle.
In the xml for the ui set the font element to font=”imported element/full font name”

I got it working for my project doing this.

2 years ago
1

Erikmum, is your project on the workshop? I’m keen to see how you utilised this.

a year ago

Is there any documentation on how to make these font custom assetsbundles and how to reference them?

a year ago