Bitmap File Format
A "bitmap file" is a binary file of character bitmaps indexed
by the corresponding HBF file.
The format described below is fairly common;
in particular many bitmap fonts supplied by vendors may be used
without modification.
Structure of a Bitmap
A bitmap of size "Width x Height" bits is stored by rows from top to bottom,
with each row taking up a whole number of bytes.
Thus each row occupies (Width+7)/8 bytes, where integer division with
truncation of decimal places is used in the calculation.
Each row is stored from left to right,
with the leftmost pixel in the most significant bit of the first byte.
Hence each bitmap occupies Height*((Width+7)/8) bytes.
For example,
- a 16x16 bitmap occupies 16*((16+7)/8) = 32 bytes
- a 15x16 bitmap occupies 16*((15+7)/8) = 32 bytes
- a 16x15 bitmap occupies 15*((16+7)/8) = 30 bytes
- a 64x64 bitmap occupies 64*((64+7)/8) = 512 bytes
A bit value of 1 represents part of the character,
while a value of 0 indicates the background.
Arrangement of Bitmaps in the File
Each HBF_CODE_RANGE entry in
the HBF file gives an offset into a bitmap file at which the bitmaps
for a range of characters may be found.
The bitmaps for characters from firstCode to lastCode
are stored sequentially in the file,
but bitmaps for codes outside the defined byte-2 range are omitted.
For example, suppose we have a 24x24 Big5 font,
so that each bitmap occupies 72 bytes.
In Big5, the ranges for the second byte are:
HBF_BYTE_2_RANGE 0x40-0x7E
HBF_BYTE_2_RANGE 0xA1-0xFE
An entry of the form
HBF_CODE_RANGE 0xA440-0xC67E stdfont.24k 0
means that the offsets of bitmaps in the file are
0 bitmap for character A440
72 bitmap for character A441
... ...
4464 bitmap for character A47E
4536 bitmap for character A4A1
... ...
11232 bitmap for character A4FE
11304 bitmap for character A540
... ...
395568 bitmap for character C67E
Part of Hanzi Bitmap Font (HBF) File Format version 1.1.