summaryrefslogtreecommitdiff
path: root/dviware/beebe/src/readpxl.h
blob: 3b94e1cf1a22fa8170035c17f78b6440cd05e936 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/* -*-C-*- readpxl.h */
/*-->readpxl*/
/**********************************************************************/
/****************************** readpxl *******************************/
/**********************************************************************/

int
readpxl()	/* return 0 on success, EOF on failure */
{
    UNSIGN32 checksum;
    register struct char_entry *tcharptr;/* temporary char_entry pointer */
    register UNSIGN16 the_char;		/* loop index */

#if    OS_VAXVMS
    /* VMS binary files are stored with NUL padding to the next 512 byte
    multiple.  We therefore search backwards to the last non-NULL byte
    to the find real end-of-file, then move back 20 bytes from that. */
    FSEEK(fontfp,0L,2);		/* seek to end-of-file */
    while (FSEEK(fontfp,-1L,1) == 0)
    {
        the_char = (UNSIGN16)fgetc(fontfp);
	if (the_char)
	  break;		/* exit leaving pointer PAST last non-NUL */
	UNGETC((char)the_char,fontfp);
    }
    if (FSEEK(fontfp,-20L,1))	/* 20 bytes before last non-NUL for checksum */
#else
    if (FSEEK(fontfp,-20L,2))	/* 20 bytes before end-of-file for checksum */
#endif
    {
	(void)warning("readpxl():  FSEEK() failed--PXL font file may be empty");
	return(EOF);
    }

    checksum = nosignex(fontfp,(BYTE)4);
    if ((fontptr->c != 0L) && (checksum != 0L) && (fontptr->c != checksum))
    {
	(void)sprintf(message,
	"readpxl():  font [%s] has checksum = 10#%010lu [16#%08lx] [8#%011lo] \
different from DVI checksum = 10#%010lu [16#%08lx] [8#%011lo].  \
TeX preloaded .fmt file is probably out-of-date with respect to new fonts.",
	    fontptr->name, fontptr->c, fontptr->c, fontptr->c,
	    checksum, checksum, checksum);
	(void)warning(message);
    }
    fontptr->magnification = nosignex(fontfp,(BYTE)4);
    fontptr->designsize = nosignex(fontfp,(BYTE)4);
    if (FSEEK(fontfp, (long)(nosignex(fontfp,(BYTE)4) << 2), 0))
    {
	(void)warning(
	"readpxl():  FSEEK() did not find PXL font file character directory");
	return(EOF);
    }

    for (the_char = FIRSTPXLCHAR; the_char <= LASTPXLCHAR; the_char++)
    {
	tcharptr = &(fontptr->ch[the_char]);
	tcharptr->wp = (COORDINATE)nosignex(fontfp,(BYTE)2);
	tcharptr->hp = (COORDINATE)nosignex(fontfp,(BYTE)2);
	tcharptr->xoffp = (COORDINATE)signex(fontfp,(BYTE)2);
	tcharptr->yoffp = (COORDINATE)signex(fontfp,(BYTE)2);

	/* convert (32-bit) word pointer to byte pointer */
	tcharptr->fontrp = (long)(nosignex(fontfp,(BYTE)4) << 2);

	tcharptr->tfmw = (UNSIGN32)(((float)nosignex(fontfp,(BYTE)4) *
	    (float)fontptr->s) / (float)(1L<<20));
	tcharptr->pxlw = (UNSIGN16)PIXROUND((INT32)(tcharptr->tfmw), conv);
	tcharptr->refcount = 0;			/* character unused */
	tcharptr->rasters = (UNSIGN32*)NULL;	/* no raster description */
    }

#if    (BBNBITGRAPH | HPJETPLUS | POSTSCRIPT | IMPRESS | CANON_A2)
    (void)newfont();
#endif

    return(0);
}