Font
Reference Manual > Components > Asset Components > Font

Font

Fonts can be created or imported for use in either the GUI Text or the Text Mesh Components.

Importing True Type Font files (.ttf)

To add a Font to your project you need to place the .ttf file in your Assets folder. Unity will then automatically import it. You have to make sure that the font has a .ttf extension otherwise Unity will not recognize it.

To change the Size of the font, highlight it in the Project View and you have a number of options in the Import Settings in the Inspector.


Import Settings for a font
Font SizeThe size of the font, based on the sizes set in any word processor
CharactersThe text encoding of the font. You can force the font to display only upper- or lower-case characters here
Font RenderingThe amount of anti-aliasing applied to the font

After you import the font, you can expand the font in Project View to see that it has auto-generated some assets. Two assets are created during import: "font material" and "font texture". You can alter the "font material" to change the font's color, but you shouldn't alter the "font texture" at all.

Unicode support

Unity has full unicode support. Unicode text allows you to display German, French, Danish or Japanese characters that are usually not supported in an ASCII character set. You can also enter a lot of different special purpose characters like arrow signs or the option key sign, if your font supports it.

To use unicode characters, choose Unicode from the Characters drop-down in the Import Settings. You can now display unicode characters with this font. If you are using a GUIText or Text Mesh, you can enter unicode characters into the Component's Text field in the Inspector.

You can also use unicode characters if you want to set the displayed text from scripting. The Javascript and C# compilers fully support Unicode based scripts. You simply have to save your scripts with UTF-16 encoding. In Unitron, this can be done by opening the script and choosing Text->Text Encoding->Unicode (UTF 16). Now you can add unicode characters to a string in your script and they will display as expected in UnityGUI, a GUIText, or a Text Mesh.

Changing Font Color

There are different ways to change the color of your displayed font, depending on how the font is used.

GUIText & Text Mesh

If you are using a GUIText or a Text Mesh, you can change its color by altering the Text Color of the font's auto-generated Material in the Inspector. This is called the "font material".

UnityGUI

If you are using UnityGUI scripting to display your font, you have much more control over the font's color under different circumstances. To change the font's color, you create a GUISkin from Assets->Create->GUI Skin, and define the color for the specific control state, e.g. Label->Normal->Text Color. For more details, please read the GUI Skin page.

Hints