Subject: GB code and bitmap

From: YLu <[email-masked]>
Date: Tue, 21 May 91 11:30:53 BST

Here is my understanding of GB coding:

The 2-byte 8-bit GB code (with high bit set) is in the range
0xA1A1 to 0xF7FE. The second byte takes values from 0xA1 to 0xFE,
thus allowing 0xFE - 0xA1 + 1 = 0x5E (decimal 94) GB symbols.
The first byte is from 0xA1 to 0xF7, therefore there can be a total
of (0xF7 - 0xA1 + 1)*94 = 8187 valid GB codes.

In the GB table, HanZi starts from 0xB0A1, the possible total HanZi
is thus (0xF7 - 0xB0 + 1)*94 = 6768. The HanZi code between 0xB0A1
and 0xF7FE is divided into two parts, the first part between 0xB0A1
and 0xD7F9 is in PinYin order, while the second part between 0xD8A1
and 0xF7FE is in stroke (BuShou) order. There are five blank spaces
from 0xD7F to 0xD7FE. The total HanZi accommodated in the GB table
is therefore 6768 - 5 = 6763.

Calculations for getting bitmaps from GB fonts:
-----------------------------------------------

    word_index = (first_byte - 0xA1)*94 + (second_byte - 0xA1);
    byte_index = word_index * num_bytes;

where num_bytes is the number of bytes needed for one bitmap. A 16x16
font requires 32 bytes for each bitmap, and a 24x24 font requires 72
bytes for each bitmap.

byte_index gives the starting point of the bitmap in the font file.

In the BYX ziku, the range from 0xA8A1 to 0xAFFE is undefined. This
gives (0xAF - 0xA8 + 1)*94 = 752 empty spaces.

Therefore,

if (first_byte > 0xAF)
    word_index -= 752;
byte_index = word_index * 32;

--------------
Yuzhao Lu
[email-masked]