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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
#include "defs.h"
#include "global.h"
#include "rastfont.h"
#include "pxlfont.h"
int pxltype_access();
void init_pxl_fontinfo();
struct fontop pxlop = {
"pxl",
pathtype_init,
pxltype_access,
init_pxl_fontinfo,
};
static FILE *fntfp;
void loadpxlchar();
pxltype_access(proto, fe, acca)
char *proto;
struct font_entry *fe;
struct accarg *acca;
{
BOOLEAN ok;
rast_mag(fe, acca, 5);
pave(fe->name, proto, acca);
ok = access(fe->name, R_OK) == 0;
#ifdef DEBUG
rast_debug_report(fe, acca, ok);
#endif
return (ok ? check_id(fe->name, PXLID) : FALSE);
}
void
init_pxl_fontinfo(fe)
register struct font_entry *fe;
{
void read_pxl_fontinfo();
fe->fnt_readfontinfo = read_pxl_fontinfo;
init_rast_fontinfo(fe);
}
void
read_pxl_fontinfo(fe)
register struct font_entry *fe;
{
int t, i, fdir, nchars;
long possave;
register struct rastchar_entry *ce;/* temporary char_entry pointer */
struct rastinitfontinfo *rii;
struct rastfntinfo *rfi;
int ds, mg;
openfontfile(fe);
fntfp = fe->openfile;
if ((t = getuint(fntfp, 4)) != PXLID)
Fatal("PXL ID = %d, can only process PXL ID = %d files",
t, PXLID);
(void)fseek(fntfp, -20L, 2);
t = getuint(fntfp, 4);
if ((fe->c != 0) && (t != 0) && (fe->c != t))
Warning("font = \"%s\",\n-->font checksum = %d,\n-->dvi checksum = %d",
fe->name, fe->c, t);
mg = getuint(fntfp, 4);
ds = getuint(fntfp, 4);
t = ftell(fntfp) - 12;
(void)fseek(fntfp, (long)(fdir = getuint(fntfp, 4) * 4), 0);
nchars = (t-fdir)/(4*4);
if (nchars > NPXLCHARS) {
Fatal("PXL-font dir size of %s is %d\n", fe->name, nchars);
} else if (nchars != NHALFPXLCHARS && nchars != NPXLCHARS) {
Warning("PXL-font dir size of %s is %d\n", fe->name, nchars);
}
rii = rastinifinfo(fe);
rastfinfo(fe) = rfi = alloc_rastfinfo(rii->maxc+1, TRUE, rii);
dev_rast_initfe(fe);
/* rfi->designsize = ds; */
/* rfi->magnification = mg; */
rfi->nfntchars = nchars;
for (i = 0; i < nchars; i++) {
if (rii->mark[i] == FALSE) {
(void)fseek(fntfp, 16L, 1);
} else {
ce = &(rfi->ch[i]);
ce->width = getuint(fntfp, 2);
ce->height = getuint(fntfp, 2);
ce->xoffset = getint(fntfp, 2);
ce->yoffset = getint(fntfp, 2);
/*ce->dev_char = NONCHAR;*/
ce->nbpl = ((unsigned short)(ce->width + 31) >> 5) * 4;
ce->where.fileoffset = getuint(fntfp, 4) * 4;
ce->tfmw = scale(getuint(fntfp, 4), fe->s);
if (ce->where.fileoffset == 0) {
/*ce->where.fileoffset = NONEXISTANT;*/
Warning("The glyf of char %x in %s missing\n", i, fe->name);
continue;
}
possave = ftell(fntfp);
loadpxlchar(fe, ce);
dev_rast_initfontdict(fe, i);
(void)fseek(fntfp, possave, 0);
}
}
free((char *)rii);
}
/* ARGSUSED */
void
loadpxlchar(fe, ce)
struct font_entry *fe;
register struct rastchar_entry *ce;
{
char *pixel;
int nbytes;
(void)fseek(fntfp, (long)ce->where.fileoffset, 0);
nbytes = ce->nbpl * ce->height;
if ((pixel = malloc((unsigned)nbytes)) == NULL)
Fatal("Unable to allocate memory for char\n");
(void)fread(pixel, 1, nbytes, fntfp);
ce->where.pixptr = pixel;
}
|