Westwood Font Format v3

From ModdingWiki
Jump to: navigation, search
Westwood Font Format v3
Cc vcr.png
Format typeTileset
HardwareVGA
Max tile count256
PaletteExternal
Tile names?No
Minimum tile size (pixels)0×0
Maximum tile size (pixels)255×255
Plane count1
Plane arrangementLinear
Transparent pixels?Yes
Hitmap pixels?No
Metadata?None
Supports sub-tilesets?No
Compressed tiles?No
Hidden data?Yes
Games

This is the third type of bitmap font created by Westwood Studios, used in the Lands of Lore and Legend of Kyrandia series and in their early RTS games. It is a 4-bit-per-pixel font with a variable amount of characters, which allows the separate symbols to specify their width, height and Y-offset.

File format

Header

The font format starts with the following header.

Offset Data type Name Description
0x00 UINT16LE Size File size.
0x02 BYTE DataFormat Data format. 0x00 for v3, 0x02 for v4.
0x03 BYTE SigByte1 Signature byte. Always 0x05.
0x04 BYTE SigByte2 Signature byte. Always 0x0E.
0x05 BYTE SigByte3 Signature byte. Always 0x00.
0x06 UINT16LE OffsetsListOffset Offset of the array of data offsets.
0x08 UINT16LE WidthsListOffset Offset of the array of symbol widths
0x0A UINT16LE FontOffsetStart Offsets are relative to this value. 0x00 for v3.
0x0C UINT16LE HeightsListOffset Offset of the array containing the symbol heights and Y-offsets.
0x0E UINT16LE Unknown Unknown. Always 0x1012.
0x10 BYTE Unknown Unknown. Always 0x00.
0x11 BYTE NrOfChars Number of characters. Actually, this is the byte value of the last character in the list, so the real number of characters is this value plus one.
0x12 BYTE Height Overall font symbols maximum height, in pixels.
0x13 BYTE Width Overall font symbols maximum width, in pixels.

Following this header are the referenced arrays and the font data, normally in this order:

  • Array of UINT16LE values indicating the offset of the data for each symbol, technically relative to FontOffsetStart, though the v3 fonts always have 0x00 in that field. The start offset of this list is specified by OffsetsListOffset
  • Array of byte values indicating the symbol widths, in pixels. The start offset of this list is specified by WidthsListOffset
  • Array containing two bytes per entry; the first being the Y-offset, the second the height in pixels. The start offset of this array is specified by HeightsListOffset
  • Actual symbol data referenced in the offsets list

However, since the game just follows the offsets as it reads them, this order probably doesn't really matter.

The font data is uncompressed, but it is optimised by making the offsets for any identical symbols in the font refer to the same data. This technique allows the use of filler symbols without a large increase in file size, and allows fonts with no difference in upper and lower case to expose the same data for both.

Image data

The actual font data is 4 bit per pixel, and always uses the minimum stride per line, so, for example, a font with a width of 5 will require 3 bytes to contain all five nybbles, and will have these three bytes for each line, without optimising a next line's start-nybble into the unused end of the previous line's byte. The general method of calculating the minimum stride for any bit-per-pixel value under 8 is (width * bpp + 7) / 8.

For each byte, the lowest nybble is the leftmost of the two pixels, which might seem counterintuitive when compared to the way the bytes are viewed in a hex editor.

Tools

The following tools are able to work with files in this format.

Name PlatformView images in this format? Convert/export to another file/format? Import from another file/format? Access hidden data? Edit metadata? Notes
Westwood Font Editor WindowsYesYesYesNoN/A Created by Nyerguds