[comp.fonts] Anyone interested in doing this in Japanese?

lee@uhccux.uhcc.hawaii.edu (Greg Lee) (10/20/88)

From article <1439@maccs.McMaster.CA>, by gordan@maccs.McMaster.CA (gordan):
" Kanji or bust.

Mark Moraes sent me a helpful note about kterm, a terminal emulator
program that is part of the X windows system, version 11, rev. 2.
I can't use it myself, because I don't have this version of X
running, and, anyhow, I don't know Japanese.  But I've looked at
the font it uses, "k14", and made a certain amount of progress.
There are over 6000 characters defined, katakana, hiragana,
Cyrillic, Greek, Roman, graphics, but mostly kanji.  The name of
the file containing the font is "k14.bdf", or in binary form "k14.snf".
According to the kterm document, the font conforms to standard
JIS X 0208, levels 1 and 2.  It appears to me, though, that there
are additional kanji in the font beyond levels 1 and 2, at least
some of which are duplicates.

Anyhow, if you can snag a copy of the font somewhere (it's over
a megabyte) and you have a PostScript printer, the lex program
I've appended to the end of this posting should give a chart
of all the characters in the font.

In addition, I have a program to print text files making use of
this font (in the binary form, "k14.snf") on a LaserWriter.
It seems to work ok for the one sample file I have prepared with
kterm and for the Japanese language postings in the usenet
newsgroup gnu.emacs.gnus.  (I don't know for sure, but the
printout *looks* like Japanese to me.)  I'll post the program
to comp.sources.misc in a day or two.  The print resolution
is not great, since the bitmap for each character is only
14 by 14 dots.

For input, in addition to kterm, I've heard there's an editor
with the JTeX system, a Japanese version of TeX.  I don't have
JTeX yet.

		Greg, lee@uhccux.uhcc.hawaii.edu
	---------------------------
If you put the following in file kps.l, compile with:
	% lex kps.l
	% cc -o kps lex.yy.c -ll
then for printout
	% kps <k14.bdf |lpr
or something similar.
----------------------cut-----------------------
%{
#define RHEIGHT 36
#define CWIDTH 42
#define LASTROW 20
#define LASTCOL 12
#define XOFF 18
#define YOFF 336
#define KSIZE 18
	int i, j, col, row, bitrow;
%}

%%

"STARTCHAR "....$   {
	sscanf(yytext+10, "%2x", &i);
	sscanf(yytext+12, "%2x", &j);
	if (col >= LASTCOL) {
		col = 1;
		if (row >= LASTROW) {
			printf("showpage restore save\n");
			row = 1;
		} else row++;
	} else col++;
	printf("%d %d moveto (\\%o\\%o  ) show\n",
		col*CWIDTH+XOFF, (11-row)*RHEIGHT+YOFF+8, i, j);
	bitrow = 0;
};

^[0-9A-F]{4}$	{
	if (bitrow == 0) {
	printf("gsave\n");
	printf("%d %d translate %d %d scale\n",
		col*CWIDTH+XOFF+16, (11-row)*RHEIGHT+YOFF, KSIZE, KSIZE);
		printf("16 14 true [16 0 0 -14 0 14]\n");
		printf("{<");
	}
	ECHO;
	bitrow++;
	if (bitrow == 14) {
		printf(">} imagemask\n");
	printf("grestore\n");
		bitrow = 0;
	}
};

.  |
\n	;

%%
main()
{
	printf("%%!\n");
	printf("/Times-Roman findfont 12 scalefont setfont\n");
	printf("save\n");
	yylex();
	if (row+col > 0) printf("showpage restore\n");
}