1. Architectural Role & Engine Purpose
The FNT (Font File) format stores font glyph metrics, character kerning data, and raster atlases in Project I.G.I. 1.
FNT files provide the typography for tactical on-screen displays, mission objectives, computer terminal hacking interfaces, ammo counts, and subtitles. The format maps ASCII characters (0–255) to precise pixel coordinates within a packed texture atlas.
2. Binary File Layout & Memory Map Diagram
An FNT file contains a font descriptor header, a 256-entry glyph metrics table, and the raw font atlas bitmask:
3. Text Rendering & Quad Emission Pipeline Diagram
When DrawString("OBJECTIVE COMPLETE") is called, the font renderer transforms characters into Direct3D quads:
4. Architectural Mechanics & Engine Implementation Details
The FNT format was designed for minimal batching overhead:
- Single-Pass Batching: Entire sentences or HUD dialogue blocks are transformed into a single dynamic vertex buffer containing all character quads, rendering the entire UI in a single Direct3D draw call.
- Fixed-Width Fast Path: Monospaced military fonts (used for terminal hacking and coordinate readouts) bypass kerning calculations entirely, executing at peak frame rates.
5. C++ Struct Definitions
#pragma pack(push, 1)
struct FntHeader {
uint16_t font_height; // Line height in pixels
uint16_t baseline; // Distance from top to text baseline
uint16_t first_char; // Typically 32 (Space)
uint16_t last_char; // Typically 255
uint16_t atlas_width; // Width of font texture atlas
uint16_t atlas_height; // Height of font texture atlas
uint32_t flags; // 0=1-bit, 1=8-bit alpha
};
struct FntGlyphMetric {
uint16_t width; // Glyph pixel width
uint16_t height; // Glyph pixel height
int16_t x_advance; // Horizontal cursor step
int16_t bearing_x; // Left side offset
int16_t bearing_y; // Top offset relative to baseline
uint16_t u0, v0; // Top-left atlas texel coordinates
uint16_t u1, v1; // Bottom-right atlas texel coordinates
};
static_assert(sizeof(FntHeader) == 16, "FntHeader must be 16 bytes");
#pragma pack(pop)