1VGA Font File Formats
2=====================
3
4We only deal with 8x8 fonts with 256 characters, so different formats aren't described here.
5
61. The binary format (*.bin)
7----------------------------
8A binary font file is always 2048 bytes in size.
9These bytes are divided into 256 characters, so every character is 8 bytes large.
10Each byte represents a character row. Consequently, each column is represented by one bit.
11The most-significant bit contains the pixel of the first column from the left.
12
13Example:
14  We want to get the pixel in the third column of the second row of the seventh character.
15  We assume you loaded the binary font file completely into a byte array called FontBits.
16
17  // All indexes need to be zero-based
18  UINT uCharacter = 6;
19  UINT uRow = 1;
20  UINT uColumn = 2;
21
22  UCHAR uBit;
23
24  // uBit will either contain 0 (0-bit is set) or 128 dec, 0x80 hex (1-bit is set) now
25  uBit = FontBits[uCharacter * 8 + uRow] << uColumn & 0x80;
26
272. The PC Screen Font Version 1 format (*.psf)
28----------------------------------------------
29A PC Screen Font Version 1 file is always 2052 bytes in size.
30
31It has the following structure:
32
33struct PSF1_FILE
34{
35    UCHAR uMagic[2];
36    UCHAR uMode;
37    UCHAR uCharSize;
38
39    UCHAR FontBits[2048];
40};
41
42* uMagic contains two magic bytes, which identify a PSFv1 file. These are:
43     uMagic[0] = 0x36
44     uMagic[1] = 0x04
45
46* uMode specifies special modes of the font.
47  We only deal with fonts here, which don't have any special modes, so this value should be 0.
48
49* uCharSize specifies the size of a character.
50  In our case, this needs to be 8.
51
52* Finally the FontBits array contains the font bits in the same format as described above.
53  This way, it is very easy to convert a PSFv1 file to a binary *.bin file.
54
55
56- Colin Finck, 2008/02/01
57