TEXT FONT
Fonts can be an otf (open type) or ttf (true type font) file.
To add a new font to your game, you have to copy the file in the assets/pictures directory.
Then, in the same location, create a text file called yourFontName.fontdef.
Open this file with a text editor, and add this:
font yourFontName
{
type truetype
source yourFontName.ttf (or yourFontName.otf)
size 64
resolution 72
code_points 32-255
}
!!! Don’t forget to replace yourFontName with the name of your font!
For example, if you are importing comic.ttf, the resulting script should be:
font comic
{
type truetype
source comic.ttf
size 64
resolution 72
code_points 32-255
}
For Japanese characters:
You need to use this template:
font myJapaneseFont
{
type truetype
source MochiyPopOne.ttf
size 64
resolution 72
code_points 32-255 //latin
code_points 12288-12351 // japanese-style punctuation
code_points 12353-12447 // hiragana
code_points 12448-12543 // katakana
code_points 19968-40959 // kanjis
code_points 65280-65519 // Full-width roman characters and half-width katakana
}
Note: please don't use any space in the font name.
BITMAP FONT
You can import a custom bitmap font. You can create a font using colors, shadows… The import process is a little convoluted, but you can do it!
With a software:
First, download and install Bitmap Font Builder:
http://www.lmnopc.com/bitmapfontbuilder/
>> Launch it.
>> Choose a font you like as a starting point
>> Choose a texture size (ex: 1024)
>> You can play with the font size: you can press the checkbox near the font size to maximize the characters. But if you want to add some drop shadows, for instance, you can decrease a little the size to add space around characters.
You can display the grid to help you in this case.
>> Save the picture in 8-bit in tga.
>> Then do File > Save Font Widths (Byte format ) and save this file with the same name as the tga, but with a .dat extension.
Converting the font
>> Download the small fontConverter.exe tool:
fontConverter.exe
>> Copy it into an empty directory
>> Copy your .tga and .dat in this directory.
>> Run the converter
>> You need to answer some pretty self-explanatory questions:
. Enter a name for your new font (ex: hardcoreMetal)
. Enter the name of your .tga (ex: hardcoreMetal.tga)
. Enter the size of the texture you saved (ex: 256)
. Enter the name for the .dat (ex: hardcoreMetal.dat)
. Then you need to add pixels around your font, only if you plan to add a drop shadow or glow. If not, answer zero.
Note: you can use your paint software to retouch the .tga, add gradient, colors…
>> Copy the .tga and the generated .fontdef in the Assets/pictures directory of your game
Or, customizing a sample:
The disadvantage of this method is that the letters have the same squared size. So the space between letters is going to be different.A sample could be downloaded HERE.
Then, you can use your paint software to retouch the .tga, add gradient, colors…
Then copy the square.tga and the square.fontdef in:
>> Assets/pictures directory of your game.
SCORE AND MULTIPLIER FONT
Scores and multiplier font works like animated sprites.
You need to put all the numbers, an X, a dot, and a coma in the same picture. All numbers need to have the same size, like 32×32, or 32×64 for example.
Score pictures should be saved in Assets / Pictures.
An 832×64 pixels picture:
A 416×32 picture: