This is fontdef.c in view mode; [Download] [Up]
/*
* fontdef.c of dviamiga software package.
*
* Stores the data from a font definition into the global data structures.
* A routine skipnop is also included to skip over nops and font definitions.
* It returns the first byte not a nop or font definition.
*/
#include "structures.h"
/*
* These are the external routines it calls.
*/
extern shalfword dvibyte() ;
extern halfword twobytes() ;
extern integer signedquad(), threebytes() ;
extern void dviseek(), skipover() ;
/*
* The external variables it uses:
*/
extern TeXfontdesctype *TeXfonts[] ;
extern integer curpos, thispage ;
extern int tracking ;
extern int debugon ;
extern Boolean scanning ;
extern void free() ;
long fakeeof = 2000000000 ;
/*
* We use mymalloc here:
*/
void *mymalloc() ;
/*
* fontdef takes a font definition in the dvi file and loads the data
* into its data structures.
*/
void fontdef()
{ register int i, j ;
register char *p ;
register TeXfontdesctype *fp ;
register shalfword fn ;
register integer t1, t2, t3 ;
fn = dvibyte() ;
#ifdef DEBUG
if (debugon > 4 ) {
printf("The font I am defining is number %i\n", fn) ;
}
#endif
if ((TeXfonts[fn] == NULL) || !scanning)
{
#ifdef DEBUG
if (debugon > 4 ) {
printf("Font not already defined\n");
}
#endif
t1 = signedquad() ;
t2 = signedquad() ;
t3 = signedquad() ;
i = dvibyte() ;
j = dvibyte() ;
fp = mymalloc(sizeof(TeXfontdesctype)+i+j+1, 0L) ;
TeXfonts[fn] = fp ;
fp->loaded = NULL ;
fp->checksum = t1 ;
fp->scaledsize = t2 ;
fp->designsize = t3 ;
fp->thinspace = t2 / 6 ;
p = fp->name ;
for (; i>0; i--)
*p++ = dvibyte() ;
*p++ = 0 ;
for (; j>0; j--)
*p++ = dvibyte() ;
*p++ = 0 ;
for (i=0; i<256; i++)
fp->scaledwidth[i] = 0 ;
#ifdef DEBUG
if (debugon > 4)
printf("Defining font %s\n", fp->name+1) ;
#endif
} else {
#ifdef DEBUG
if (debugon > 4) {
printf("Font already defined\n") ;
}
#endif
for (i = 1; i<=12; i++) dvibyte() ;
i = dvibyte() + dvibyte() ;
for (; i>0; i--) dvibyte() ;
}
}
/*
* The next routine handles nops or font definitions between pages in a
* dvi file. Returns the first command that is not a nop or font definition.
*
* Now handles specials (but ignores them)
*/
int
skipnop()
{
register int cmd ;
if (curpos >= fakeeof)
return -1 ;
while (1) {
switch(cmd=dvibyte()) {
case 138: break ;
case 239: skipover((int)dvibyte()) ; break ; /* xxx1 */
case 240: skipover((int)twobytes()) ; break ; /* xxx2 */
case 241: skipover((int)threebytes()) ; break ; /* xxx3 */
case 242: skipover((int)signedquad()) ; break ; /* xxx4 */
case 243: case 244: case 245: case 246: fontdef(cmd-242) ; break ;
default: return cmd ;
}
}
}
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.