Subject: Re: GB and BIG5 bitmap format

From: [email-masked]
Date: Fri, 17 May 91 09:40:26 MDT

Stephen G Simpson writes:
 > [elided for brevity]
 >
 > Does this hold for all the bitmaps we know about? (Yang Yongxin's
 > ziku, the cclib.16 and 24, the .bdf fonts, etc.)  Also, in what order
 > are the 32 or 72 bytes displayed in the square character, e.g. row by
 > row upper left to lower right, or what?  Or does this vary from font
 > to font?

Good point.  It didn't occur to me to explain this.

The calculations I posted are for raw bitmap fonts (binary form) like
CCLIB fonts used in ChTeX, CCDOS, Byx 1.1 and other programs.  I don't
have easy access to MSDOS machines, so I haven't looked at the ziku
file.

The X11 BDF fonts are different because they are straight ASCII files.
BDF fonts have a field called ENCODING for each bitmap, in which the
encoding value is given.  The ENCODING field can be used in a couple
of different ways, so it is easiest to convert a BDF font to a raw
bitmap (binary form) font before looking for bitmaps.

Fonts on other systems are stored differently.  I am in the process of
reverse engineering the Macintosh Chinese OS font format, so I'll post
information on that when I get it figured out (if anyone wants to
supply info on FBIT expansion, I'd love to hear from you :-).

The order of the bytes in a bitmap font should not really be a factor,
because the program that reads the bitmaps ends up seeing the bytes in
the correct order.  There are some machines that have strange byte
orderings that may cause trouble.  The bit order *will* be different
on some machines.

Below is a short algorithm to display a 16x16 bitmap in ASCII (C code)
from a CCLIB raw bitmap font.  To modify this algorithm for a 24x24
font, the size of the bitmap array would be 72, the first loop would
go from 0 to 71, and the second loop would from 0 to 3.

This algorithm needs some modification to display a group of bitmaps
in ASCII horizontally across the screen.

    Assuming the bitmap is a linear array of characters that have
    been read from the raw bitmap font.

    char bitmap[32];
    int next_byte = 0;

    /*
     * The variable i will represent the number of rows in the
     * in the bitmaps.
     */
    for (i = 0; i < 16; i++) {

        /*
         * The variable j will represent the number of bytes needed
         * to hold 16 columns (bits).
         */
        for (j = 0; j < 2; j++) {

            /*
             * The variable k will be used to extract each column
             * (bit) from the bytes in the current row.
             * This part is where machine specific things come in.
             * This loop may need to be changed to:
             *    for (k = 0; k < 8; k++)
             * for some systems.
             */
            for (k = 7; k >= 0; k--) {
                if (((bitmap[next_byte] >> k) & 1) != 0)
                  printf("*");
                else
                  printf(" ");
            }
            next_byte++;
        }
    }
-----------------------------------------------------------------------------
[email-masked]                      "I laughed.
Mark Leisher                                I cried.
Computing Research Lab                          I fell down.
New Mexico State University                        It changed my life."
Las Cruces, NM                     - Rich [Cowboy Feng's Space Bar and Grille]