About Kyrandia 2, FNT Files (Kyra Engine).

General chat related to ScummVM, adventure gaming, and so on.

Moderator: ScummVM Team

Post Reply
User avatar
Ondinha
Posts: 4
Joined: Thu Aug 14, 2008 2:31 pm
Location: São Luís - Maranhão - Brazil
Contact:

About Kyrandia 2, FNT Files (Kyra Engine).

Post by Ondinha »

As you already know, I'm developing a tool to help the translation of Kyrandia 2 to Brazilian Portuguese, according this thread: Kyrandia PT-BR thread, that contains images of my progress too.

For now, the tool can:
  • * Unpack/Repack *.PAK files (like dekyra)
    * Extract/Insert *.TXT from *.DL* files
    * Extract *.TXT from *.EMC files (I'm working in insertion)
But I've a little problem, my language uses Latin-1 Charset, and the game doesn't have support for this Charset, so I've to add by reverse the egineering of the *.FNT(6.FNT, 8FAT.FNT, BOOKFONT.FNT) Files.

Looking to the file internals, I don't have any idea on how to proceed, so, I've to look at Kyra Engine source code, to get any, and the file starts do make a little sense.

Code: Select all

	if (!fontData || !sz)
		error("couldn't load font file '%s'", filename);

	uint16 fontSig = READ_LE_UINT16(fontData + 2);

	if (fontSig != 0x500)
		error("Invalid font data (file '%s')", filename);

	fnt->charWidthTable = fontData + READ_LE_UINT16(fontData + 8);
	fnt->charSizeOffset = READ_LE_UINT16(fontData + 4);
	fnt->charBitmapOffset = READ_LE_UINT16(fontData + 6);
	fnt->charWidthTableOffset = READ_LE_UINT16(fontData + 8);
	fnt->charHeightTableOffset = READ_LE_UINT16(fontData + 0xC);

	return true;
The font data is stored on a Buffer, and the reads have to be made in a Little Endian order.
  • * The first two bytes are the filesize;
    * The 3rd and 4º are a kind of signature;
    * 5º and 6º charSizeOffset;
    * 7º and 8º charBitmapOffset;
    * 9º and 10º charWidthTableOffset;
    * 11º and 12º don't have in reference (maybe the end of charWidthTable?)
    * 13 and 14º charHeightTableOffset;
The charSizeOffset, looking to the functions getCharWidth and getCharHeight, I think the first is the Height and the second is the Width.

I looking for more details about...
* What's the charWidthTableOffset and charHeightTableOffset, what the purpose of this two tables?
* What's the 11º and 12º bytes(fontData + 0xA)? Is really the end of charWidthTableOffset?
* And the charBitmapOffset? Is the whole bitmap including tables?

My idea is convert the *.FNT Files to *.BMP, add the Latin-1 characters and convert the *.BMP into a new *.FNT.

Thanks in advance!
Sandro
User avatar
LordHoto
ScummVM Developer
Posts: 1029
Joined: Sun Oct 30, 2005 3:58 pm
Location: Germany

Re: About Kyrandia 2, FNT Files (Kyra Engine).

Post by LordHoto »

Ondinha wrote: * What's the charWidthTableOffset and charHeightTableOffset, what the purpose of this two tables?
It's the specific offset to the tables for the width and height of a specific glyph. Just check Screen::getCharWidth and Screen::drawCharANSI.

charSizeOffset is only the offset to the 'global' font width/height.
Ondinha wrote: * What's the 11º and 12º bytes(fontData + 0xA)? Is really the end of charWidthTableOffset?
Actually no idea, it isn't used in the original either :-).
Ondinha wrote: * And the charBitmapOffset? Is the whole bitmap including tables?
It's a offset table into the glyph gfx data. For the format of a glyph check Screen::drawCharANSI.
User avatar
Ondinha
Posts: 4
Joined: Thu Aug 14, 2008 2:31 pm
Location: São Luís - Maranhão - Brazil
Contact:

Post by Ondinha »

Thank you! I'll try to implement my idea and I'll post about the progress.
Post Reply