summaryrefslogtreecommitdiff
path: root/dviware/beebe/src/charpxl.h
blob: 49b6eb1852f8ebdf6595b41449876886e9e0051a (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
/* -*-C-*- charpxl.h */
/*-->charpxl*/
/**********************************************************************/
/******************************* charpxl ******************************/
/**********************************************************************/

int
charpxl(c,outfcn)	/* return 0 on success, and EOF on failure */
BYTE c;			/* current character value */
void (*outfcn)();	/* (possibly NULL) function to output current row */
{
    UNSIGN16 i,j;		/* loop index */
    long p;			/* offset into font file */
    register UNSIGN32 *q;	/* pointer into rasters area */
    struct char_entry *tcharptr;/* temporary char_entry pointer */

    if ((c < FIRSTPXLCHAR) || (LASTPXLCHAR < c))
    {
	(void)warning(
	    "charpxl():  Character value out of range for PXL font file");
	return(EOF);
    }
    tcharptr = &(fontptr->ch[c]);

    if (!VISIBLE(tcharptr))
	return(0);	/* do nothing for empty characters */

    p = (long)tcharptr->fontrp;	/* font file raster pointer */
    if (p < 0L)
    {
	(void)warning(
	    "charpxl():  Requested character not found in PXL font file");
	return(EOF);
    }

    if (FSEEK(fontfp,p,0))
    {
	(void)warning(
	    "charpxl():  FSEEK() failure for PXL font file character raster");
	return(EOF);
    }

    if (outfcn != (void(*)())NULL)
    {
	img_words = ((UNSIGN16)(tcharptr->wp) + 31) >> 5;
	for (i = 0; i < (UNSIGN16)(tcharptr->hp); ++i)
	{
	    q = img_row;
	    for (j = 0; j < img_words; ++j)
		*q++ = (UNSIGN32)nosignex(fontfp,(BYTE)4);
	    (void)(*outfcn)(c,i);
	}
    }
    return(0);
}