- Home /
Using font in UI Builder
I'm relatively new to Unity and have been learning how to make a GUI using UIToolkit & the UI Builder. I'm finding it quite straightforward so far thanks to the similarities with CSS.
However I am unable to apply any fonts to text elements, and I wonder what I'm doing wrong.
In a new project, I:
Create a new UIDocument object in my scene
Create a new UIDocument asset in my project, and then drag this to the game object's "Source Asset" property
Drag a TTF font from a Windows Explorer folder into my assets folder to add it to the project
Double-click the UIDocument asset in my project to open up the UI Builder
Add a label to the UI in UI Builder
Select the label then drag the font from my assets folder onto the Font property of the Text component in the UI Builder's inspector panel.
The correct font name displays in the inspector panel, but the font doesn't change in my UI, either in the UI Builder window or in the Game view, and remains the default Arial-esque font in both.
Here's a screenshot illustrating the issue.
Am I missing something?
Answer by andrew-lukasik · Dec 14, 2021 at 04:28 PM
You need to generate a Font Asset
from that Font
file and use it instead.
Open Font Asset Creator window
Change character set to ASCII (narrow char set, but good enough most of the times)
Click Generate Font Atlas, then it Save to file
Profit
Perfect, thank you very much!
As a related question, where should I have found this info in the documentation? I was searching for this kind of info but with no luck.
As far as I can tell this is a bug, a broken feature, so no documentation for that :T
Your answer

Follow this Question
Related Questions
Problem with fonts with ttf format 2 Answers
How can I create Font objects at runtime? 0 Answers
Embedded fonts? 0 Answers
New Unity UI not working with windows standalone builds 0 Answers
UI Builder and UI Toolkit compatible latest Unity Version? 0 Answers