FNT files contain the bitmap font (or character set) used by the game.

Usage Edit

The FNT file is loaded by the engine and used to render all the text displayed in the game. The file contains bitmap representations of 256 different characters. The first 128 characters map almost directly to the standard ASCII characters. The second set of 128 characters are the same as the first set, only slightly smaller in size (each letter in the first set being approximately 6x7 pixels in size, with the second set being 5x6 pixels in size.)

The characters can be broken down in to catgories:

  • Characters 0 to 31 in each set represent non-displayable characters, and so while still stored in the file, are completely blank
  • Character 32 represents the space character, so is never actually drawn to the screen. The actual stored image comprises of a single dot in the middle of the character
  • Characters 33-47 are the standard miscellaneous characters: !"#$%&'()*+,-./
  • Characters 48-57 are the numbers 0-9
  • Characters 58-64 are the characters :;<=>?@
  • Characters 65-90 are the characters A-Z
  • Characters 91-96 are the characters [\]^_`
  • Characters 97-122 are the characters a-z
  • Character 123 is the open curly bracket {
  • Character 125 is the close curly bracket }
  • Characters 124, 126 and 127 form the frames of the cursor animation - a small box, a medium box, and a large box, which are displayed in sequence to form the pulsating cursor when the game expects input from the player.

Characters should be displayed with only one blank space between them. ie, 'I' is only two pixels wide, but should not followed by 6 blank columns of pixels. There should be one pixel space, followed by the next character. The only exception to this is when the entire character is empty; space, for example.

Lines are 10 pixels tall, with each 8 pixel tall character being centered. Most characters only use the first 7 of the 8 pixels. This leads to there generally being 3 blank pixels between the bottom of one line, and the top of the tallest character in the next line. The exception to this is "hanging" characters, such as 'g', 'p', q', and 'y'. In these cases, which use the last row of pixels, they are also drawn at the bottom of the line, with 2 blank pixels being left above, as opposed to being centered on the line.

File Format Edit

The FNT file is always exactly 4352 bytes (0x1100 bytes) in size. The first 4096 bytes contain the information required to render each character (256 characters, each 16 bytes in size), and the remaining 256 bytes at the end of the file contains what is essentially the width and amount of spacing required when drawing each character.

Each character is an 8x8x2 bitmap. That means each character is 8 pixels wide, 8 pixels tall, with each pixel being stored in 2 bits.

Reading a character involves reading the 8x8x2 bits as eight 16-bit ints that make up that character, and flipping them. Those 16 bits must then be formatted into 2 bit wide pixels that make up that row of the character.

For example, the hex value "94 02" would be binary string "0000001010010100" which, when formatted to 2 bit wide pixels and flipped, looks like "01122000".

The larger hex string "94 02 09 0A 09 0A 09 0A A9 0E 09 0E 09 0E 00 00", which makes up the 'A' character (character 65) is loaded as the 8 binary strings


which, when formatted to 2 bit wide pixels and flipped, looks like

12  22  
12  22  
12  22  
12  23  
12  23  

(0 values removed for readability)

The spacing value is then read from the end of the file. The spacing value for character 56 is located at 0x1000 + decimal 56 = 0x1038. This byte has a value of 7, meaning that the bitmap for this character should be rendered into a space 7 pixels wide. This leaves exactly one pixel of spacing between all characters, and can be used by the game engine to work out how to split text over multiple lines when rendering text into a small area, such as a scroll window.

Community content is available under CC-BY-SA unless otherwise noted.