AAF File Format

The AAF file format stores bitmap fonts used by Fallout and Fallout 2. This page describes the English-version files; localized releases may contain variations that are not covered here.

An AAF file stores one glyph descriptor for each of the 256 byte values. Glyphs are usually proportional: each glyph has its own width and height. The glyph bitmap is stored as one byte per pixel, with values in the range 0 through 9.

The following bitmap is a glyph from FONT1.AAF representing the character b (ASCII 98):

  77
  77
  777763
  77  76
  77  77
  77  76
  777763

Pixels with value 0 are omitted because they are transparent. The values 7 and 6 mark brighter parts of the glyph, while 3 is dimmer and appears around the rounded corners.

All integer fields are stored in Motorola / big-endian byte order. The file starts with a 12-byte header followed by 256 glyph descriptors. Each descriptor is 8 bytes: width, height, and an offset relative to the start of the glyph data block. The glyph data block starts at 0x000C + 256 * 8 = 0x080C.

AAF viewer

The viewer below reads an uploaded .aaf file, validates the header and glyph descriptors, and renders both a text preview and a 256-slot glyph grid. Pixel values are shown as brightness levels of the selected foreground color.

Maximum glyph height-
Horizontal gap-
Space width-
Vertical gap-
Glyph data size-

Text preview

Glyph grid

OffsetBytesData TypeDescription
0x0004char[4] = "AAFF"Signature used to identify the file type.
0x0042unsigned shortMaximum glyph height, including ascenders and descenders.
0x0062unsigned shortHorizontal gap, in pixels, added between adjacent glyphs.
0x0082unsigned shortWidth, in pixels, used for the space character.
0x00A2unsigned shortVertical gap, in pixels, added between two lines of glyphs.
0x00C2unsigned shortWidth, in pixels, of glyph 0.
0x00E2unsigned shortHeight, in pixels, of glyph 0.
0x0104unsigned longOffset of glyph 0, relative to the glyph data block at 0x080C. If width * height = 0, this can be the offset of the next non-empty glyph.
0x0142unsigned shortWidth, in pixels, of glyph 1.
0x0162unsigned shortHeight, in pixels, of glyph 1.
0x0184unsigned longOffset of glyph 1, relative to the glyph data block at 0x080C.
0x01C(2 + 2 + 4) * (256 - 2)Descriptions of glyphs 2 through 255, as described above.
0x80CGLYPH-0-WIDTH * GLYPH-0-HEIGHTbyte = [0..9]Pixel data for glyph 0. Pixels are stored left to right, then top to bottom. Each pixel is one byte in the range 0 through 9.
0x080C + (GLYPH-0-WIDTH * GLYPH-0-HEIGHT)GLYPH-1-WIDTH * GLYPH-1-HEIGHTbyte = [0..9]Pixel data for glyph 1.
0x080C + (GLYPH-0-WIDTH * GLYPH-0-HEIGHT) + (GLYPH-1-WIDTH * GLYPH-1-HEIGHT)...byte = [0..9]Pixel data for glyphs 2 through 255, as described above.

Parsing notes

The AAFF signature identifies the file type. After the 12-byte header, the descriptor table always contains 256 entries and therefore always ends at 0x080C. Descriptor offsets are relative to this glyph data block, not to the beginning of the file.

Each glyph consumes width * height bytes. A NULL glyph has no pixel data of its own, and its offset can be the same as the next glyph with data, so readers should use width and height to decide whether to read pixels.

AAF stores glyph brightness, not final palette colors. At render time, the engine blends each non-zero pixel value with the selected text color.

Runtime notes

In Fallout 2 CE, the AAF loader attempts to load interface fonts named font0.aaf, font1.aaf, and so on. The interface font manager exposes AAF fonts as font ids 100 through 110, separate from the FON text font manager.

When rendering a string, a space character uses the header's space width field instead of the width in glyph descriptor 32. Each character advances by its character width plus the horizontal gap. The line height reported by the engine is the maximum glyph height plus the vertical gap.

Glyph pixels are bottom-aligned within the maximum glyph height. If a glyph is shorter than the maximum height, rendering skips the difference before drawing that glyph's rows.

AAF and FON comparison

FeatureAAFFON
Typical roleInterface font managerLow-numbered text font manager
Typical filesfont0.aaf and other interface font filesfont0.fon through font9.fon
Font id range100 through 110 in Fallout 2 CE0 through 9 in Fallout 2 CE
Glyph slotsAlways 256 descriptor slotsGlyph count is stored in the file header
Pixel dataOne byte per pixel; values 1 through 9 represent brightness levels1 bit per pixel; set bits draw the chosen text color
Integer byte orderBig-endian 16-bit and 32-bit integersLittle-endian 32-bit integers

Source code

Fallout 2 Community Edition AAF interface font manager - C++

History

Fallout 2 Community Edition FON text font manager - C++

2019-12-16 - Ported from https://falloutmods.fandom.com/wiki/AAF_File_Format by ghost Patched by Anchorite (anchorite2001@yandex.ru) Created by Noid (noid@888.nu)