Thief Font Converter - create font files for Dark Engine based games

usage: thieffon -c [-m|-a] [-s] [-f num] [-b num] [-p num] [-w num] image_file fon_file
       thieffon -d [-b num] [-p num] [-w num] fon_file image_file [pal_file]

       -c      Create a font file from an image file.
       -d      Create an image file from a font file.
               The external palette file is optional.
       -m      Write a monochrome font. Any non-black pixel will be set.
       -a      Write an anti-aliased font.
       -s      When creating an 8bpp font, use the standard Thief palette.
       -f num  Specify the character code for the first glyph.
               Default is 0.
       -b num  The color table index of black (background).
               Default is 0.
       -p num  The color table index of pink.
               Default is 254.
       -w num  The color table index of white (foreground).
               Default is 1.

It's called "Thief Font Converter", but the same font format is used in 
System Shock 2. In fact, it goes all the way back to the original System 
Shock game for DOS!

Only MSWindows-style BMP files with 8 bits-per-pixel are supported for image 
files. Since font files don't contain any color information, you need to 
supply an external palette when deconstructing a font. Palettes may be in 
Microsoft RIFF format, JASC format, or Adobe ACT. If the palette file name 
is omitted, the standard Thief palette is used. Anti-aliased fonts convert 
better if you don't specify a palette.

Thief uses CP850 (MS-DOS, Western European) character codes, although the 
standard fonts don't contain all of the glyphs. The fonts included with 
Thief have the glyphs for 0xA4 and 0xA5 (lower-case and upper-case N with 
tilde) reversed.

Font images contain all the glyphs of the font with each one surrounded by 
a pink box. You should have at least one pixel of blank space around each 
pink box, or it might not be recognized. Glyphs are scanned left-to-right and 
top-to-bottom. Glyphs of varying height are allowed. The font size will be the 
height of the largest glyph, with the lower portions of short glyphs filled 
with the black color. Black should always be 0 when creating fonts.

"Pink" is a relative term, and can be any color, only the index in the color 
table is read. Normally, pink is index 254, but can be changed. White is only 
used when converting a monochrome font to an image. Black should be 0 when 
creating a font, or it might not display properly in Thief.

The color of a monochrome or anti-aliased font is determined by the game. 
Regular 8bpp fonts will be displayed using the current palette (which, in 
Thief 2, may not always be the standard palette). Use the -s argument to make 
the font always display with the standard palette. 

Most UI font names are defined in DARK.CFG (or SHOCK.CFG). On-screen text is 
displayed using `TEXTFONT.FON'. This font cannot be anti-aliased, and since 
8bpp fonts ignore custom colors, then it should only be monochrome. The font 
used for map notes in Thief 2 is `f_scrp12.fon'. Book fonts, of course, are 
looked for in the resource path.

WFon.exe can be used to create font images from installed Windows fonts.
It's rather buggy, I'm afraid, and you'll almost always have to fix the 
image before it can be used to build a font. It starts by prompting you to 
select the font, foreground and background colors, and whether the glyphs 
should be anti-aliased. Normally, WFon will print the CP850 character codes,
starting with 0x20 (space). Alternatively, you can select a file with the 
characters to use. The file must be UCS-2 encoded, and only the first 256 
characters will be used. The characters CR (0x0D) and LF (0x0A) are ignored,
so you can break the lines when creating the file. Non-spacing characters 
count as a single character.

Adobe Photoshop reads and writes the color table of PCX files backwards. 
In the standard Thief palette, color index 1 is white and index 254 is pink.
revpal.exe can be used to invert the color table of a palette file or a 
BMP file. There are no command-line options, you can just drag-and-drop the 
files you want to convert.

boxer.exe extracts rectangular regions from an image. This is similar to the 
LGS program cutout.exe, and boxer can be made to act identically. Boxer can 
handle many more ways of outlining regions, including partial boxes and 
mattes. It reads 8-bit PCX, 8-bit BMP, or 24-bit BMP images and will write 
the in the same format as the output. By default, the color of the upper-left 
pixel is taken to be the matte color and any region enclosed by that color 
will be extracted. The area surrounding the image is assumed to be the matte 
color. With the -i option, only internally enclosed regions are extracted. 
This usually just has the effect of not extracting the entire image as if it 
were a region. The matte color can be changed with the -c option, the color 
value is specified as red, green, and blue components separated with commas. 
The -p option is shorthand for "-c 255,0,255". The -m option will use color 
index 0. Except for -c, options can be combined into a single switch. So 
"boxer -pi rect.pcx" is the same as "boxer -p -i rect.pcx", which happens 
to be the cutout-emulation mode. And if you aren't getting the results you 
expect, add one, two, or three -v switches to have boxer print more detailed 
messages.
