void
read_PXL_index(fontp)
register struct font *fontp;
{
register FILE *fp = fontp->file;
register struct glyph *g;
long font_dir_ptr;
long trailer_ptr;
if (debug & DBG_PK)
Printf("Reading PXL file %s\n", fontp->filename);
fontp->read_char = read_PXL_char;
/* seek to trailer info */
Fseek(fp, (long) -4, 2);
while (four(fp) != 1001)
Fseek(fp, (long) -5, 1);
Fseek(fp, (long) -5 * 4, 1);
trailer_ptr = ftell(fp);
(void) four(fp); /* checksum */
(void) four(fp); /* magnify */
(void) four(fp); /* design size */
font_dir_ptr = sfour(fp) * 4;
(void) four(fp); /* pxl id word */
/* seek to font directory */
Fseek(fp, font_dir_ptr, 0);
maxchar = (trailer_ptr - font_dir_ptr) / 16 - 1;
fontp->glyph = (struct glyph *)
xmalloc((maxchar + 1) * sizeof(struct glyph), "glyph array");
for (g = fontp->glyph; g <= fontp->glyph + maxchar; ++g) {
g->bitmap.bits = NULL;
g->bitmap2.bits = NULL;
#ifdef GREY
g->pixmap2 = NULL;
#endif
g->bitmap.w = two(fp);
g->bitmap.h = two(fp);
g->x = stwo(fp);
g->y = stwo(fp);
g->addr = four(fp) * 4;
/*
** The TFM-width word is kind of funny in the units
** it is expressed in. It works this way:
**
** If a glyph has width 'w' in a font with design-size
** 'd' (both in same units), the TFM-width word is
**
** t = (w/d) * 2^20
**
** Therefore, in order to find the glyph width in
** DVI units (1 / 2^16 points), we take the design-size
** 'd' (in DVI's), the magnification 'm' of the PXL file
** and the TFM-width word 't' to the width (in DVI's)
** as follows:
**
** dmt
** w = -----
** 2^20
**
** But the magnification of the PXL file is just the
** scaled size 's' over the design size, so the final
** expression for the width is
**
** st
** w = ----
** 2^20
**
*/