Subject: fonts compression

From: Xiangdong Wang <[email-masked]>
Date: Tue, 9 Nov 1993 09:29:03 MEZ

Bin Lee wrote:
>         Thanks for your idea of compress the memory for chinese
>         fonts, could you tell me how do you actually do it?
>          I am a novice of compress.

How to compress chinese fonts
-----------------------------
I describe how I compress the chinese bitmap fonts of size 64x64.

1. get a table A from the original bitmap file which says how many
00, 01,..., FE, FF aprear in the bitmap file. for example:
     A[00]=100, A[01]=90,...,A[FE]=89, A[FF]=95
Then sorte the table:
     ....
     A[FE]=89
     A[01]=90
     ....
     A[FF]=95
     A[00]=100
we get a new table corresponding to ASCII table, this table is
called frequence table:
      ASCII_TABLE: 00 01 02 ... FE FF
      F_TABLE:     FF xx xx ... xx FE
(in general, the ASCII code 00 is most frenquently, and FF is also.
 therefore 00 maps to FF, FF maps to FE,...)

2. get a suitable integer (REPEAT_CODE) from the table A and table F,
that is a integer satisfing

    A[F[00]]+A[F[01]]+...+A[F[REPEAT_CODE]] < 5% of size of the bimap file

3. the bitmap of a character consists of couples:
     (r1,b1),(r2,b2),...
where r1 is repeat count of byte b1, so is r2. with the table F we get
     (r1,F[b1]),(r2,F[b2]),...

The compression of a couple (r,c) is given by following method:

   if r=1, c>REPEAT_CODE : ----->  c                 ( 1 byte )
   if r=1, c<=REPEAT_CODE: ----->  01,c              ( 2 bytes)
   if r>1, r<=REPEAT_CODE: ----->  r,c               ( 2 bytes)
   if r>REPEAT_CODE      : ----->  REPEATCODE,c      ( 2 bytes)
                                   and (r,c)->(r-REPEAT_CODE,c)

4. In step 3, the bitmap bytes of a character must be vertical arranged,
i. e. the matrix is:
    | | | | | | | |
    | | | | | | | |
      ..........
      ..........
    | | | | | | | |
not
    - - - - - - - -
    - - - - - - - -
        ........
        ........
    - - - - - - - -
(very very important !!!)

using the above method I have compressed some 64x64 chinese
bitmap fonts (3.4MB -----> 1.3MB).

wang xiangdong