The .WFN font file format

Started by Denzil Quixode, Mon 28/06/2010 20:17:55

Previous topic - Next topic

Denzil Quixode

I've been working on a new experimental editor plugin that involves exporting various stuff from the loaded game. It's going pretty well, but I've hit a problem - see, I'd like to be able to export a game's SCI fonts in a custom format. I thought there'd be no problem, since there is information online about the format of SCI font resource files, and I could just follow that. But I just realised that the .WFN font files that get created when you import a SCI font are actually a custom format, not simply the SCI font renamed like I assumed :P

So... does anyone have a technical description of what a .WFN file contains? I mean, at the level of bits-and-bytes, endianness, signed/unsigned integers, that kind of deal. I have tried to look online but could not find anything. I'd really appreciate it!

Jim Reed

Radiant made a font editor.
Maybe he can offer some help.

The editor supports .WFN files

Denzil Quixode

;D I sent Radiant a PM first, before I made the thread. He said he couldn't remember and to ask here, instead...

Rulaman

Radiant could you send his source code.

I did also a little research in the net.
I found out about 50 percent by investigate the differences.
I haven't a doku, but I could send you my information and some source code.

So I have the byte-order and the bytelength.
But There is alo a tail, I didn't know about.

Code: ags

|----------|
|    ok    |
-----------|
|  not ok  |
|----------|
Zak: Komm mit mir Sushi.
Zak: Come with me Sushi.

Denzil Quixode

Quote from: Rulaman on Tue 29/06/2010 07:40:18
I did also a little research in the net.
I found out about 50 percent by investigate the differences.
I haven't a doku, but I could send you my information and some source code.
Yes, if you would, that would be very helpful! I don't mind informal/incomplete info.

Quote
So I have the byte-order and the bytelength.
But There is alo a tail, I didn't know about.

Code: ags

|----------|
|    ok    |
-----------|
|  not ok  |
|----------|


You mean, data right at the end of the file with no obvious purpose?

Rulaman

Quote
You mean, data right at the end of the file with no obvious purpose?
Yes

Hi Denzil Quixode ,


I didn't have much Information, but I could write it down.
for the first step you could have a look at my code. Code
Its not the best, because it was only for testing purposes.

But for short "WGT Font file  "<length of file>
the length is encoded in big endian and the upper byte is one bigger.
Example: "WGT Font File  " 7406(Hex) the length of the file is 1908Bytes  0774(Hex) -> 74 07 [swapped] and one minus -> 7406

Then it goes (129 chars) [see code] width (Byte) Height (Byte) <bytes to decribe the char>
if the width is smaller than 4, so only one nibble is encoded, if the char is smaller than 8 so one byte is encoded [see code]

so far so good  ;D

If you found out more, please tell me.

There are some Qt specific parts. Please ignore them. The important thing is the code itself.
Code

Greetings
Rulaman
Zak: Komm mit mir Sushi.
Zak: Come with me Sushi.

smiley

Quote from: Rulaman on Tue 29/06/2010 19:47:47
the length is encoded in big endian and the upper byte is one bigger.
Looks more like the offset of the footer (little endian).

The footers (256 bytes) contains the offsets of the 128 char descriptions (2 bytes, little endian).

Denzil Quixode

#7
Aha! Ok, thanks to you both. This is what I've pieced together now:

(All addresses are little-endian 16-bit integers.)

Header (start of the file)

  • First 15 bytes: "WFN Font Format  " (note: extra two spaces at the end) encoded in ASCII.
  • Immediately followed by: Address of the start of the character address table.
Character Address Table

  • A simple array of addresses to each character.
  • The table ends at the end of the whole file. (The number of characters never seems to be mentioned. I'm not sure if that means the number of characters is ((length of file - start of character address table)/2), or if it is permanently hardcoded to 128.)
Character

  • 16-bit little-endian int: width of character
  • 16-bit little-endian int: height of character
  • Bitmask: (height * RoundUp(width / 8.0)) bytes of data

Pumaman

The WFN font format goes back to the very early DOS days of AGS, when it was written using something called the Wordup Graphics Toolkit, which had its own custom WFN font format. Of course, AGS no longer uses WGT, but it still uses the same font files!

Glad to see you've pieced it together yourself, if you need any more info let me know.

SMF spam blocked by CleanTalk