Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Denzil Quixode on Mon 28/06/2010 20:17:55

Title: The .WFN font file format
Post by: Denzil Quixode on Mon 28/06/2010 20:17:55
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 (http://wiki.scummvm.org/index.php/SCI/Specifications/Graphics/Font_resource), 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!
Title: Re: The .WFN font file format
Post by: Jim Reed on Mon 28/06/2010 23:42:36
Radiant made a font editor. (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=23521.0)
Maybe he can offer some help.

The editor supports .WFN files
Title: Re: The .WFN font file format
Post by: Denzil Quixode on Tue 29/06/2010 01:35:51
;D I sent Radiant a PM first, before I made the thread. He said he couldn't remember and to ask here, instead...
Title: Re: The .WFN font file format
Post by: Rulaman on Tue 29/06/2010 07:40:18
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.


|----------|
|    ok    |
-----------|
|  not ok  |
|----------|
Title: Re: The .WFN font file format
Post by: Denzil Quixode on Tue 29/06/2010 10:40:34
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.


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


You mean, data right at the end of the file with no obvious purpose?
Title: Re: The .WFN font file format
Post by: Rulaman on Tue 29/06/2010 19:47:47
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 (http://www.file-upload.net/download-2636677/main.cpp.html)
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 (http://www.file-upload.net/download-2636677/main.cpp.html)

Greetings
Rulaman
Title: Re: The .WFN font file format
Post by: smiley on Wed 30/06/2010 08:17:06
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).
Title: Re: The .WFN font file format
Post by: Denzil Quixode on Wed 30/06/2010 12:34:19
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)
Character Address Table
Character
Title: Re: The .WFN font file format
Post by: Pumaman on Mon 12/07/2010 21:13:20
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.