Adding Custom Fonts – Arma 3

From Bohemia Interactive Community
Jump to navigation Jump to search

This tutorial explains how to get a font into Arma 3.

bi symbol white.png
Disclaimer: This page describes an unofficial tool created without permission or support of Bohemia Interactive.

The product itself and its usage may be violating rights of Bohemia Interactive and is in no way endorsed or recommended by Bohemia Interactive.

See also Official Tools.


Requirements


Definitions

Term Meaning
Arma 3 Tools Arma 3 Tools Launcher
CfgFontFamilies this refers to a class type that can be put inside a config.cpp file.
.tga file format Used for textures. In this context, TGA files are used to store all characters of a font.
.paa file format Also used for textures. Arma 3 uses TGA files converted into PAA files to display text.
.fxy file format This contains information about where each character of a font is placed in a particular texture file.
FontToTGA.exe A command-line tool included with Arma 3 Tools. It converts fonts into TGA files. More details here: FontToTga
ImageToPAA.exe A tool also included in Arma 3 Tools which can be used to convert TGA files into PAA files. More details here: ImageToPAA


Steps

The idea is that fonts (TTF or OTF) can be converted into TGA files by FontToTGA.exe. Every time FontToTGA.exe is called, one of the required parameters is a specific font size in pt size format.

  1. FontToTGA.exe will then generate .fxy files and .tga files.
  2. Then, ImageToPAA.exe can convert the TGA files created by FontToTGA.exe into PAA files.
  3. Then the .fxy and .paa files should be moved into an Addon. See Arma 3: Creating an Addon to learn how to make one.
  4. Then, inside of the addon's config.cpp, there should be an entry for each font you want to add, so that the game knows for what to look. Here is an example of that config.cpp:
    class CfgPatches
    {
    	class TAG_Custom_Fonts
    	{
    		name = "SOMETHING - UI fonts";
    		author = "your name";
    		url = "https://github.com/yourname";
    		requiredVersion = 0;
    		requiredAddons[] = {};
    		units[] = {};
    		weapons[] = {};
    		skipWhenMissingDependcies = 0;
    	};
    };
    
    class CfgFontFamilies
    {
    	class BebasNeue
    	{
    		fonts[] =
    		{
    			/*
    				these are just four examples to make this example shorter.
    				normally, there would be a lot more entries in here as explained below.
    			*/
    			"TAG_Custom_Fonts\Fonts\BebasNeue\BebasNeue10", // the number at the end refers to the size of the font in pt
    			"TAG_Custom_Fonts\Fonts\BebasNeue\BebasNeue11",
    			"TAG_Custom_Fonts\Fonts\BebasNeue\BebasNeue12",
    			"TAG_Custom_Fonts\Fonts\BebasNeue\BebasNeue100" // it can go higher than that, but 100 is pretty big :)
    		};
    	};
    };
    


Config

Each added font requires a class theNameOfTheFont in the class CfgFontFamilies brackets. If you want to add multiple fonts, simply do it like so:

class CfgFontFamilies
{
	class SomeReallyNiceFont
	{
		fonts[] = {}; // should be filled with strings 
	};

	class MonoSpaceFontMaybe
	{
		fonts[] = {}; // should be filled with strings
	};

	// and so on - add as much as you like
};
The classname you use will be the exact name that you later will use in the font = "fontName"; property to get that font to appear in UI elements.

The name itself makes no difference as long as it does not conflict with an existing font. Thanks to the creator of the Powershell script (as linked earlier), the config is generated for you. The only thing you need to do is copy it and paste it in the right place.

Fonts Array

This will all be generated by the Powershell script :)
It is a list of strings where each string refers to the path of each size of the font that was generated. If you want really big text in the game, then the appropriate size in pt has to be generated.
If the text inside of a UI element is much larger than the biggest available texture, the text will look ugly simply because the game will scale the texture up to the requested size.
By default, the Powershell script will generate a bunch of sizes to make sure that the font will look good through a wide range of sizes; but it is also capable of using provided custom sizes. Using the default values is fine.
If you only want a very specific size of the font, you can use the Powershell script to get that. The script itself tells you how.


Process

  1. Read the instructions for the Powershell script, then execute that script.
  2. Once done, you should have a bunch of .fxy and .tga files inside the Fonts folder of where FontToTGA.exe is located. Unless you provided another location to the Powershell script.
  3. Now it is time to let ImageToPAA.exe convert all the .tga files into .paa files. Start it up and just look at the interface to see how it works. It is pretty straightforward.
  4. Once all PAA images are generated, copy the .fxy and .paa files into a directory where you can let Addon Builder (also included in Arma 3 Tools) make a PBO from. The instructions on how to use Addon Builder can be found here.
  5. Now pay close attention to the config for class CfgFontFamilies that was generated by the Powershell script: each string in the fonts[] = {}; list will contain the path to where the .fxy and .paa files should be placed.

    An example:
    fonts[] =
    {
    	"TAG_Custom_Fonts\Fonts\BebasNeue\BebasNeue10"
    };
    

    The TAG_Custom_Fonts is a reference to the class used inside the addon config.cpp's class CfgPatches.
    In the example above, there should be a folder called Fonts in the same folder as config.cpp.
    Create it if missing, and then take the folder with the font's name (the one inside the FontToTGA.exe's Fonts folder) and put it in there.
    It is up to you if you want to keep or delete the .tga files.
  6. Double-check everything and make sure the config.cpp for your addon has been set right. If so, build it using Addon Builder.
  7. Add it to the launch options of the game. Instructions for that can be found elsewhere.
  8. Start the game, go into the 3DEN editor, open the config viewer, double-click on configFile.
  9. Type CfgFontFamilies. It should scroll the list to where it is.
  10. Double-click it and it should show the font you have added :)
  11. If so, then your font is ready to be used in the game. To see it, make sure any Dialog/Display control with a text property has font = "theFontYouAdded"; in it and you should be able to view the font!