Game Development Community

Font export bug (core engine)

by Michael Woerister · in Torque Game Builder · 04/28/2006 (9:14 am) · 5 replies

Hi,
the either GFont::exportStrip() or GFont::importStrip() or both are bugged.
Repro:

- delete all files from the font cache directory
- type the following in the console:
// add some characters to the cache
 populateFontCacheString("Arial",20,"abcdefgh");

 // export it 
 exportCachedFont("Arial",20,"test/arial1.png",2,2);

 // import it again with or without modifying it 
 importCachedFont("Arial",20,"test/arial1.png",2,2);

 // add some more characters
 populateFontCacheString("Arial",20,"xyz");

 // export again
 exportCachedFont("Arial",20,"test/arial2.png",2,2);

The first export gives expected results:
www.unet.univie.ac.at/~a0402917/arial1.png
But the second is messed up:
www.unet.univie.ac.at/~a0402917/arial2.png
This does not happen if you leave out the importCachedFont call, so I guess the error must be in GFont::importStrip().

EDIT: I just noticed that the last character ('h' and 'z') did not get exported. Seems to be another error.

#1
04/28/2006 (3:40 pm)
Once you have imported a cached font with importCachedFont(...) the weights are set in that font so any future calls to importCachedFont(...) with the same font name/size would then have a weight of 0. The first time you call with a weight of 3 for example then that weight is built into the font - so calling it with weight 3 again makes it get off on character locations.

I can't rember off the top of my head if any of the parameters in your calls above are weights, but if they are then this could be your problem.
#2
04/29/2006 (2:10 am)
The parameters above are for kerning and padding. The source comment for GFont::importStrip says "Import an image strip generated with exportStrip, make sure parameters match!". So if parameters match, everything should work. I can't find anything like weight in the GFont class. I think weight is only applied when a character is retrieved from the OS and it is always zero (see WinFont::create() in winFont.cc).
#3
04/29/2006 (7:37 am)
Sorry, used the wrong parameter name, weight is the same as padding.

Take a look here at the note on importCachedFont().

Not sure if this could be your problem, but Alex and I had a problem with importing fonts because we weren't handing the importing/exporting with padding correctly.

In looking at your example "abcdefgh" should end up with a padding of 4 and "xyz" should have a padding of 2.

(edit:typo in link)
#4
04/29/2006 (9:36 am)
Thanks for hint Kevin. I'll take a closer look at this when I get time. (Unfortunatly I cannot access that TDN page as I don't have a TGE license).

Thanks again.

-Michael
#5
05/01/2006 (12:38 pm)
Ok,
I've read the note (thanks again, Justin :). It says something like this actually I don't call importCachedFont() twice but only once... I still think it is a bug. And if it isn't then the whole thing is way too crude for me to use. Maybe I'll try to write more stable and usable functions on my own.