Custom fonts in Unity

How to use custom fonts in your game

Danielle H
3 min readNov 24, 2023

My game Space Short was pretty much done, but the name itself bothered me. It looked kind of… blah.

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:

What do you think? (I’m not changing it now, though ;) )

1 is the Saira font and the Saira Condensed font. I downloaded the family and installed the font…and Unity doesn’t care.

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:

  1. Create a Resources/Fonts folder in your Assets folder.
  2. Drag your font file into the Resources folder (but not the Fonts folder!)
  3. Open Window TextMesh Pro Font Asset Creator.
  4. In Source Font File, choose the ttf file you just copied.
  5. Click Generate Font Atlas (yet another clear and intuitive name there).
  6. Click Save.
  7. Navigate to Resource/Fonts, and click Save again.
  8. 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.

Much better.

How important is the font in your opinion? What fonts have you chosen and why? Let me know in the comments.

Space short is live! Play it online, download from Google Play, and check out the source code.

I hope that this game provides a welcome distraction at this terrible time. #BringThemBackHome.

--

--

Danielle H

I started programming in LabVIEW and Matlab, and quickly expanded to include Android, Swift, Flutter, Web(PHP, HTML, Javascript), Arduino and Processing.