THAW FNT3 Format - Specification

THUG+ discussions can go here, about modding, or what ever you want
Barti
Posts: 8
Joined: Wed Sep 26, 2012 7:17 am

THAW FNT3 Format - Specification

Postby Barti » Tue Jan 21, 2014 5:09 am

Hi everyone,

This is a project I have started a long time ago (back when Demo's FNT Tool came out). I kept putting it off for a long time because I was still a n00b at reversing file formats and couldn't wrap my head around the concept of floats :lol: . I have lots of free time now and I decided to finish up the specification and get it out there.

For those who don't know, FNT3 is a font format used by THAW. It is very different from the FNT1 and FNT2 formats used from THPS3 to THUG2. I worked on this format because I wanted to be able to convert fonts between FNT1/2 and FNT3. I might create a converter when I stop being lazy :( .

Without further ado, here is the FNT3 Specification:

Code: Select all

Header
{
   long FontVShift;
   long FontHeight;
   long LetterDataOffset;
   ubyte ASCIITable[288];
   byte Unknown[76]
   long PalettedIMGOffset;
};

LetterData // * (PalettedIMGOffset - LetterDataOffset) / 24
{
   float TopLeftX;
   float TopLeftY;
   float BottomRightX;
   float BottomRightY;
   short XStretch;
   short YStretch;
   short VShift;
   short Unknown;
};

PalettedIMGHeader
{
   byte FourCC[4];
   short Unknown; // Maybe compression type, can't remember
   short Unknown; // Maybe compression type, can't remember
   long Empty;
   short Width;
   short Height;
   short Width;
   short Height;
   long Unknown; // Maybe compression type, can't remember
   long PaletteSize;
};

IMGPalette // * PaletteSize
{
   byte Red;
   byte Green;
   byte Blue;
   byte Alpha;
};

IMGBitmap
{
   short Width;
   short Height;
   byte ColorFromPalette[Width*Height];
};


Converting letter coordinates between FNT1/2 and FNT3:

Code: Select all

FNT1/2 (short) to  FNT3 (float)
charXShift = TopLeftX = charXShift / bitmapWidth
charYShift = TopLefyY = charYShift / bitmapHeight
charLength = BottomRightX = (charXShift + charLength) / bitmapWidth
charHeight = BottomRightY = (charYShift + charHeight) / bitmapHeight

FNT3 (float) to  FNT1/2 (short) // Note that you're losing accuracy this way as the numbers have to be rounded!
TopLeftX = charXShift = TopLeftX * bitmapWidth
TopLeftY = charYShift = TopLeftY * bitmapHeight
BottomRightX = charLength = BottomRightX * bitmapWidth - TopLeftX * bitmapWidth
BottomRightY = charHeight = BottomRightY * bitmapHeight - TopLeftY * bitmapHeight


The ASCII Table holds Letter IDs from the font and uses them like this:

Code: Select all

Offset (ASCII Value) - Font ID
0x30 ("0") - ID of the character 0 in your font
0x41 ("A") - ID of the character A in your font


Hopefully my explanation is easy to understand, I'm terrible at explaining things :mrgreen:

User avatar
Demo
VIP
Posts: 278
Joined: Thu Aug 25, 2011 5:54 am
Contact:

Re: THAW FNT3 Format - Specification

Postby Demo » Tue Jan 21, 2014 7:07 am

great, will look into it later. if this one is correct i'll add thaw support in fnt tool.
i've added thaw font bitmap loading support back then, but didn't figure out the ASCII table and the rest, so i didn't release that version.

my progress on the format was smth like that xD

Code: Select all

dword
dword
dword - offset

***

dword - offset

***

28 bytes - unknown

1024 bytes - palette
word - width
word - height

width*height bytes - bitmap

bAstimc
VIP
Posts: 132
Joined: Thu Jun 10, 2010 2:33 pm

Re: THAW FNT3 Format - Specification

Postby bAstimc » Fri Jan 24, 2014 6:33 am

lol @ demo :D


Return to “THUG+”

Who is online

Users browsing this forum: No registered users and 5 guests