home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / COMM / MISC / SRC26_2.ZIP / SRC / FONT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-13  |  16.7 KB  |  721 lines

  1. /*
  2. ** font.c: hterm soft font driver
  3.  *
  4.  * Author: HIRANO Satoshi
  5.  * (C) 1989  Halca Computer Science Laboratory TM
  6.  *           University of Tokyo
  7.  *
  8.  * Edition History:
  9.  * 1.1 90/06/18 Halca.Hirano creation
  10.  * 1.2 90/07/12 Halca.Hirano limit font cache size 64K
  11.  *
  12.  * $Header: font.cv  1.5  90/07/04 05:52:06  hirano  Exp $
  13.  *
  14.  */
  15.  
  16. #include "option.h"
  17. #ifdef SOFT_FONT
  18. #include <stdio.h>
  19. #include <fcntl.h>
  20. #include <io.h>
  21. #include <stdlib.h>
  22. #include "config.h"
  23. #include "hterm.h"
  24. #include "default.h"
  25. #include "global.h"
  26. #include "font.h"
  27.  
  28. /*
  29. ** static variables
  30.  */
  31. /*
  32.  * physical line number to graphic VRAM address convertion table
  33.  * index = physical line number
  34.  * contents = VRAM address
  35.  */
  36. static int ltopTab[MAX_LINE_25_MODE];
  37. /*
  38.  * logical line number to VRAM address conversion function
  39.  */
  40. #define ltop(y) (ltopTab[y])
  41.  
  42. static FontDesc asciiFont;
  43. static FontDesc kanjiFont;
  44. static u_char FAR *vram;
  45. static char softCursor;            /* soft cursor has been displayed or not    */
  46. static int oldX = 0;            /* old soft cursor position                    */
  47. static int oldY = 0;
  48. static char blinkState;
  49. static u_char FAR *kanjiFontCache;    /* font cache buffer                    */
  50. static u_short FAR *fontHashTable;    /* pointer to font cache hash table        */
  51. static int kanjiFontSize;            /* kanji font size in bytes                */
  52. static int kanjiPath = 0;            /* font file path number                */
  53.  
  54. void fontUnLoad(void);
  55. void reverseFont(int x,int y);
  56. u_char FAR *loadOneChar(u_short);
  57. char *fontRead(int path,FontDesc *fontDesc);
  58.  
  59. /*
  60. ** void fontInit()
  61.  *
  62.  * initialize font driver; called once just after hterm startup
  63.  */
  64. void fontInit()
  65. {
  66.     char *p, *getenv();
  67.  
  68.     /*
  69.      * J3100 note: GVRAM segment can't be determined here
  70.      */    
  71.     FP_SEG(vram) = gvramSegment;
  72.     FP_OFF(vram) = 0;
  73.     softCursor = NO;
  74.     if ((p = getenv("HTFONTCACHE")) == NULL) {
  75.         fontCacheSize = DEFAULT_HIST_LINES;
  76.     } else {
  77.         fontCacheSize = atoi(p);
  78.         if (fontCacheSize == 0)
  79.             fontCacheSize = 20;
  80.     }
  81. }
  82.  
  83. /*
  84. ** void fontEnd()
  85.  *
  86.  * terminate soft font driver
  87.  */
  88. void fontEnd()
  89. {
  90.     fontUnLoad();
  91. }
  92.  
  93. /*
  94. ** void softFontLocate(register short x, register short y)
  95.  *
  96.  * erase old soft cursor and write new soft cursor on position (x, y)
  97.  */
  98. void softFontLocate(x, y)
  99. register short x, y;
  100. {
  101.     if (softCursor && blinkState)
  102.         reverseFont(oldX, oldY);
  103.     reverseFont(x, y);    
  104.     blinkState = softCursor = YES;
  105.     blinkTimer = BLINK_ON_INTERVAL;
  106.     oldX = x; oldY = y;
  107. }
  108.  
  109. /*
  110. ** void softCursorOnOff(register int onOff)
  111.  *
  112.  * erase or write soft cursor
  113.  *
  114.  * write cursor if old state is Off and new state is On
  115.  * erase cursor if old state is On and new state is Off
  116.  */
  117. void softCursorOnOff(onOff)
  118. register int onOff;
  119. {
  120.     if ((softCursor && (onOff == NO) && blinkState) /* turn OFF condition */
  121.          || ((softCursor == NO) && onOff && (blinkState == NO))) /* turn ON condition */
  122.         reverseFont(oldX, oldY);
  123.     blinkState = softCursor = onOff;
  124.     blinkTimer = BLINK_ON_INTERVAL;
  125. }
  126.  
  127. /*
  128. ** void blinkSoftCursor()
  129.  *
  130.  * blink cursor
  131.  */
  132. void blinkSoftCursor()
  133. {
  134.     if (softCursor) {
  135.         reverseFont(oldX, oldY);        /* erase or write cursor    */
  136.         blinkTimer = blinkState ? BLINK_ON_INTERVAL : BLINK_OFF_INTERVAL;
  137.         blinkState = !blinkState;
  138.     }
  139. }
  140.         
  141. /*
  142. ** static void reverseFont(int x, int y)
  143.  *
  144.  * reverse a character at position (x, y)
  145.  */
  146. static void reverseFont(x, y)
  147. int x, y;
  148. {
  149.     register u_char FAR *p;
  150.     register int d, w;
  151.     int len, offset;
  152.  
  153.     /*
  154.      * determine character size    to reverse by VRAM backing store
  155.      * If backing store is not supported, use 
  156.      *    #define isKanjiOnVRAM(x,y) (0)
  157.      */
  158.     len = isKanjiOnVRAM(x, y) ? kanjiFont.wwidth : asciiFont.wwidth;
  159.     /*
  160.      * OK, reverse the character
  161.      */
  162.     p = vram + ltop(y) + x;
  163.     offset = MAX_X_DOT/8;
  164.     if (blockCursor) {
  165.         p = p + (offset*1);
  166.         d = asciiFont.dwidth-2;
  167.     } else {
  168.         p = p + offset*(asciiFont.dwidth - 2);
  169.         d = 2;
  170.     }
  171.     for (; d > 0; --d) {
  172.         for (w = len; w > 0; --w, p++)
  173.             *p = ~*p;
  174.         p = p + offset - len;
  175.     }
  176. }
  177.  
  178. /*
  179. ** void softFontPutChar(u_short c)
  180.  *
  181.  * put a character c on position (cursorX, cursorY) using attribute 'attrib'
  182.  * c is hterm kanji code
  183.  * currently reverse and underline attribute are supported.
  184.  *
  185.  * Just only this function touches font buffer.
  186.  */
  187. void softFontPutChar(c)
  188. u_short c;
  189. {
  190.     register u_char FAR *p;
  191.     register u_char FAR *f;
  192.     register int d, w;
  193.     FontDesc *fnt;
  194.     int offset;
  195.  
  196.     /*
  197.      * cursor has already erased by conWrite()
  198.      */
  199.     
  200.     if (c & 0xff00) {
  201.         fnt = &kanjiFont;
  202.         f = loadOneChar(c);
  203.     } else {
  204.         fnt = &asciiFont;
  205.         if (c < fnt->startChar || fnt->endChar < c ||
  206.             (f = (u_char FAR *)*(fnt->indexTab+(c-fnt->startChar))) == 0)
  207.             f = (u_char FAR *)*(fnt->indexTab);
  208.     }
  209.  
  210.     p = vram + ltop(cursorY) + cursorX;
  211.     offset = MAX_X_DOT/8;
  212. #ifdef PC98
  213.     if (attrib & B_REVER) {
  214. #endif
  215. #ifdef IBMPC
  216.     if (attrib & 0x10) {
  217. #endif
  218. #ifdef J3100
  219.     if (attrib & _REVER) {
  220. #endif
  221.         for (d = fnt->dwidth; d > 0; --d) {
  222.             for (w = fnt->wwidth; w > 0; --w)
  223.                 *p++ = ~*f++;
  224.             p = p + offset - fnt->wwidth;
  225.         }
  226.     } else {
  227.         for (d = fnt->dwidth; d > 0; --d) {
  228.             for (w = fnt->wwidth; w > 0; --w)
  229.                 *p++ = *f++;
  230.             p = p + offset - fnt->wwidth;
  231.         }
  232.     }
  233. #ifdef PC98
  234.     if (attrib & B_UNDER) {
  235. #endif
  236. #if defined(IBMPC) || defined(J3100)
  237.     if (attrib & _UNDER) {
  238. #endif
  239.         p -= offset;
  240.         for (w = fnt->wwidth; w > 0; --w)
  241. #ifdef PC98
  242.             *p++ = (attrib & B_REVER) ? 0x00 : 0xff;
  243. #endif
  244. #ifdef IBMPC
  245.             *p++ = (attrib & 0x10) ? 0x00 : 0xff;
  246. #endif
  247. #ifdef J3100
  248.             *p++ = (attrib & _REVER) ? 0x00 : 0xff;
  249. #endif
  250.     }
  251.     /*
  252.      * we must not rewrite cursor because backing store has not
  253.      * been updated.
  254.      */
  255. }
  256.  
  257. /*
  258. ** void softFontInsertLine(int num)
  259.  *
  260.  * insert num lines at cursorY
  261.  * filling of new blank lines are done in another place.
  262.  */
  263. void softFontInsertLine(num)
  264. int num;
  265. {
  266.     u_short vramSegmentSave = vramSegment;
  267.  
  268.     vramSegment = gvramSegment;
  269.     moveBackward((u_short *)(ltop(cursorY+num)), (u_short *)(ltop(cursorY)),
  270.         (lowScrRegion+1-cursorY-num)*(MAX_X_DOT/8*asciiFont.dwidth)/2, NO);
  271.     vramSegment = vramSegmentSave;
  272. }
  273.  
  274. /*
  275. ** softFontDeleteLine(int num)
  276.  *
  277.  * void delete num lines at cursorY
  278.  * filling of new blank lines are done in another place.
  279.  */
  280. void softFontDeleteLine(num)
  281. int num;
  282. {
  283.     u_short vramSegmentSave = vramSegment;
  284.  
  285.     vramSegment = gvramSegment;
  286.     moveForward((u_short *)(ltop(cursorY)), (u_short *)(ltop(cursorY+num)),
  287.         (lowScrRegion+1-cursorY-num)*(MAX_X_DOT/8*asciiFont.dwidth)/2, NO);
  288.     vramSegment = vramSegmentSave;
  289. }
  290.  
  291. /*
  292. ** void softFontInsertChar(int at, int n)
  293.  *
  294.  * insert n blanks at 'at' on cursorY
  295.  */
  296. void softFontInsertChar(at, n)
  297. int at;
  298. int n;
  299. {
  300.     register int i;
  301.     register int p;
  302.     int offset;
  303.     int moveNum = MAX_COLUMN-at-n;
  304.  
  305.     if (moveNum > 0) {
  306.         p = ltop(cursorY)+at;
  307.         offset = MAX_X_DOT/8;
  308.         for (i = 0; i < kanjiFont.dwidth; i++) {
  309.             moveBackByte((u_short *)(p+n), (u_short *)p, moveNum*asciiFont.wwidth);
  310.             p += offset;
  311.         }
  312.     } else
  313.         n = MAX_COLUMN-at;
  314.     softFontClearColumn(at, at+n);
  315. }
  316.  
  317. /*
  318. ** void softFontDeleteChar(int at, int n)
  319.  *
  320.  * delete n blanks at 'at' on cursorY
  321.  */
  322. void softFontDeleteChar(at, n)
  323. int at;
  324. int n;
  325. {
  326.     register int i;
  327.     register int p;
  328.     int offset;
  329.     int moveNum = MAX_COLUMN-at-n;
  330.  
  331.     if (moveNum > 0) {
  332.         p = ltop(cursorY)+at;
  333.         offset = MAX_X_DOT/8;
  334.         for (i = 0; i < kanjiFont.dwidth; i++) {
  335.             moveForByte((u_short *)p, (u_short *)(p+n), moveNum*asciiFont.wwidth);
  336.             p += offset;
  337.         }
  338.     } else
  339.         n = MAX_COLUMN-at;
  340.     softFontClearColumn(MAX_COLUMN-n, MAX_COLUMN);
  341. }
  342.  
  343. /*
  344. ** void softFontClearColumn(register u_shrot from, register u_short to)
  345.  *
  346.  * clear column 'from' to 'to'-1 on cursorY line, 
  347.  */
  348. void softFontClearColumn(from, to)
  349. u_short from, to;
  350. {
  351.     register u_char FAR *p, FAR *q;
  352.     register int i, d, w;
  353.     int offset;
  354.     u_char filler;
  355.  
  356.     q = p = vram + ltop(cursorY) + from;
  357.     offset = MAX_X_DOT/8;
  358. #ifdef PC98
  359.     filler = (eraseAttr & B_REVER) ? 0xff : 0;
  360. #endif
  361. #ifdef IBMPC
  362.     filler = (eraseAttr & 0x10) ? 0xff : 0;
  363. #endif
  364. #ifdef J3100
  365.     filler = (eraseAttr & _REVER) ? 0xff : 0;
  366. #endif
  367.     for (i = to-from; i > 0; --i) {
  368.         for (d = asciiFont.dwidth; d > 0; --d) {
  369.             for (w = asciiFont.wwidth; w > 0; --w)
  370.                 *p++ = filler;
  371.             p = p + offset - asciiFont.wwidth;
  372.         }
  373.         p = ++q;
  374.     }
  375. }
  376.  
  377. /*
  378. ** void softFontClearLine(y)
  379.  *
  380.  * clear line
  381.  */
  382. void softFontClearLine(y)
  383. int y;
  384. {
  385.     register u_long FAR *p = (u_long FAR *)(vram + ltop(y));
  386.     register int i;
  387.     u_long filler;
  388.  
  389. #ifdef PC98
  390.     filler = (eraseAttr & B_REVER) ? 0xffffffffL : 0L;
  391. #endif
  392. #ifdef IBMPC
  393.     filler = (eraseAttr & 0x10) ? 0xffffffffL : 0L;
  394. #endif
  395. #ifdef J3100
  396.     filler = (eraseAttr & _REVER) ? 0xffffffffL : 0L;
  397. #endif
  398.     for (i = asciiFont.dwidth*((MAX_X_DOT/8)/sizeof(long)); i > 0; --i)
  399.         *p++ = filler;
  400. }
  401.  
  402. /*
  403. ** void softFontReverseScreen()
  404.  *
  405.  * reverse GVRAM screen
  406.  */
  407. void softFontReverseScreen()
  408. {
  409.     long FAR *p;
  410.     int i, j;
  411.  
  412.     FP_SEG(p) = gvramSegment;
  413.     FP_OFF(p) = 0;
  414.     for (i = MAX_Y_DOT; i > 0; --i)
  415.         for (j = (MAX_X_DOT/8)/sizeof(long); j > 0; --j, p++)
  416.             *p = ~*p;
  417. }
  418.  
  419. /*
  420. ** static u_char FAR *loadOneChar(u_short code)
  421.  *
  422.  * return pointer to font body by code
  423.  * NOTE: code must be JIS kanji code
  424.  */
  425. static u_char FAR *loadOneChar(code)
  426. register u_short code;
  427. {
  428.     register int rehashValue;
  429.     register int hashValue;
  430.     u_char FAR *f;
  431.     static u_char fontTempBuf[100];
  432.     int i;
  433.     u_short val;
  434.  
  435.     /*
  436.      * check code validity
  437.      */
  438.     if (code < kanjiFont.startChar || kanjiFont.endChar < code)
  439.         code = JIS_SPACE;
  440.  
  441.     /*
  442.      * check font existence
  443.      */
  444.     if ((f = (u_char FAR *)*(kanjiFont.indexTab+(code - kanjiFont.startChar))) == 0) {
  445.         f = (u_char FAR *)*(kanjiFont.indexTab);    /* return SPACE    */
  446.         return(f);
  447.     }
  448.  
  449.     /*
  450.      * first look at parmanent cache
  451.      */
  452.     if (code <= kanjiFont.onMemEndChar) {        /* certainly on memory        */
  453.         return(f);
  454.     }
  455.  
  456.     /*
  457.      * next look at cache
  458.      */
  459.     rehashValue = hashValue = (code*13) % fontCacheSize;
  460. #define MAX_REHASH 10
  461.     for (i = MAX_REHASH; i > 0; --i) {
  462.         if ((val = fontHashTable[rehashValue]) == code) {    /* found in hash table    */
  463.             f = (u_char FAR *)&kanjiFontCache[rehashValue*kanjiFontSize];
  464.             return(f);
  465.         } else if (val == 0) {            /* found empty slot     */
  466.             hashValue = rehashValue;
  467.             break;
  468.         } else
  469.             rehashValue = (rehashValue + 17) % fontCacheSize;
  470.     }
  471.     /*
  472.      * while replacing algorithm is not so good, this code will
  473.      * macth first at next time.
  474.      */
  475.     fontHashTable[hashValue] = code;
  476.     lseek(kanjiPath, (long)f, 0);
  477.     f = (u_char FAR *)&kanjiFontCache[hashValue*kanjiFontSize];
  478.     read(kanjiPath, fontTempBuf, kanjiFontSize);
  479.     moveData(f, (u_char FAR *)fontTempBuf, kanjiFontSize);
  480.     return(f);
  481. }
  482.  
  483. /*
  484. ** char *fontLoad(fontName)
  485.  *
  486.  * load font file
  487.  *
  488.  * search font file named 'fontName' on current directory, HOME directory
  489.  * and PATH directory.
  490.  * return a poitner to error message string
  491.  */
  492. char *fontLoad(fontName)
  493. char *fontName;
  494. {
  495.     FontFile fontFile;
  496.     char *fontPath;
  497.     int i, p;
  498.     char *errmsg;
  499.     char *fontRead();
  500.  
  501.     if (fontFileLoaded)
  502.         return((char *)NULL);
  503.  
  504.     if ((fontPath = searchPath(fontName)) == NULL)
  505.         goto err;
  506.     if ((kanjiPath = open(fontPath, O_RDONLY|O_BINARY)) == ERR ||
  507.         read(kanjiPath, (char *)&fontFile, sizeof(FontFile)) == ERR) {
  508.         (void)close(kanjiPath);
  509.         kanjiPath = 0;
  510. err:
  511.         return("can't find font file");
  512.     }
  513.     asciiFont = fontFile.ascii;
  514.     kanjiFont = fontFile.kanji;
  515.     errmsg = fontRead(kanjiPath, &(asciiFont));
  516.     if (errmsg) {
  517.         goto err2;
  518.     }
  519.     errmsg = fontRead(kanjiPath, &(kanjiFont));
  520.     if (errmsg) {
  521. err2:    fontUnLoad();
  522.         return(errmsg);
  523.     }
  524.  
  525.     /*
  526.      *    build line number conversion table
  527.      */
  528.     p = 0;
  529.     for (i = 0; i < MAX_LINE_25_MODE; i++) {
  530.         /* physical line no to GRAPHIC VRAM address conversion table */
  531.         ltopTab[i] = p;
  532.         p += (MAX_X_DOT/8)*asciiFont.dwidth;
  533.     }
  534.  
  535.     /*
  536.      * clear cache
  537.      */
  538.     for (i = 0; i < fontCacheSize; i++)
  539.         fontHashTable[i] = 0;
  540.  
  541.     fontFileLoaded = YES;
  542.     return((char *)NULL);
  543. }
  544.  
  545. /*
  546. ** static void fontUnLoad()
  547.  *
  548.  * unload font; free font memory
  549.  */
  550. static void fontUnLoad()
  551. {
  552.     freeMem((void FAR *)asciiFont.indexTab);
  553.     freeMem((void FAR *)asciiFont.fontBuf);
  554.     freeMem((void FAR *)kanjiFont.indexTab);
  555.     freeMem((void FAR *)kanjiFont.fontBuf);
  556.     freeMem((void FAR *)kanjiFontCache);
  557.     freeMem((void FAR *)fontHashTable);
  558.     asciiFont.indexTab = kanjiFont.indexTab = (long HUGE *)0;
  559.     asciiFont.fontBuf = kanjiFont.fontBuf = (char FAR *)0;
  560.     kanjiFontCache = (u_char FAR *)0;
  561.     fontHashTable = (u_short FAR *)0;
  562.     fontFileLoaded = NO;
  563.     if (kanjiPath) {
  564.         close(kanjiPath);
  565.         kanjiPath = 0;
  566.     }
  567. }
  568.  
  569. /*
  570. ** static char *fontRead(FILE *ifp, FontDesc *fontDesc, int hashMode)
  571.  *
  572.  * read one font file into memory
  573.  *
  574.  * NOTE:
  575.  *        Font file consists of font body part and index part.
  576.  *
  577.  *        Fonts in font part are able to separate on memory part and
  578.  *        off memory part. While on memory part is stored in fontBuf[],
  579.  *        off memory part is not stored. On memory part is defined
  580.  *        by fontDesc->onMemEndChar and number of font is fontDesc->numOnMemFont.
  581.  *
  582.  *        All of index part is stored on memory indexTable[]. Index points
  583.  *        font body in fontBuf[] for on memory partial of font body.
  584.  *        And index points address in the font file for off memory partial
  585.  *        respectively.
  586.  *
  587.  */
  588. static char *fontRead(path, fontDesc)
  589. int path;
  590. FontDesc *fontDesc;
  591. {
  592.     long fontSize;
  593.     long indexSize;
  594.     register long HUGE *indexp;
  595.     register char FAR *fontp;
  596.     register char *p;
  597.     short offset;
  598.     short *q;
  599.     int size;
  600.     u_short code;
  601.  
  602.     /*
  603.      * calculate font body size and font index size
  604.      */
  605.     kanjiFontSize = fontDesc->wwidth * fontDesc->dwidth;
  606.     fontSize = (long)(fontDesc->numOnMemFont) * (long)kanjiFontSize;
  607.     indexSize = (long)(fontDesc->numIndex) * sizeof(long);
  608.  
  609. #ifdef DEBUG
  610.     printf("\nfontSize %ld, indexSize %ld\n", fontSize, indexSize);
  611. #endif
  612.     /*
  613.      * allocate index table memory
  614.      * allocate font memory
  615.      */
  616.     fontDesc->indexTab = (long HUGE *)allocMem(indexSize);
  617.     fontDesc->fontBuf = (char FAR *)allocMem(fontSize);
  618.     if (fontDesc->indexTab == 0 || fontDesc->fontBuf == 0)
  619.         goto memErr;
  620.     /*
  621.      * allocate font cache memory
  622.      */
  623.     if (fontDesc->onMemEndChar < fontDesc->endChar) {
  624.         if ((long)kanjiFontSize*fontCacheSize > 0x10000L)
  625.             fontCacheSize = 0xff00L / (long)kanjiFontSize;
  626.         kanjiFontCache = (u_char FAR *)allocMem((long)kanjiFontSize*fontCacheSize);
  627.         fontHashTable = (u_short FAR *)allocMem((long)fontCacheSize*sizeof(u_short));
  628.         if (kanjiFontCache == 0 || fontHashTable == 0) {
  629. memErr:
  630.             return("Can't allocate font memory, check $HTFONTCACHE");
  631.         }
  632.     }
  633.  
  634.     /*
  635.      * read font body part
  636.      */
  637.     lseek(path, fontDesc->fontAddress, 0);
  638. #ifdef DEBUG
  639.     printf("body address in file %ld, real %ld\n", fontDesc->fontAddress, tell(path));
  640. #endif
  641.     fontp = fontDesc->fontBuf;
  642.     while (fontSize > 0) {
  643.         size = (int)(fontSize < MAX_XFER_BUF ? fontSize : MAX_XFER_BUF);
  644.         if ((size = read(path, XFerBuffer, size)) == ERR) {
  645.             goto fontErr;
  646.         }
  647.         fontSize -= size;
  648.         for (p = XFerBuffer; size > 0; --size)
  649.             *fontp++ = *p++;
  650.     }
  651.  
  652.     /*
  653.      * read font index part
  654.      */
  655.     lseek(path, fontDesc->indexAddress, 0);
  656. #ifdef DEBUG
  657.     printf("index address in file %ld, real %ld\n", fontDesc->indexAddress, tell(path));
  658. #endif
  659.     indexSize = (long)(fontDesc->numIndex);
  660.     indexp = fontDesc->indexTab;
  661.     /*
  662.      * first char; extra treatment because offset is always 0
  663.      */
  664.     code = fontDesc->startChar;
  665.     read(path, (char *)&offset, sizeof(short));
  666.     *indexp++ = (long)(fontDesc->fontBuf);
  667.     indexSize--;
  668.     code++;
  669.  
  670.     /*
  671.      * read and store index
  672.      */
  673.     while (indexSize > 0) {
  674.         size = (int)(indexSize < (MAX_XFER_BUF/sizeof(short)) ? indexSize : (MAX_XFER_BUF/sizeof(short)));
  675.         if ((size = read(path, XFerBuffer, size*sizeof(short))) == ERR) {
  676. fontErr:
  677.             return("unexpected EOF in font file");
  678.         }
  679.         size /= 2;
  680.         indexSize -= size;
  681.         for (q = (short *)XFerBuffer; size > 0; --size, q++, code++) {
  682.             if (*q == 0)
  683.                 /* 
  684.                  * font for not defined font
  685.                  */
  686.                 *indexp++ = 0L;
  687.             else if (code <= fontDesc->onMemEndChar)
  688.                 /*
  689.                  * on memory font; store index to font body in fontBuf[]
  690.                  */
  691.                 *indexp++ = (long)(fontDesc->fontBuf) + (long)(*q)*(long)kanjiFontSize;
  692.             else
  693.                 /*
  694.                  * off memory font; store address of font body in the font file
  695.                  */
  696.                 *indexp++ = (long)(fontDesc->fontAddress) + (long)(*q)*(long)kanjiFontSize;
  697.         }
  698.     }
  699. #if DEBUG
  700.     printf("load done\n");
  701. #endif
  702.     return((char *)NULL);
  703. }
  704.  
  705.  
  706. #else /* SOFT_FONT */
  707. void fontInit(){}
  708. void fontEnd(){}
  709. void softFontLocate(){}
  710. void softCursorOnOff(){}
  711. void softFontPutChar(){}
  712. void softFontInsertLine(){}
  713. void softFontDeleteLine(){}
  714. void softFontInsertChar(){}
  715. void softFontDeleteChar(){}
  716. void softFontClearColumn(){}
  717. void softFontClearLine(){}
  718. char *fontLoad(){return((char *)0);}
  719. void fontUnLoad(){}
  720. #endif /* SOFT_FONT */
  721.