/* GCFHZK.C --- General C Functions for Chinese Font M.L.Y 2000.9
Note: Must compiled by Microsoft C or Turbo C or Borland C */
#if !defined(_MSC_VER) && !defined(__BORLANDC__) && !defined(__TURBOC__) # error "Must compiled by Microsoft C or Turbo C or Borland C !" #endif
#include
#ifndef USG_TYPES # define USG_TYPES 1 typedef unsigned char USGC; typedef unsigned short USGS; typedef unsigned int USGI; typedef unsigned long USGL; #endif
/* ------------------------------------------------------------------------- */ int read_hzk16(FILE *fphzk, USGC hz[2], USGC buf[32]) /* 从 16*16 点阵字库(如UCDOS的HZK16,文件指针fphzk)读一个汉字(hz前2字节)的 点阵到buf中 返回: 0 = 成功 -1 = 失败(读文件出错) */ { int qm, wm; long offset;
qm = hz[0] - 0xA0; wm = hz[1] - 0xA0; if(qm < 16) offset = (long) ((qm - 1) * 94 + (wm - 1)) * 32; else offset = (long) ((qm - 1) * 94 + (wm - 1)) * 32; fseek(fphzk, offset, SEEK_SET); if(fread((char *)buf, 1, 32, fphzk) != 32) return -1; return 0; }
/* ------------------------------------------------------------------------- */ int read_hzk24(FILE *fphzk24t, FILE *fphzk24, USGC hz[2], USGC buf[72]) /* 从 24*24 点阵字库(如UCDOS的HZK24K(16区到94区,文件指针fphzk24), HZK24T(1到15区,文件指针为fphzk24t))读一个汉字(hz前2字节)的点阵到buf中 返回: 0 = 成功 -1 = 失败(读文件出错) */ { int qm, wm; long offset;
qm = hz[0] - 0xA0; wm = hz[1] - 0xA0; if(qm < 16) { offset = (long) ((qm - 1) * 94 + (wm - 1)) * 72; fseek(fphzk24t, offset, SEEK_SET); if(fread((char *)buf, 1, 72, fphzk24t) != 72) return -1; } else { offset = (long) ((qm - 1 - 15) * 94 + (wm - 1)) * 72; fseek(fphzk24, offset, SEEK_SET); if(fread((char *)buf, 1, 72, fphzk24) != 72) return -1; } return 0; }
/* ------------------------------------------------------------------------- */ int read_hzk48(FILE *fphzk48t, FILE *fphzk48, USGC hz[2], USGC buf[288]) /* 从 48*48 点阵字库(如UCDOS的HZK48S(16区到94区,文件指针fphzk48), HZK48T(1到15区,文件指针为fphzk48t))读一个汉字(hz前2字节)的点阵到buf中 返回: 0 = 成功 -1 = 失败(读文件出错) */ { int qm, wm; long offset;
qm = hz[0] - 0xA0; wm = hz[1] - 0xA0; if(qm < 16) { offset = (long) ((qm - 1) * 94 + (wm - 1)) * 288; fseek(fphzk48t, offset, SEEK_SET); if(fread((char *)buf, 1, 288, fphzk48t) != 288) return -1; } else { offset = (long) ((qm - 1 - 15) * 94 + (wm - 1)) * 288; fseek(fphzk48, offset, SEEK_SET); if(fread((char *)buf, 1, 288, fphzk48) != 288) return -1; } return 0; }
/* End of file */
| | |