Game Development Community

Using a custom font?

by Vern Jensen · in Torque Game Builder · 08/07/2008 (2:38 pm) · 8 replies

Just wondering if it's possible to use a custom font with Torque. I have a font file in .TTF format, but it's available in other formats as well. If possible, where do I put the font file, and what must I do to load it? (Either for use with t2dTextObject, or any other way of displaying text is fine too.)

#1
08/10/2008 (8:54 pm)
In the past, I've simply installed the font into my "Windows/Fonts" directory. Torque just picks them up. I then use "Inno Setup" to make my installer program. It has an option to pick a font from your fonts directory to be installed on the user's computer.

NOTE! Make sure that you have distribution rights to the font.
#2
08/10/2008 (10:44 pm)
I just came across Font Boy in the Resources section a couple of days ago. With it installed, you can use any font you have on your system and it'll create a UFT in your game's fonts folder in each size required for your game. Neat little tool.
#3
08/14/2008 (12:39 am)
I'm trying to use font boy as well in 1.7.3 but struggling to get it to start up. Anyone having problems with it in a newer version of TGB?

I get the icon (without the F, which is expected) but clicking on it wont do anything. If I open the GUI builder and then open the first gui for FontBoy there, close GUI builder, and run it again it seems to work all of a sudden. I only get one font choice and one size choice however..

Seems like a great tool though.
#4
08/17/2008 (2:51 pm)
Not sure what the problem is. I also got the button without the F, but when I clicked it I was able to select the font and size, click ok, then click the button again to see the result, just as the instructions indicated. I don't know if it makes a difference, but did you reload the project after adding the resource?
#5
08/21/2008 (1:57 pm)
FontBoy works for me in TGB 1.7.2 for Mac.

Question though: it seems like I can just drop the font I want to use into my system's fonts folder, start up TGB, create a t2dTextObject using it, and then Torque automatically creates a font for me in:

~/common/data/fonts/

I seem to remember reading somewhere that TGB does this so that even if you package your game and run it on a system without that font, it will still work. So I don't think I need FontBoy, do I? I'm confused.

-Vern
#6
08/21/2008 (2:36 pm)
How do you make a custom font?
#7
08/21/2008 (4:19 pm)
Wow - I was just reading through Amanda's Gui Resolution tutorial on TDN and came across this little gem towards the bottom.

// populate fonts
   %font = "Casper Comics";
   %sizes = "10 14 16 20 22 24 26 30 36 42 72";
   for (%i = 0; %i < getWordCount(%sizes); %i++)
      populateFontCacheRange(%font, getWord(%sizes, %i), 32, 126);
   writeFontCache();

It looks like this achieves the same thing. Casper Comics is a font I have installed into Windows, and popping the above code into my main.cs initializeProject function has just generated UFT files in all of those sizes. This makes it so easy! I really need to spend more time exploring all those tutorials...
#8
08/21/2008 (7:51 pm)
Yup all fontboy does is automate the use of that function, and importing of the fonts. Once you do it one time the font can be used on any machine whether or not they have that font installed for their operating system. Torque uses its own font format.