Eye of the Beholder bitmap font Format

From ModdingWiki
Jump to: navigation, search
Edge of map!

! Wikify formatting

! Add infobox

Contains bit-map for the fonts.


    short int fsize; // Size of the file
    short int unknown1; // Unknown entry (always 0x0500 or 0x0002)
    short int unknown2; // Unknown entry (always 0x000e)
    short int unknown3; // Unknown entry (always 0x0014)
    short int wpos; // Offset of char. widths array  (abs. from beg. of file)
    short int cdata; // Offset of char. graphics data (abs. from beg. of file)
    short int hpos; // Offset of char. heights array (abs. from beg. of file)
    short int unknown4; // Unknown entry (always 0x1012 or 0x1011) maybe a file version??
    unsigned char zero; //zero value
    unsigned char nchars; // Number of characters in font minus 1
    unsigned char maxh; // Font height
    unsigned char maxw; // Max. character width

EOB 1 (PC) - Fixed Font File Format

typedef struct {
    short int filesize;                   // the size of the file
    short int charoffset[128];            // the offset of the pixel data from the beginning 
                                          // of the file, the index is the ascii value
    unsigned char width;                  // the width of a character in pixel
    unsigned char height;                 // the height of a character in pixel
    unsigned char data[128][height];      // the pixel data, one byte per line 


To render a character from the font, you could use something like the following code:

TFIXEDFONT fnt;      // assume this is loaded and initialized
int x, y;            // position to draw the character
int color;           // color of the text
char c;              // the character to be drawn
for (int h = 0; h < fnt.height; h++) {
    unsigned char line = fnt.data[c][h];
    unsigned char bit = 0x80;
    for (int w = 0; w < fnt.width; w++) {
        if ((line & bit) == bit)
            DrawPixel(x + w, y + h, color);
        bit = bit >> 1;