Game Development Community

Anti-aliased text?

by Vern Jensen · in Torque Game Builder · 10/27/2008 (1:42 pm) · 9 replies

Is there any way to get anti-aliased text in Torque? (Presumably using t2dTextObject, but I'm open to other options as well, if there are any.) It seems the characters created with t2dTextObject are jagged and sharp, not anti-aliased, and I don't see any option for turning this on. (It would just create an alpha mask for the sprite that is a better alpha mask.)

#1
10/28/2008 (9:17 pm)
I believe text objects are always unfiltered in TGB. If you want anti-aliased or filtered text your best option is to convert your text to images.

If you use a large enough font size you might be able to get away with regular text objects and they'll still look smooth.
#2
10/29/2008 (5:45 am)
I'm struggling with my fonts as well in the same manner. I'm trying to output an image from a font in TGB which I believe should work. Not entirely sure how to tell a t2dTextObject to use an image as a font but it's there somewhere.

Struggling to output my font as an image in the first place but search for FontBoy and you might have more luck with it than I did (guis not showing up).

Not much help really, sorry but am just starting to look at this here. It might point you in the right direction though.
#3
10/29/2008 (1:34 pm)
Thanks Connor, that's what I'm actually in the process of doing (using a sprite-based alphabet), just wanted to make sure it was necessary.

BTW, do you know if that's what TGB does for t2dTextObjects anyway? In other words, by using a sprite-based alphabet, am I not taking up any more RAM/VRAM than I would with a regular t2dTextObject anyway?
#4
11/21/2008 (8:50 pm)
Torque converts .ttf fonts into a .uft file, which I believe is basically a big tile-mapped image, with no filtering. I'm not 100% sure of this, as I can't view .uft files.

PacManiac - you can't use an image as a t2dTextObject, instead you write your text in photoshop and save the whole thing out as an image which is a t2dImageMap in tgb. If you need lots of different text you might have to save out each letter as an image and write your own text handling code, which is a big pain.

I recommend using pixel fonts that don't need anti-aliasing when using t2dtextobjects. You can find lots of free ones at www.aenigmafonts.com.
#5
11/24/2008 (12:47 am)
Conor - FontBoy saves out the font as a bitmap for editing and I thought you could then use that as a basis for your font? Are you saying if I manage to do that I'll need to convert the image back again to utf or something?

It's a real shame with t2dTextObjects not handling AA. Makes it pretty useless for me unless I can get the above to work out. Do you always use the GUI text controls then?

Still yet to finish my first game so not sure what the best approach is to many things.. thanks for the input!
#6
11/30/2008 (8:11 pm)
PacManiac - if I need to do anti-aliased fonts I export the text as images from photoshop (see www.droneswarm.com) but if I want non-anti-aliased pixel fonts then I use Torque's built-in text object (see www.harpooned.org).

I've never used the GUI text or any GUI stuff at all so far.
#7
11/30/2008 (8:27 pm)
I believe that TGB's font rendering system relies on converting the font's character set into a bitmap to store in its memory. This means that it you need to specify what font size you actually want to render. This is very different from the line height or height of the t2dTextObject itself.

I belive that you have to specify the "fontSizes" parameter on the actual text object itself. This parameter is a space separated list so you can specify multiple font sizes for one object (this is handy for when you try to resize the object after a resolution change).

Here is a quick idea of what you need to do when specifying this parameter: If you are running TGB's default resolution and camera size (res: 800x600, camera: 100x75) then each TGB unit is 8px by 8px. If your t2dTextObject is 10 units high, this corresponds to a font height of 80px. In this case you would want to set your fontSizes field to something close to 80 (72 is the closest off hand). If your resolution is changed to 1024x768, then your unit size is actually 10.24px by 10.24px and thus your t2dTextObject's font size should be 10 units high times 10.24 = 102.4.

It would be best to size your text object to the actual font size that you're using. Lets say you are trying for a large font, size 72. You should change your text object's size to 7.2 units high in the first example or 7.03 units in the second.

I believe that this is the kind of thing you have to do, but I haven't messed with this stuff for a while.

The FontBoy tool exports the font's character set as a physical file for you to load into the game later. You would do this for when you distribute a game and cannot bank on the user having the font that you are using on their system, or if you want to tweak the characters in Photoshop or equivalent. It also means that for each font size that you wish to use on your text object, you will need to export and tweak it!
#8
12/18/2008 (2:05 pm)
I created my own font-rendering scripts, loading in my own ImageMaps. The result is a MUCH better looking font in the end, since it is anti-aliased, versus t2dTextObjects which are not.
#9
12/21/2008 (3:19 pm)
With t2dTextObjects the user actually does not need to have your font installed on their system. You can probably also get away with using one font size per font.

If you want to write your own font scripts and just use images go for it. They would be easier to work with and probably look better being anti aliased. I do believe there are other advantages to using t2dTextObjects, like performance, and maybe some unicode support. Though these issues may not matter to you depending on the project. I am really not really an expert on the TGE font system, despite my being the one who made the font tool.