mirror of
https://github.com/reactos/reactos.git
synced 2024-09-12 05:43:24 +00:00
![Colin Finck](/assets/img/avatar_default.png)
It has a MDI user interface, imports binary fonts (.bin) and PC Screen Fonts (.psf) and exports .bin fonts. Compiles without any warnings with GCC and MSVC (at /W3). The "misc.c" file was taken from devmgmt (thanks Ged!) and modified. The used bitmaps and icons were all done myself, but partly consist of characters of the cp737 font we have in media/vgafont. svn path=/trunk/; revision=32079
55 lines
1.8 KiB
Plaintext
55 lines
1.8 KiB
Plaintext
VGA Font File Formats
|
|
=====================
|
|
|
|
We only deal with 8x8 fonts with 256 characters, so different formats aren't described here.
|
|
|
|
1. The binary format (*.bin)
|
|
----------------------------
|
|
A binary font file is always 2048 bytes in size.
|
|
These bytes are divided into 256 characters, so every character is 8 bytes large.
|
|
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.
|
|
|
|
Example:
|
|
We want to get the pixel in the third column of the second row of the seventh character.
|
|
We assume you loaded the binary font file completely into a byte array called FontBits.
|
|
|
|
// All indexes need to be zero-based
|
|
UINT uCharacter = 6;
|
|
UINT uRow = 1;
|
|
UINT uColumn = 2;
|
|
|
|
UCHAR uBit;
|
|
|
|
// uBit will either contain 0 (0-bit is set) or 128 dec, 0x80 hex (1-bit is set) now
|
|
uBit = FontBits[uCharacter * 8 + uRow] << uColumn & 0x80;
|
|
|
|
2. The PC Screen Font Version 1 format (*.psf)
|
|
----------------------------------------------
|
|
A PC Screen Font Version 1 file is always 2052 bytes in size.
|
|
|
|
It has the following structure:
|
|
|
|
struct PSF1_FILE
|
|
{
|
|
UCHAR uMagic[2];
|
|
UCHAR uMode;
|
|
UCHAR uCharSize;
|
|
|
|
UCHAR FontBits[2048];
|
|
};
|
|
|
|
* uMagic contains two magic bytes, which identify a PSFv1 file. These are:
|
|
uMagic[0] = 0x36
|
|
uMagic[1] = 0x04
|
|
|
|
* uMode specifies special modes of the font.
|
|
We only deal with fonts here, which don't have any special modes, so this value should be 0.
|
|
|
|
* uCharSize specifies the size of a character.
|
|
In our case, this needs to be 8.
|
|
|
|
* Finally the FontBits array contains the font bits in the same format as described above.
|
|
This way, it is very easy to convert a PSFv1 file to a binary *.bin file.
|
|
|
|
|
|
- Colin Finck, 2008/02/01 |