EGA Font format

From ModdingWiki
Jump to: navigation, search

The 'EGA Font format' is used to store a monochrome font used in many Softdisk and ID Software games. While the font is functionally monochrome is is related to EGA and used solely by EGA games. There are two versions of the font, differing slightly in format. This is because the first format was dropped due to limitations in what it could display (256 characters of one color) however after some experimentation using 8x8 unmasked tiles for font (Notable in Commander Keen 1-3.), a new way to use the font for more varied purposes was discovered.


0	2	Lineheight	Height of lines (And thus all characters)	
2	512	Char point	Pointers to data for characters, 2 bytes per character
514	256	Char width	Character widths, 1 byte per character
770	?	Char data	Character data

Each file starts with a 770 byte header. This can be used to search for the font if it is stored internally. This is because characters 0-31 are used by the game to write 8x8 window tiles inside which text is written. Therefore a font file will start with a word of varying value followed by 64 nulls and the word $302, pointing to the end of the header.

The raw character data appears at first to be simple 1-bit, but in reality it is a single plane of Raw EGA data Thus the size of a character's width given in the header is also a spacing, 'true' character width is always a multiple of 8, with 'extra' data still being displayed. It is thus possible to have characters overlap if care is not taken when writing a font file. In practice this is avoided by keeping this blank. So a 4x10 character will have 10 bytes of character data.

Version 1 and Version 2

There is one difference between the two versions of fonts; version 1 has twice as much character data, as each character's data is preceded by a mask. It is not known if or how the game uses this, but it may have something to do with character overlap mentioned above. The difference between versions can be detected by comparing the size of a character's data with its height\width. The 4x10 character above would have 20 bytes of data in version 1.

Version 1 is found either internally in executables or externally as a single file in earlier Softdisk\ID Software games such as Shadow Knights or Rescue Rover. Version 2 is found inside EGAGraph files as a font chunk.


In its earliest implementation characters are treated as another plane of EGA data overlaid on the screen. The game performs a NOT check meaning in essence that the nonzero part of the character inverts the color it is displayed on. In a text window this turns the white background black, but characters can be displayed over images outside of text windows, where this effect can be seen more clearly.

Later games allow the font to be warped in various ways, as well as having custom colors instead of simple inversion. This can be seen in the Commander Keen 4-6 help screens for example.