/* * Copyright (C) 1990 Democracy News Propaganda System. * Version 1.00 * Produced By TheDog * All Rights Reserved * * This program can read a chinese article, * Provided by the Society of HKU Postgraduates on the Chinese Affairs, * on a ASCII terminal. * * July 2, 1990. * July 25, 1990: added font file path and ported for VMS -- KS * */ #include #if vms #ifndef ZITAPE #define ZITAPE "inferno:[sun.hknews]chinese.16" #endif #endif #if unix #ifndef ZITAPE #define ZITAPE "/home/ftp/software/fonts/chinese.16.new" #endif #endif #ifndef ZITAPE #define ZITAPE "chinese.16.new" #endif #define HEIGHT 16 char dictname[100]; char buffer[16][200]; FILE *fip, *fop; char inbuf[512]; FILE *bitmap; char charinline; main (argc,argv) int argc; char **argv; { char ch; unsigned char ch1,ch2; int charno, i; char charcnt; fip = stdin; fop = stdout; *dictname=0; charinline=5; for (i=1; (i0) { putline (charcnt); charcnt=0; } } else if (ch1>=0x81) { if ((ch=fgetc (fip))==EOF) { printf ("\tFile read error!\n"); exit (); } ch2=ch; getbitmap (order(ch1,ch2)); putbitmap (charcnt); charcnt++; } else if (map (ch,&ch1,&ch2) == 0) { getbitmap (order(ch1,ch2)); putbitmap (charcnt); charcnt++; } if (charcnt==charinline) { putline (charinline); charcnt=0; } } switch(argc) { /* close all the open files */ case 2: fclose(fop); case 1: fclose(fip); default: break; } } order (fontid,glyphid) unsigned char fontid,glyphid; { int charno; if (fontid<0xA4) { if (glyphid<0x7F) charno=(fontid-0xA1)*157+(glyphid-0x40); else charno=(fontid-0xA1)*157+(glyphid-0xA1)+(0x7E-0x40+1); } else { if (glyphid<0x7F) charno=(fontid-0xA4)*157+(glyphid-0x40); else charno=(fontid-0xA4)*157+(glyphid-0xA1)+(0x7E-0x40+1); charno += 765; } return (charno); } getbitmap (glyphid) int glyphid; { long absaddr; int i; int ch, tch; absaddr = (long)glyphid*32; absaddr += 256; #ifdef unix bitmap = fopen (dictname, "r"); #else bitmap = fopen (dictname, "rb"); #endif fseek (bitmap, absaddr, 0); for (i=0; i<32; i++) fscanf (bitmap,"%c",&inbuf[i]); fclose (bitmap); } putbitmap (charpos) char charpos; { int i,k; k=charpos*2; for (i=0; i': *fontcode= 0xA1; *charcode= 0x72; break; case '\"': *fontcode= 0xA1; *charcode= 0xAA; break; case '`': *fontcode= 0xA1; *charcode= 0xAB; break; case '\'': *fontcode= 0xA1; *charcode= 0xAC; break; case '#': *fontcode= 0xA1; *charcode= 0xAD; break; case '&': *fontcode= 0xA1; *charcode= 0xAE; break; case '*': *fontcode= 0xA1; *charcode= 0xAF; break; case '_': *fontcode= 0xA1; *charcode= 0xC4; break; case '+': *fontcode= 0xA1; *charcode= 0xDE; break; case '-': *fontcode= 0xA1; *charcode= 0xDF; break; case '=': *fontcode= 0xA1; *charcode= 0xE2; break; case '~': *fontcode= 0xA1; *charcode= 0xE3; break; case '^': *fontcode= 0xA1; *charcode= 0xF4; break; case '/': *fontcode= 0xA2; *charcode= 0x41; break; case '\\': *fontcode= 0xA2; *charcode= 0x42; break; case '$': *fontcode= 0xA2; *charcode= 0x43; break; case '%': *fontcode= 0xA2; *charcode= 0x48; break; case '@': *fontcode= 0xA2; *charcode= 0x49; break; } return (0); }