Subject: patch chinese.16: BIG5 font previously from HKU

From: [email-masked] (Fung Fung Lee)
Date: Wed, 16 Sep 92 18:58:34 GMT

*[For those interested in following up the discussion, please do so
* on alt.chinese.text. For questions, please also post them there.]

---------------------------------------------------------------------------
For those of you who already know what BIG5 is, "chinese.16" is a
16x16 bitmap font file for traditional Chinese characters encoded 
in BIG5 order.  If you have ever used/read those "infrequently-used"
characters, you may have noticed something wrong.  The following
solution seems to be the most painless: just patch the original file,
"chinese.16". 

-----------------   --------------------   ------------------ --------------
For other programs which use a different file format,
but derive the content from "chinese.16", there may be a need to
regenerate the font files.

For example, hz2ps and hzview both support BIG5, but require a different
file format.  Users can run "hku2hz" (included in the hz2ps package) on
"chinese.16" again to re-generate the font files. hz2ps and hzview will
now work properly (without changing a single line of code).

The program "chirk" (v 1.2) will now display the infrequently-used BIG5
characters correctly, but not perfectly due to some other bug, which is not
present in its previous version (v 1.1). (Surprise?)

The programs cxterm and xhzview display Han characters on X window
systems, using a bdf font file based on the content of "chinese.16".
Therefore, the bdf file "HKU-Ch16.bdf" ("HKU-Ch16.pcf") needs to be
regenerated.  Some range checking codes may have to be changed if
it matters.

patch-chinese16.c can be found in ahkcus.org:src/unix
chinese.16 can be found in ahkcus.org:src/pc/hku
Other software mentioned above can also be found in ahkcus.org:src/unix

Since patch-chinese16.c is so small, it is also included in this message.

------------------------------cut here------------------------------------
/* patch-chinese16.c (version 9/15/92)

   A program to patch "chinese.16" as distributed by HKU.
   Copyright 1992  Fung F. Lee

   As of today, many popular Chinese display/editing programs made
   some incorrect interpretation about the file format of "chinese.16",
   possibly the only publicly accessable traditional font file, such that
   the "infrequently-used" characters are displayed incorrectly.
   It seems to me that this patching of the original "chinese.16" can save
   the work and hassle of changing those software.
   
   This program expects "chinese.16" residing in the same directory.

   Permission to copy and distribute copies of this program is granted.
   There is absolutely no warranty for this program.
*/

#include <stdio.h>

char inFile[] = "chinese.16";
char outFile[] = "chinese.16.new";

#define FSIZE       442432 /* file size of "chinese.16" */
#define INSERT_PT   197568 /* offset of first byte belonging to code 0xC940 */
#define INSERT_LEN  13056  /* (94+157+157)*32 */

main(argc, argv)
int argc;
char *argv[];
{
    FILE *fin, *fout;
    int c;
    long i, j;

    if ((fin = fopen(inFile, "r")) == 0)
    {
	fprintf(stderr, "Can't open font file %s\n", inFile);
	exit(1);
    }
    if ((fout = fopen(outFile, "w")) == 0)
    {
	fprintf(stderr, "Can't create new font file %s\n", outFile);
	exit(1);
    }
    for (i = 0; i < FSIZE; i++)
    {
	if (i == INSERT_PT)
	    for (j = 0; j < INSERT_LEN; j++)
		fputc('\0', fout);
	c = fgetc(fin);
	fputc(c, fout);
    }
    fclose(fin);
    fclose(fout);

    fprintf(stdout, "Remember to rename chinese.16 to something else,\n");
    fprintf(stdout, "and rename chinese.16.new as chinese.16\n");
    exit(0);
}