home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / textutil / tex / p_drivers / !TeX / TeXSource / beebe / h / loadchar < prev    next >
Encoding:
Text File  |  1992-01-13  |  2.7 KB  |  72 lines

  1. /* -*-C-*- loadchar.h */
  2. /*-->loadchar*/
  3. /**********************************************************************/
  4. /****************************** loadchar ******************************/
  5. /**********************************************************************/
  6.  
  7. #ifdef __STDC__
  8. void 
  9. loadchar(register BYTE c)
  10. #else 
  11. void 
  12. loadchar(c)  
  13. BYTE c;        /* character number in current font */ 
  14. #endif
  15.  
  16. /***********************************************************************
  17.     This simple version will do for now.  Even in a book DVI file, there
  18.     are unlikely to be more than about 25 fonts used and with an average
  19.     of 50 characters  each, this  is about  1250 character  definitions.
  20.     With typical character  sizes of 10  point type on  a 300  dots/inch
  21.     device, each would take a block of (10/72)*300 = 42 dots square,  or
  22.     about 84 words each,  for a total storage  requirement of 84*1250  =
  23.     105000 words.  This is  quite reasonable for  the DEC-20/60 and  VAX
  24.     Unix  implementations,  and  may  be  acceptable  on  large   memory
  25.     microprocessors like the MC68000 and NS16000.
  26.  
  27.     However, for future expansion, a  reference count of each  character
  28.     is  maintained,  and  the  total  storage  allocated  for  character
  29.     descriptions is recorded.  Then, when  malloc fails, or MAXCACHE  is
  30.     reached, the font  entries can  be scanned  to find  the least  used
  31.     characters whose  raster  storage  can  then  be  freed  and  malloc
  32.     retried.
  33. ***********************************************************************/
  34.  
  35. {
  36.     void (*charyy)();        /* subterfuge to get around PCC-20 bug */
  37.     register UNSIGN32 nwords;    /* how many 32-bit words we need */
  38.     register struct char_entry *tcharptr;
  39.  
  40.     if ((c < FIRSTPXLCHAR) || (LASTPXLCHAR < c)) /* check character range */
  41.     return;
  42.  
  43.     tcharptr = &(fontptr->ch[c]);
  44.  
  45.     if (!VISIBLE(tcharptr))    /* check for empty character rasters */
  46.     return;
  47.  
  48.     nwords = (UNSIGN32)(((tcharptr->wp+31) >> 5) * (tcharptr->hp));
  49.  
  50.     tcharptr->rasters = (UNSIGN32*)MALLOC((unsigned)(nwords*sizeof(UNSIGN32)));
  51.     if (tcharptr->rasters == (UNSIGN32*)NULL)
  52.     {
  53.     (void)sprintf(message,"loadchar():  Could not allocate %ld words of \
  54. raster space--used %ld words so far",
  55.         (long)nwords,(long)cache_size);
  56.     (void)fatal(message);
  57.     }
  58.     tcharptr->refcount = 0;        /* clear reference count */
  59.     cache_size += (INT32)nwords;    /* update cache size record */
  60.  
  61.     if (fontptr != pfontptr)
  62.     openfont(fontptr->n);
  63.  
  64.     if (fontfp == (FILE *)NULL)        /* do nothing if no font file */
  65.     return;
  66.  
  67.     /* Bug workaround: PCC-20 otherwise jumps to charxx instead of *charxx */
  68.     charyy = fontptr->charxx;
  69.     (void)(*charyy)(c,outrow);        /* load character from font file */
  70. }
  71.  
  72.