Custom fonts in Unity
My game Space Short was pretty much done, but the name itself bothered me. It looked kind of… blah.
I had a vague impression of wanting maybe a motion blur or something, but it didn’t really look the way I wanted. After some thought, I realized that I want a different font for the two words, where “Space” would be heavy and massive, and “short” would be narrower.
So I started browsing through Google Fonts. I chose them because they are free for commercial use, and have a lot of options. As I intended to use them in a Unity game directly (that is, use the ttf file) and not embed in a website, I figured that I bypass the privacy issue.
After playing with some different options, I realized that the look I like best has the same kind of font for both words, just “Space” is bold and wide, and “Short” is narrower. In short, I needed a font that had a Condensed version.
I gathered the options I liked best and did a quick in-family poll, and 1 won by a landslide:
It was surprisingly difficult to find out how to do this, as some links led to old tutorials, but in the end I found this Unity Tutorial. And in an utterly counter-intuitive move, in order to add a font to your project you need to go to Window → TextMesh Pro → Font Asset Creator.
But before that, you need to copy the ttf file to your project’s Asset file. Otherwise your project won’t see it. Duh.
To add a font to your game:
- Create a
Resources/Fontsfolder in your
- Drag your font file into the
Resourcesfolder (but not the
Font Asset Creator.
Source Font File, choose the ttf file you just copied.
Generate Font Atlas(yet another clear and intuitive name there).
- Navigate to
Resource/Fonts, and click
- Now you can use it in your TextMeshPro objects.
Then I went over each scene and changed the font for all text. I had two fonts, the condensed and the regular. Google offers it in two forms, one variable font file and a folder of static font files. Guess which one Unity accepts?
Right. The static font. So I need to add each font I wanted separately.
I didn’t want to search and replace, as the sizes of the fonts weren’t the same. Each change also needed resizing and moving to the correct place. But that was actually kind of fun, seeing the game change its look and become even cooler.
How important is the font in your opinion? What fonts have you chosen and why? Let me know in the comments.