Adding Custom Fonts – Arma 3
(page added.) |
Lou Montana (talk | contribs) m ("Some" wiki formatting) |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
{{TOC|side}} | |||
This tutorial | This tutorial explains how to get a font into {{arma3}}. | ||
{{Feature| | {{Feature|UnsupportedTool}} | ||
== | == Requirements == | ||
* {{arma3}} | |||
* {{Link|Arma 3 Tools Launcher}} (from [[Steam]]) | |||
* a Windows machine capable of running Powershell scripts | |||
* this unofficial Powershell script: https://github.com/Nelis75733126/Arma_3_FontToTGA_Helper/ | |||
* a mouse and keyboard might be handy :P :P | |||
== Definitions == | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
! | ! Term !! Meaning | ||
|- | |- | ||
| Arma 3 Tools || {{Link | | Arma 3 Tools || {{Link|Arma 3 Tools Launcher}} | ||
|- | |- | ||
| | | <syntaxhighlight lang="cpp" inline>CfgFontFamilies</syntaxhighlight> || this refers to a {{hl|class}} type that can be put inside a {{Link|Config.cpp/bin_File_Format|config.cpp}} file. | ||
|- | |- | ||
| .tga file format || Used for textures. In this context, TGA files are used to store all characters of a font. | | {{hl|.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. | | {{hl|.paa}} file format || Also used for textures. {{arma3}} 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. | | {{hl|.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]] | | FontToTGA.exe || A command-line tool included with Arma 3 Tools. It converts fonts into TGA files. More details here: [[FontToTga]] | ||
Line 32: | Line 36: | ||
|} | |} | ||
== | |||
The idea is that fonts (TTF or OTF) can be converted into TGA files by | == Steps == | ||
Then, inside of the config.cpp | The idea is that fonts (TTF or OTF) can be converted into TGA files by {{hl|FontToTGA.exe}}. | ||
<syntaxhighlight lang="cpp"> | Every time {{hl|FontToTGA.exe}} is called, one of the required parameters is a specific font size in {{hl|pt}} size format. | ||
# {{hl|FontToTGA.exe}} will then generate {{hl|.fxy}} files and {{hl|.tga}} files. | |||
# Then, ImageToPAA.exe can convert the TGA files created by FontToTGA.exe into PAA files. | |||
# Then the {{hl|.fxy}} and {{hl|.paa}} files should be moved into an Addon. See {{Link|Arma 3: Creating an Addon}} to learn how to make one. | |||
# 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 {{hl|config.cpp}}:<syntaxhighlight lang="cpp"> | |||
class CfgPatches | 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 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 :) | |||
}; | |||
}; | }; | ||
</syntaxhighlight> | }; | ||
</syntaxhighlight> | |||
== Config == | |||
Each added font requires a <syntaxhighlight lang="cpp" inline>class theNameOfTheFont</syntaxhighlight> in the <syntaxhighlight lang="cpp" inline>class CfgFontFamilies</syntaxhighlight> brackets. | |||
If you want to add multiple fonts, simply do it like so: | If you want to add multiple fonts, simply do it like so: | ||
<syntaxhighlight lang="cpp"> | <syntaxhighlight lang="cpp"> | ||
class CfgFontFamilies | class CfgFontFamilies | ||
{ | |||
class SomeReallyNiceFont | |||
{ | |||
fonts[] = {}; // should be filled with strings | |||
}; | |||
class MonoSpaceFontMaybe | |||
{ | |||
fonts[] = {}; // should be filled with strings | |||
}; | |||
</syntaxhighlight>< | // and so on - add as much as you like | ||
}; | |||
</syntaxhighlight> | |||
{{Feature|informative|The classname you use will be the exact name that you later will use in the <syntaxhighlight lang="cpp" inline>font = "fontName";</syntaxhighlight> 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. | |||
Thanks to the creator of the Powershell script (as linked earlier), | 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 :)<br> | This will all be generated by the Powershell script :)<br> | ||
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.<br> | It is a list of strings where each string refers to the path of each size of the font that was generated. | ||
If the text inside of a UI element is much larger than the biggest available texture, the text will look ugly | If you want really big text in the game, then the appropriate size in pt has to be generated.<br> | ||
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 | 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.<br> | ||
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.<br> | |||
If you only want a very specific size of the font, you can use the Powershell script to get that. The script itself | 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 == | ||
<syntaxhighlight lang="cpp"> | # Read the instructions for the Powershell script, then execute that script. | ||
# Once done, you should have a bunch of {{hl|.fxy}} and {{hl|.tga}} files inside the Fonts folder of where {{hl|FontToTGA.exe}} is located. Unless you provided another location to the Powershell script. | |||
# Now it is time to let {{hl|ImageToPAA.exe}} convert all the {{hl|.tga}} files into {{hl|.paa}} files. Start it up and just look at the interface to see how it works. It is pretty straightforward. | |||
# Once all PAA images are generated, copy the {{hl|.fxy}} and {{hl|.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 {{Link|Arma 3: Creating an Addon#Addon Builder|here}}. | |||
# Now pay close attention to the config for <syntaxhighlight lang="cpp" inline>class CfgFontFamilies</syntaxhighlight> that was generated by the Powershell script: each string in the <syntaxhighlight lang="cpp" inline>fonts[] = {};</syntaxhighlight> list will contain the path to where the {{hl|.fxy}} and {{hl|.paa}} files should be placed.<br><br>An example:<syntaxhighlight lang="cpp"> | |||
fonts[] = | fonts[] = | ||
{ | |||
"TAG_Custom_Fonts\Fonts\BebasNeue\BebasNeue10" | |||
}; | |||
</syntaxhighlight> | </syntaxhighlight><br><!-- | ||
-->The {{hl|TAG_Custom_Fonts}} is a reference to the class used inside the addon {{hl|config.cpp}}'s <syntaxhighlight lang="cpp" inline>class CfgPatches</syntaxhighlight>.<br><!-- | |||
Create it if missing, and then take the folder with the name | -->In the example above, there should be a folder called Fonts in the same folder as {{hl|config.cpp}}.<br><!-- | ||
-->Create it if missing, and then take the folder with the font's name (the one inside the {{hl|FontToTGA.exe}}'s Fonts folder) and put it in there.<!-- | |||
{{Feature|informative|It is up to you if you want to keep or delete the <syntaxhighlight lang="cpp" inline> | -->{{Feature|informative|It is up to you if you want to keep or delete the {{hl|.tga}} files.}} | ||
# Double-check everything and make sure the {{hl|config.cpp}} for your addon has been set right. If so, build it using [[Addon Builder]]. | |||
# Add it to the launch options of the game. Instructions for that can be found elsewhere. | |||
# Start the game, go into the 3DEN editor, open the config viewer, double-click on {{hl|configFile}}. | |||
# Type {{hl|CfgFontFamilies}}. It should scroll the list to where it is. | |||
# Double-click it and it should show the font you have added :) | |||
# If so, then your font is ready to be used in the game. To see it, make sure any Dialog/Display control with a <syntaxhighlight lang="cpp" inline>text</syntaxhighlight> property has <syntaxhighlight lang="cpp" inline>font = "theFontYouAdded";</syntaxhighlight> in it and you should be able to view the font! | |||
{{GameCategory|arma3|Tutorials}} | {{GameCategory|arma3|Tutorials}} |
Latest revision as of 10:44, 16 May 2024
This tutorial explains how to get a font into Arma 3.
Requirements
- Arma 3
- Arma 3 Tools Launcher (from Steam)
- a Windows machine capable of running Powershell scripts
- this unofficial Powershell script: https://github.com/Nelis75733126/Arma_3_FontToTGA_Helper/
- a mouse and keyboard might be handy :P :P
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.
- FontToTGA.exe will then generate .fxy files and .tga files.
- Then, ImageToPAA.exe can convert the TGA files created by FontToTGA.exe into PAA files.
- Then the .fxy and .paa files should be moved into an Addon. See Arma 3: Creating an Addon to learn how to make one.
- 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 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
- Read the instructions for the Powershell script, then execute that script.
- 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.
- 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.
- 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.
- Now pay close attention to the config for
class CfgFontFamilies
that was generated by the Powershell script: each string in thefonts[] = {};
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'sclass 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. - Double-check everything and make sure the config.cpp for your addon has been set right. If so, build it using Addon Builder.
- Add it to the launch options of the game. Instructions for that can be found elsewhere.
- Start the game, go into the 3DEN editor, open the config viewer, double-click on configFile.
- Type CfgFontFamilies. It should scroll the list to where it is.
- Double-click it and it should show the font you have added :)
- 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 hasfont = "theFontYouAdded";
in it and you should be able to view the font!