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