home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3.4.17 [SPARC, PA-RISC] / nextstep33_risc.iso / NextLibrary / TeX / tex / src / texview / fontdef.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-13  |  2.5 KB  |  98 lines

  1. /*
  2.  *   fontdef.c of dviamiga software package.
  3.  *
  4.  *  Stores the data from a font definition into the global data structures.
  5.  *  A routine skipnop is also included to skip over nops and font definitions.
  6.  *  It returns the first byte not a nop or font definition.
  7.  */
  8. #include "structures.h"
  9. /*
  10.  *   These are the external routines it calls.
  11.  */
  12. extern shalfword dvibyte() ;
  13. extern halfword twobytes() ;
  14. extern integer signedquad(), threebytes() ;
  15. extern void dviseek(), skipover() ;
  16. /*
  17.  *   The external variables it uses:
  18.  */
  19. extern TeXfontdesctype *TeXfonts[] ;
  20. extern integer curpos, thispage ;
  21. extern int tracking ;
  22. extern int debugon ;
  23. long fakeeof = 2000000000 ;
  24. /*
  25.  *   We use mymalloc here:
  26.  */
  27. void *mymalloc() ;
  28. /*
  29.  *   fontdef takes a font definition in the dvi file and loads the data
  30.  *   into its data structures.
  31.  */
  32. void fontdef()
  33. {  register int i, j ;
  34.    register char *p ;
  35.    register TeXfontdesctype *fp ;
  36.    register shalfword fn ;
  37.    register integer t1, t2, t3 ;
  38.  
  39.    fn = dvibyte() ;
  40.    if (TeXfonts[fn] == NULL)
  41.    {
  42.       t1 = signedquad() ;
  43.       t2 = signedquad() ;
  44.       t3 = signedquad() ;
  45.       i = dvibyte() ;
  46.       j = dvibyte() ;
  47.       fp = mymalloc(sizeof(TeXfontdesctype)+i+j+1, 0L) ;
  48.       TeXfonts[fn] = fp ;
  49.       fp->loaded = NULL ;
  50.       fp->checksum = t1 ;
  51.       fp->scaledsize = t2 ;
  52.       fp->designsize = t3 ;
  53.       fp->thinspace = t2 / 6 ;
  54.       p = fp->name ;
  55.       for (; i>0; i--)
  56.          *p++ = dvibyte() ;
  57.       *p++ = 0 ;
  58.       for (; j>0; j--)
  59.          *p++ = dvibyte() ;
  60.       *p++ = 0 ;
  61.       for (i=0; i<256; i++)
  62.          fp->scaledwidth[i] = 0 ;
  63. #ifdef DEBUG
  64.       if (debugon > 4)
  65.          printf("Defining font %s\n", fp->name+1) ;
  66. #endif
  67.    } else {
  68.       for (i = 1; i<=12; i++) dvibyte() ;
  69.       i = dvibyte() + dvibyte() ;
  70.       for (; i>0; i--) dvibyte() ;
  71.    }
  72. }
  73. /*
  74.  *   The next routine handles nops or font definitions between pages in a
  75.  *   dvi file.  Returns the first command that is not a nop or font definition.
  76.  *
  77.  *   Now handles specials (but ignores them)
  78.  */
  79. int
  80. skipnop()
  81. {
  82.   register int cmd ;
  83.  
  84.    if (curpos >= fakeeof)
  85.       return -1 ;
  86.    while (1) {
  87.       switch(cmd=dvibyte()) {
  88. case 138: break ;
  89. case 239: skipover((int)dvibyte()) ; break ; /* xxx1 */
  90. case 240: skipover((int)twobytes()) ; break ; /* xxx2 */
  91. case 241: skipover((int)threebytes()) ; break ; /* xxx3 */
  92. case 242: skipover((int)signedquad()) ; break ; /* xxx4 */
  93. case 243: case 244: case 245: case 246: fontdef(cmd-242) ; break ;
  94. default: return cmd ;
  95.       }
  96.    }
  97. }
  98.