v03i039: dvi previewer, Part03/03

Mike Wexler mikew at wyse.wyse.com
Wed Mar 8 04:45:06 AEST 1989


Submitted-by: vojta at bosco.berkeley.edu
Posting-number: Volume 3, Issue 39
Archive-name: xdvi/part03

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 3 (of 3)."
# Contents:  AUTHOR Imakefile Makefile_10 dvi.h gf.c mktable.c pk.c
#   pxl.c pxl_open.c xdvi.h xdvi10.man.s
# Wrapped by mikew at wyse on Tue Mar  7 10:42:22 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'AUTHOR' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'AUTHOR'\"
else
echo shar: Extracting \"'AUTHOR'\" \(1308 characters\)
sed "s/^X//" >'AUTHOR' <<'END_OF_FILE'
X(Message inbox:1046)
XReturn-Path: usenet%agate.Berkeley.EDU at ucbvax.Berkeley.EDU
XReceived:  by wyse.wyse.com (5.58/Wyse master/5-13-88)
X	id AA24270; Mon, 6 Mar 89 10:21:26 PST
XReceived: from UCBVAX.Berkeley.EDU by uunet.UU.NET (5.61/1.14) with SMTP 
X	id AA16785; Sun, 5 Mar 89 19:11:28 -0500
XReceived: from agate.Berkeley.EDU by ucbvax.Berkeley.EDU (5.61/1.33)
X	id AA05984; Sun, 5 Mar 89 16:12:08 -0800
XReceived: by agate.berkeley.edu (5.61/1.30)
X	id AA08053; Sun, 5 Mar 89 16:10:54 PST
XTo: comp-sources-x at ucbvax.Berkeley.EDU
XPath: agate!math.berkeley.edu!vojta
XFrom: vojta%bosco.Berkeley.EDU at ucbvax.Berkeley.EDU (Paul Vojta)
XNewsgroups: comp.sources.x
XSubject: xdvi, a TeX dvi file previewer (part 1 of 3)
XMessage-Id: <21190 at agate.BERKELEY.EDU>
XDate: 6 Mar 89 00:10:47 GMT
XSender: usenet%agate.Berkeley.EDU at ucbvax.Berkeley.EDU
XReply-To: vojta%bosco.Berkeley.EDU at ucbvax.Berkeley.EDU (Paul Vojta)
XOrganization: Math Dept., UC Berkeley
XLines: 1830
X
X
XEnclosed is an updated version of the program xdvi.  This version has been
Xmodified to use the toolkit (specifically, a viewport widget), and it also
Xhas a `magnifying glass.'  tpic specials, too (X11 only).  I should note,
Xhowever, that it might not work with color VAXstations.  I understand that
Xthis is a server bug.
X
X--Paul Vojta, vojta at math.berkeley.edu
X
END_OF_FILE
if test 1308 -ne `wc -c <'AUTHOR'`; then
    echo shar: \"'AUTHOR'\" unpacked with wrong size!
fi
# end of 'AUTHOR'
fi
if test -f 'Imakefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Imakefile'\"
else
echo shar: Extracting \"'Imakefile'\" \(770 characters\)
sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
XFONT_PATH=TEXFONTS
XDEFAULT_FONT_PATH=/usr/local/tex/fonts
XFONTFORMATS_C=gf.c pk.c pxl.c
XFONTFORMATS_O=gf.o pk.o pxl.o
X
XDEFINES=-DBMSHORT \
X		    -DFONT_PATH=\"$(FONT_PATH)\" \
X		    -DDEFAULT_FONT_PATH=\"$(DEFAULT_FONT_PATH)\"
XSYSLAST_LIBRARIES=-lXaw -lXmu -lXt -lX11 -lm
XSRCS=xdvi.c dvi_init.c dvi_draw.c $(FONTFORMATS_C) pxl_open.c tpic.c
XOBJS=xdvi.o dvi_init.o dvi_draw.o $(FONTFORMATS_O) pxl_open.o tpic.o
X
XComplexProgramTarget(xdvi)
X
Xtable.h: mktable
X	mktable > table.h
X
Xmktable: mktable.c
X	$(CC) $(CFLAGS) -o mktable mktable.c
X
Xxdvi.man:
X	sed -e "s;%%FONT_PATH%%;$(FONT_PATH);g" \
X	    -e "s;%%DEFAULT_FONT_PATH%%;$(DEFAULT_FONT_PATH);g" \
X	    < xdvi.man.sed \
X	    > xdvi.man
X
Xclean::
X	$(RM) mktable table.h xdvi.man
X
Xlint::
X	lint $(INCLUDES) $(DEFINES) $(SRCS)
END_OF_FILE
if test 770 -ne `wc -c <'Imakefile'`; then
    echo shar: \"'Imakefile'\" unpacked with wrong size!
fi
# end of 'Imakefile'
fi
if test -f 'Makefile_10' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile_10'\"
else
echo shar: Extracting \"'Makefile_10'\" \(1373 characters\)
sed "s/^X//" >'Makefile_10' <<'END_OF_FILE'
X#
X# Makefile for dvi previewer.
X#
X# $Header: Makefile,v 1.2 87/05/14 14:05:34 eichin Locked $
X# $Source: /u1/uus/vs2/xdvi/RCS/Makefile,v $
X#
XFONT_PATH=TEXFONTS
XDEFAULT_FONT_PATH=/usr/local/tex/fonts
XDEFINES=-DX10 \
X  -DFONT_PATH=\"$(FONT_PATH)\" \
X  -DDEFAULT_FONT_PATH=\"$(DEFAULT_FONT_PATH)\"
XFONTFORMATS_C=gf.c pk.c pxl.c
XFONTFORMATS_O=gf.o pk.o pxl.o
XDESTDIR=
XBINDIR=/usr/sipb/$$(MACHTYPE)bin
XINCLUDES=-I/usr/include/X
XCFLAGS=-O $(DEFINES)
XLIBS=-lX
XSRCS=xdvi.c dvi_init.c dvi_draw.c $(FONTFORMATS_C) pxl_open.c \
X		    xdvi.h dvi.h table.h xdvi_curs.h xdvi_mask.h
XOBJS=xdvi.o dvi_init.o dvi_draw.o $(FONTFORMATS_O) pxl_open.o
XCC=/tuna_a/gnu/bin/gcc
XRM=rm -f
X
X.c.o:
X	$(CC) -c $(CFLAGS) $*.c
X
Xxdvi:	$(OBJS)
X	$(CC) -o xdvi $(OBJS) $(LIBS)
X	chmod go+rx xdvi
X
Xxdvi.o: xdvi.h xdvi_curs.h xdvi_mask.h
Xdvi_init.o:xdvi.h dvi.h
Xdvi_draw.o:xdvi.h dvi.h
X
Xgf.o:	xdvi.h
Xpk.o:	xdvi.h
Xpxl.o:	xdvi.h table.h
X
X# table.h: mktable
X# 	mktable > table.h
X
Xmktable: mktable.c
X	$(CC) $(CFLAGS) -o mktable mktable.c
X
Xxdvi.man: xdvi10.man.s
X	sed -e "s;%%FONT_PATH%%;$(FONT_PATH);g" \
X	    -e "s;%%DEFAULT_FONT_PATH%%;$(DEFAULT_FONT_PATH);g" \
X	    < xdvi10.man.s \
X	    > xdvi.man
X
Xinstall: all
X	install -c -s xdvi $(DESTDIR)$(BINDIR)
X
Xclean:
X	$(RM) mktable table.h *.o *.BAK *.CKP xdvi.man xdvi a.out core errs *~
X
Xlint:
X	lint $(DEFINES) xdvi.c dvi_init.c dvi_draw.c $(FONTFORMATS_C) pxl_open.c
END_OF_FILE
if test 1373 -ne `wc -c <'Makefile_10'`; then
    echo shar: \"'Makefile_10'\" unpacked with wrong size!
fi
# end of 'Makefile_10'
fi
if test -f 'dvi.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'dvi.h'\"
else
echo shar: Extracting \"'dvi.h'\" \(1417 characters\)
sed "s/^X//" >'dvi.h' <<'END_OF_FILE'
X/* $Header: dvi.h,v 10.5 86/02/01 15:44:52 tony Rel $ */
X
X#define SETCHAR0    0
X#define SET1        128
X#define SETRULE     132
X#define PUT1        133
X#define PUTRULE     137
X#define NOP         138
X#define BOP         139
X#define EOP         140
X#define PUSH        141
X#define POP         142
X#define RIGHT1      143
X#define RIGHT2      144
X#define RIGHT3      145
X#define RIGHT4      146
X#define W0          147
X#define W1          148
X#define W2          149
X#define W3          150
X#define W4          151
X#define X0          152
X#define X1          153
X#define X2          154
X#define X3          155
X#define X4          156
X#define DOWN1       157
X#define DOWN2       158
X#define DOWN3       159
X#define DOWN4       160
X#define Y0          161
X#define Y1          162
X#define Y2          163
X#define Y3          164
X#define Y4          165
X#define Z0          166
X#define Z1          167
X#define Z2          168
X#define Z3          169
X#define Z4          170
X#define FNTNUM0     171
X#define FNT1        235
X#define FNT2        236
X#define FNT3        237
X#define FNT4        238
X#define XXX1        239
X#define XXX2        240
X#define XXX3        241
X#define XXX4        242
X#define FNTDEF1     243
X#define FNTDEF2     244
X#define FNTDEF3     245
X#define FNTDEF4     246
X#define PRE         247
X#define POST        248
X#define POSTPOST    249
X
X#define TRAILER     223     /* Trailing bytes at end of file */
END_OF_FILE
if test 1417 -ne `wc -c <'dvi.h'`; then
    echo shar: \"'dvi.h'\" unpacked with wrong size!
fi
# end of 'dvi.h'
fi
if test -f 'gf.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'gf.c'\"
else
echo shar: Extracting \"'gf.c'\" \(6663 characters\)
sed "s/^X//" >'gf.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include "xdvi.h"
X
X/***
X ***	GF font reading routines.
X ***	Public routines are read_index and read_char.
X ***/
X
Xstatic	void	read_index(), read_char();
X
Xread_font_index_proc	read_GF_index	= read_index;
X
X#define	PAINT_0		0
X#define	PAINT1		64
X#define	PAINT2		65
X#define	PAINT3		66
X#define	BOC		67
X#define	BOC1		68
X#define	EOC		69
X#define	SKIP0		70
X#define	SKIP1		71
X#define	SKIP2		72
X#define	SKIP3		73
X#define	NEW_ROW_0	74
X#define	NEW_ROW_MAX	238
X#define	XXX1		239
X#define	XXX2		240
X#define	XXX3		241
X#define	XXX4		242
X#define	YYY		243
X#define	NO_OP		244
X#define	CHAR_LOC	245
X#define	CHAR_LOC0	246
X#define	PRE		247
X#define	POST		248
X#define	POST_POST	249
X
X#define	GF_ID_BYTE	131
X#define	TRAILER		223		/* Trailing bytes at end of file */
X
Xstatic	FILE	*GF_file;
X
Xstatic	void
Xexpect(ch)
X	ubyte ch;
X{
X	ubyte ch1 = one(GF_file);
X
X	if (ch1 != ch)
X		oops("Bad GF file:  %d expected, %d received.", ch, ch1);
X}
X
Xstatic	void
Xtoo_many_bits(ch)
X	ubyte ch;
X{
X	oops("Too many bits found when loading character %d", ch);
X}
X
X/*
X *	Public routines
X */
X
Xstatic	void
Xread_index(fontp)
X	register struct font *fontp;
X{
X	int	hppp, vppp;
X	ubyte	ch, cmnd;
X	register struct glyph *g;
X
X	fontp->read_char = read_char;
X	GF_file = fontp->file;
X/*
X *	Read the preamble.
X */
X	if (debug & DBG_PK)
X	    Printf("Reading header for GF pixel file %s\n", fontp->filename);
X	GF_file = fontp->file;
X	expect(PRE);
X	expect(GF_ID_BYTE);
X/*
X *	Find postamble.
X */
X	Fseek(GF_file, (long) -5, 2);
X	for (;;) {
X	    ch = one(GF_file);
X	    if (ch != TRAILER) break;
X	    Fseek(GF_file, (long) -2, 1);
X	}
X	if (ch != GF_ID_BYTE) oops("Bad end of font file %s", fontp->fontname);
X	Fseek(GF_file, (long) -6, 1);
X	expect(POST_POST);
X	Fseek(GF_file, sfour(GF_file), 0);	/* move to postamble */
X/*
X *	Read postamble.
X */
X	expect(POST);
X	(void) four(GF_file);	/* pointer to last eoc + 1 */
X	(void) four(fontp->file);		/* skip design size */
X	(void) four(fontp->file);		/* skip checksum */
X	hppp = sfour(fontp->file);
X	vppp = sfour(fontp->file);
X	if (debug && hppp != vppp)
X	    oops("Warning: aspect ratio not 1:1 for font %s", fontp->fontname);
X	(void) four(fontp->file);		/* skip min_m */
X	(void) four(fontp->file);		/* skip max_m */
X	(void) four(fontp->file);		/* skip min_n */
X	(void) four(fontp->file);		/* skip max_n */
X/*
X *	Prepare glyph array.
X */
X	for (g = fontp->glyph; g < &fontp->glyph[MAXCHARS]; ++g) {
X	    g->addr = 0;
X	    g->bitmap.bits = NULL;
X	    g->bitmap2.bits = NULL;
X	}
X/*
X *	Read glyph directory.
X */
X	while ((cmnd = one(GF_file)) != POST_POST) {
X	    ubyte ch;
X	    int addr;
X
X	    ch = one(GF_file);			/* character code */
X	    if (ch >= MAXCHARS)
X		oops("Character code %d outside range, file %s", ch,
X			fontp->fontname);
X	    g = &fontp->glyph[ch];
X	    switch (cmnd) {
X		case CHAR_LOC:
X		    g->dvi_adv = sfour(GF_file);
X		    (void) four(GF_file);	/* skip dy */
X		    break;
X		case CHAR_LOC0:
X		    g->dvi_adv = one(GF_file) << 16;
X		    break;
X		default:
X		    oops("Non-char_loc command found in GF preamble:  %d",
X			cmnd);
X	    }
X	    (void) four(GF_file);		/* skip width */
X	    addr = four(GF_file);
X	    if (addr != -1) g->addr = addr;
X	    if (debug & DBG_PK)
X		Printf("Read GF glyph for character %d; dy = %d, addr = %d\n",
X			ch, g->dvi_adv, addr);
X	}
X}
X
X
Xstatic	void
Xread_char(fontp, ch)
X	register struct font *fontp;
X	ubyte ch;
X{
X	register struct glyph *g;
X	ubyte	cmnd;
X	int	min_m, max_m, min_n, max_n;
X	BMUNIT	*cp, *basep, *maxp;
X	int	bytes_wide;
X	Boolean	paint_switch;
X#define	White	False
X#define	Black	True
X	Boolean	new_row;
X	int	count;
X	int	word_weight;
X
X	g = &fontp->glyph[ch];
X	GF_file = fontp->file;
X
X	if(debug & DBG_PK)
X	    Printf("Loading gf char %d", ch);
X
X	switch (cmnd = one(GF_file)) {
X	    case BOC:
X		(void) four(GF_file);		/* skip character code */
X		(void) four(GF_file);		/* skip pointer to prev char */
X		min_m = sfour(GF_file);
X		max_m = sfour(GF_file);
X		g->x = -min_m;
X		min_n = sfour(GF_file);
X		g->y = max_n = sfour(GF_file);
X		g->bitmap.w = max_m - min_m + 1;
X		g->bitmap.h = max_n - min_n + 1;
X		break;
X	    case BOC1:
X		(void) one(GF_file);		/* skip character code */
X		g->bitmap.w = one(GF_file);	/* max_m - min_m */
X		g->x = g->bitmap.w - one(GF_file);	/* ditto - max_m */
X		++g->bitmap.w;
X		g->bitmap.h = one(GF_file) + 1;
X		g->y = one(GF_file);
X		break;
X	    default:
X		oops("Bad BOC code:  %d", cmnd);
X	}
X	paint_switch = White;
X
X	if (debug & DBG_PK)
X	    Printf(", size=%dx%d, dvi_adv=%d\n", g->bitmap.w, g->bitmap.h,
X		g->dvi_adv);
X
X	alloc_bitmap(&g->bitmap, fontp->fontname, ch);
X	cp = basep = (BMUNIT *) g->bitmap.bits;
X/*
X *	Read character data into *basep
X */
X	bytes_wide = ROUNDUP(g->bitmap.w, BITS_PER_BMUNIT) * BYTES_PER_BMUNIT;
X	maxp = ADD(basep, g->bitmap.h * bytes_wide);
X        bzero(g->bitmap.bits, g->bitmap.h * bytes_wide);
X	new_row = False;
X	word_weight = BITS_PER_BMUNIT;
X	for (;;) {
X	    count = -1;
X	    cmnd = one(GF_file);
X	    if (cmnd < 64) count = cmnd;
X	    else if (cmnd >= NEW_ROW_0 && cmnd <= NEW_ROW_MAX) {
X		count = cmnd - NEW_ROW_0;
X		paint_switch = White;	/* it'll be complemented later */
X		new_row = True;
X	    }
X	    else switch (cmnd) {
X		case PAINT1:
X		case PAINT2:
X		case PAINT3:
X		    count = num(GF_file, cmnd - PAINT1 + 1);
X		    break;
X		case EOC:
X		    if (cp >= ADD(basep, bytes_wide)) too_many_bits(ch);
X		    return;
X		case SKIP1:
X		case SKIP2:
X		case SKIP3:
X		    *((char **) &basep) +=
X			num(GF_file, cmnd - SKIP0) * bytes_wide;
X		case SKIP0:
X		    new_row = True;
X		    paint_switch = White;
X		    break;
X		case XXX1:
X		case XXX2:
X		case XXX3:
X		case XXX4:
X		    Fseek(GF_file, (long) num(GF_file, cmnd - XXX1 + 1), 1);
X		    break;
X		case YYY:
X		    (void) four(GF_file);
X		    break;
X		case NO_OP:
X		    break;
X		default:
X		    oops("Bad command in GF file:  %d", cmnd);
X	    } /* end switch */
X	    if (new_row) {
X		*((char **) &basep) += bytes_wide;
X		if (basep >= maxp || cp >= basep) too_many_bits(ch);
X		cp = basep;
X		word_weight = BITS_PER_BMUNIT;
X		new_row = False;
X	    }
X	    if (count >= 0) {
X		while (count)
X		    if (count <= word_weight) {
X#ifndef	MSBITFIRST
X			if (paint_switch)
X			    *cp |= bit_masks[count] <<
X				(BITS_PER_BMUNIT - word_weight);
X#endif	MSBITFIRST
X			word_weight -= count;
X#ifdef	MSBITFIRST
X			if (paint_switch)
X			    *cp |= bit_masks[count] << word_weight;
X#endif	MSBITFIRST
X			break;
X		    }
X		    else {
X			if (paint_switch)
X#ifndef	MSBITFIRST
X			    *cp |= bit_masks[word_weight] <<
X				(BITS_PER_BMUNIT - word_weight);
X#else	MSBITFIRST
X			    *cp |= bit_masks[word_weight];
X#endif	MSBITFIRST
X			cp++;
X			count -= word_weight;
X			word_weight = BITS_PER_BMUNIT;
X		    }
X		paint_switch = 1 - paint_switch;
X	    }
X	} /* end for */
X}
END_OF_FILE
if test 6663 -ne `wc -c <'gf.c'`; then
    echo shar: \"'gf.c'\" unpacked with wrong size!
fi
# end of 'gf.c'
fi
if test -f 'mktable.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mktable.c'\"
else
echo shar: Extracting \"'mktable.c'\" \(819 characters\)
sed "s/^X//" >'mktable.c' <<'END_OF_FILE'
X#ifndef lint
Xstatic char *mktable_c = 
X  "$Header: mktable.c,v 10.5 86/02/01 15:44:59 tony Rel $";
X#endif 	lint
X
X#include <stdio.h>
X
Xunsigned char reverse_byte[0x100] = { 0 };
X
Xmain()
X{
X	seed_table();
X	fill_in_table();
X	print_table();
X}
X
Xseed_table()
X{
X	int i = 0;
X	int j = 0x100/2;
X	int b = 0;
X
X	for (;;) {
X		reverse_byte[i] = b;
X		if (j == 0)
X			break;
X		i = 2*i + 1;
X		b = b + j;
X		j = j/2;
X	}
X}
X
Xfill_in_table()
X{
X	int b;
X
X	for (b = 1; b < 0x100-2; b += 1)
X		reverse_byte[b+1] =
X			reverse_byte[b] ^ reverse_byte[b^(b+1)];
X}
X
Xprint_table()
X{
X	int b;
X
X	printf("unsigned char reverse_byte[0x100] = {\n\t");
X	b = 0;
X	for (;;) {
X		printf("0x%02x", reverse_byte[b] & 0xff);
X		b += 1;
X		if (b == 0x100) {
X			printf("\n};\n");
X			return;
X		} else if (b % 8 == 0) {
X			printf(",\n\t");
X		} else {
X			printf(", ");
X		}
X	}
X}
END_OF_FILE
if test 819 -ne `wc -c <'mktable.c'`; then
    echo shar: \"'mktable.c'\" unpacked with wrong size!
fi
# end of 'mktable.c'
fi
if test -f 'pk.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'pk.c'\"
else
echo shar: Extracting \"'pk.c'\" \(8614 characters\)
sed "s/^X//" >'pk.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include "xdvi.h"
X
X/***
X ***	PK font reading routines.
X ***	Public routines are read_index and read_char.
X ***/
X
Xstatic	void	read_index(), read_char();
X
Xread_font_index_proc	read_PK_index	= read_index;
X
X#define PK_ID      89
X#define PK_CMD_START 240
X#define PK_X1     240
X#define PK_X2     241
X#define PK_X3     242
X#define PK_X4     243
X#define PK_Y      244
X#define PK_POST   245
X#define PK_NOOP   246
X#define PK_PRE    247
X
Xstatic	int	PK_flag_byte;
Xstatic	unsigned PK_input_byte;
Xstatic	int	PK_bitpos;
Xstatic	int	PK_dyn_f;
Xstatic	int	PK_repeat_count;
X
Xstatic	int
XPK_get_nyb( fp )
X     register struct font *fp;
X{
X  unsigned temp;
X  if( PK_bitpos < 0 )
X    {
X      PK_input_byte = one(fp->file);
X      PK_bitpos = 4;
X    }
X  temp = PK_input_byte >> PK_bitpos;
X  PK_bitpos -= 4;
X  return( temp & 0xf );
X}
X
X
Xstatic	int
XPK_packed_num( fp )
X     register struct font *fp;
X{
X  int i,j;
X  if( ( i = PK_get_nyb( fp ) ) == 0 )
X    {
X      do
X	{
X	  j = PK_get_nyb( fp );
X	  i++;
X	}
X      while( j == 0 );
X      while( i > 0 )
X	{
X	  j = (j << 4) + PK_get_nyb( fp );
X	  i--;
X	}
X      return( j - 15 + ( (13 - PK_dyn_f) << 4 ) + PK_dyn_f );
X    }
X  else
X    {
X      if( i <= PK_dyn_f ) return( i );
X      if( i < 14 ) return( ( (i - PK_dyn_f - 1) << 4 ) +
X			  PK_get_nyb( fp ) + PK_dyn_f + 1 );
X      if( i == 14 ) PK_repeat_count = PK_packed_num( fp );
X      else PK_repeat_count = 1;
X      return( PK_packed_num( fp ) );
X    }
X}
X
X
Xstatic	void
XPK_skip_specials( fp )
X     register struct font *fp;
X{
X  int i,j;
X  do
X    {
X      PK_flag_byte = one(fp->file);
X      if( PK_flag_byte >= PK_CMD_START )
X	{
X	  switch( PK_flag_byte )
X	    {
X	    case PK_X1 :
X	    case PK_X2 :
X	    case PK_X3 :
X	    case PK_X4 :
X	      {
X		i = 0;
X		for (j = PK_CMD_START; j <= PK_flag_byte; j++)
X		  i = (i*256) + one(fp->file);
X		while (i--) (void) one(fp->file);
X		break;
X	      }
X	    case PK_Y :
X	      (void) four(fp->file);
X	    case PK_POST :
X	    case PK_NOOP :
X	      break;
X	    default :
X	      oops("Unexpected %d in PK file %s\n", PK_flag_byte, fp->fontname);
X	      break;
X	    }
X	}
X    }
X  while( PK_flag_byte != PK_POST && PK_flag_byte >= PK_CMD_START );
X}
X
X/**
X **	Public routines
X **/
X
Xstatic	void
Xread_index(fontp)
Xregister struct font *fontp;
X{
X  int hppp, vppp;
X  /*
X   * Read the header of a packed pixel file.
X   */
X  fontp->read_char = read_char;
X  if (debug & DBG_PK)
X    Printf("Reading header for PK pixel file %s\n", fontp->filename);
X
X  if (one(fontp->file) != PK_PRE)
X    oops("File %s lacks preamble command\n", fontp->fontname);
X
X  if (one(fontp->file) != PK_ID)
X    oops("File %s has wrong PK id\n", fontp->fontname);
X
X  Fseek(fontp->file, (long) one(fontp->file), 1);	/* skip comment */
X
X  (void) four(fontp->file);		/* skip design size */
X  (void) four(fontp->file);		/* skip checksum */
X  hppp = sfour(fontp->file);
X  vppp = sfour(fontp->file);
X  if( debug && hppp != vppp )
X    oops("Warning: aspect ratio not 1:1 for font %s\n", fontp->fontname);
X  /*fontp->f_scale = (int)((((float) hppp * 72.27) / (float) 65536) + 0.5);*/
X
X  /*if (fontp->f_scale == 0) fontp->f_scale = 1000;*/
X	{
X	    register struct glyph *g;
X	    for (g = fontp->glyph; g < &fontp->glyph[MAXCHARS]; ++g) {
X		g->addr = 0;
X		g->bitmap.bits = NULL;
X		g->bitmap2.bits = NULL;
X	    }
X	}
X	/*
X	 * Read glyph directory (really a whole pass over the file).
X	 */
X	for (;;) {
X	    int bytes_left, flag_low_bits;
X	    unsigned int cc;
X
X	    PK_skip_specials(fontp);
X	    if (PK_flag_byte == PK_POST) break;
X	    flag_low_bits = PK_flag_byte & 0x7;
X	    if (flag_low_bits == 7) {
X		bytes_left = four(fontp->file);
X		cc = four(fontp->file);
X	    } else if (flag_low_bits > 3) {
X		bytes_left = ((flag_low_bits - 4) << 16) + two(fontp->file);
X		cc = one(fontp->file);
X	    } else {
X		bytes_left = (flag_low_bits << 8) + one(fontp->file);
X		cc = one(fontp->file);
X	    }
X	    if (cc >= MAXCHARS)
X		oops("Character code %d outside range, file %s\n", cc,
X			fontp->fontname);
X	    fontp->glyph[cc].addr = ftell(fontp->file);
X	    fontp->glyph[cc].x2 = PK_flag_byte;
X	    Fseek(fontp->file, (long) bytes_left, 1);
X	}
X}
X
Xstatic	void
Xread_char(fp, ch)
X    register struct font *fp;
X    ubyte ch;
X{
X	int	i, j;
X	ubyte	n;
X	int	row_bit_pos;
X	Boolean	paint_switch;
X	BMUNIT	*cp;
X	register struct glyph *g;
X	long	fpwidth;
X	BMUNIT	word;
X	int	word_weight, bytes_wide;
X	int	rows_left, h_bit, count;
X
X  g = &fp->glyph[ch];
X  PK_flag_byte = g->x2;
X  PK_dyn_f = PK_flag_byte >> 4;
X  paint_switch = ((PK_flag_byte & 8) != 0);
X  PK_flag_byte &= 0x7;
X  if (PK_flag_byte == 7) n = 4;
X  else if (PK_flag_byte > 3) n = 2;
X  else n = 1;
X
X  if(debug & DBG_PK)
X    Printf("loading pk char %d, char type %d ", ch, n);
X
X    /* now read rest of character preamble */
X
X    if (n != 4) fpwidth = snum(fp->file, 3);
X    else {
X	fpwidth = sfour(fp->file);
X	(void) four(fp->file);	/* horizontal escapement */
X    }
X    (void) num(fp->file, n);	/* vertical escapement */
X    {
X	unsigned long w, h;
X	w = num(fp->file, n);
X	h = num(fp->file, n);
X	if (w > 0x7fff || h > 0x7fff)
X	    oops("Too large character (%d) in file %s\n", ch, fp->fontname);
X	g->bitmap.w = w;
X	g->bitmap.h = h;
X    }
X    g->x = snum(fp->file, n);
X    g->y = snum(fp->file, n);
X
X    g->dvi_adv = ((double) fp->scale * fpwidth) / (1 << 20);
X
X    if (debug & DBG_PK) {
X	if (g->bitmap.w != 0)
X	    Printf(", size=%dx%d, dvi_adv=%d", g->bitmap.w, g->bitmap.h,
X		g->dvi_adv);
X	putchar('\n');
X    }
X
X    if (g->bitmap.w == 0) return;
X    alloc_bitmap(&g->bitmap, fp->fontname, ch);
X    cp = (BMUNIT *) g->bitmap.bits;
X/*
X * read character data into *cp
X */
X      bytes_wide = ROUNDUP(g->bitmap.w, BITS_PER_BMUNIT) * BYTES_PER_BMUNIT;
X      PK_bitpos = -1;
X      if( PK_dyn_f == 14 )	/* get raster by bits */
X	{
X          bzero(g->bitmap.bits, g->bitmap.h * bytes_wide);
X	  for (i = 0; i < g->bitmap.h; i++)  /* get all rows */
X	    {
X              cp = ADD(g->bitmap.bits, i * bytes_wide);
X#ifndef	MSBITFIRST
X              row_bit_pos = -1;
X#else	MSBITFIRST
X              row_bit_pos = BITS_PER_BMUNIT;
X#endif	MSBITFIRST
X	      for (j = 0; j < g->bitmap.w; j++)  /* get one row */
X		{
X                  if (--PK_bitpos < 0)
X                    {
X                      word = one(fp->file);
X                      PK_bitpos = 7;
X                    }
X#ifndef	MSBITFIRST
X                  if (++row_bit_pos >= BITS_PER_BMUNIT)
X#else	MSBITFIRST
X		  if (--row_bit_pos < 0)
X#endif	MSBITFIRST
X                    {
X                      cp++;
X#ifndef	MSBITFIRST
X                      row_bit_pos = 0;
X#else	MSBITFIRST
X                      row_bit_pos = BITS_PER_BMUNIT - 1;
X#endif	MSBITFIRST
X                    }
X                  if (word & (1 << PK_bitpos))
X                    *cp |= 1 << row_bit_pos;
X                }
X	    }
X	}
X      else
X	{
X	  /* get packed raster */
X	  rows_left = g->bitmap.h;
X	  h_bit = g->bitmap.w;
X	  PK_repeat_count = 0;
X	  word_weight = BITS_PER_BMUNIT;
X	  word = 0;
X	  while (rows_left > 0)
X	    {
X	      count = PK_packed_num( fp );
X	      while (count > 0)
X		{
X		  if (count < word_weight && count < h_bit)
X		    {
X#ifndef	MSBITFIRST
X		      if (paint_switch)
X			word |= bit_masks[count] <<
X			  (BITS_PER_BMUNIT - word_weight);
X#endif	MSBITFIRST
X		      h_bit -= count;
X		      word_weight -= count;
X#ifdef	MSBITFIRST
X		      if (paint_switch) word |= bit_masks[count] << word_weight;
X#endif	MSBITFIRST
X		      count = 0;
X		    }
X		  else
X		    if (count >= h_bit && h_bit <= word_weight)
X		      {
X			if (paint_switch)
X			  word |= bit_masks[h_bit] <<
X#ifndef	MSBITFIRST
X			    (BITS_PER_BMUNIT - word_weight);
X#else	MSBITFIRST
X			    (word_weight - h_bit);
X#endif	MSBITFIRST
X			*cp++ = word;
X			/* "output" row(s) */
X			for (i = PK_repeat_count * bytes_wide /
X			  BYTES_PER_BMUNIT; i > 0; --i)
X			  {
X			    *cp = *SUB(cp, bytes_wide);
X			    ++cp;
X			  }
X			rows_left -= PK_repeat_count + 1;
X			PK_repeat_count = 0;
X			word = 0;
X			word_weight = BITS_PER_BMUNIT;
X			count -= h_bit;
X			h_bit = g->bitmap.w;
X		      }
X		    else
X		      {
X			if (paint_switch)
X#ifndef	MSBITFIRST
X			  word |= bit_masks[word_weight] <<
X			    (BITS_PER_BMUNIT - word_weight);
X#else	MSBITFIRST
X			  word |= bit_masks[word_weight];
X#endif	MSBITFIRST
X			*cp++ = word;
X			word = 0;
X			count -= word_weight;
X			h_bit -= word_weight;
X			word_weight = BITS_PER_BMUNIT;
X		      }
X		}
X	      paint_switch = 1 - paint_switch;
X	    }
X	  if (cp != ((BMUNIT *) (g->bitmap.bits + bytes_wide * g->bitmap.h)))
X	    oops("Wrong number of bits stored:  char. %d, font %s\n", ch,
X		fp->fontname);
X	  if (rows_left != 0 || h_bit != g->bitmap.w)
X	    oops("Bad pk file (%s), too many bits\n", fp->fontname);
X	}
X}
END_OF_FILE
if test 8614 -ne `wc -c <'pk.c'`; then
    echo shar: \"'pk.c'\" unpacked with wrong size!
fi
# end of 'pk.c'
fi
if test -f 'pxl.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'pxl.c'\"
else
echo shar: Extracting \"'pxl.c'\" \(3474 characters\)
sed "s/^X//" >'pxl.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include "xdvi.h"
X
X/***
X ***	PXL font reading routines.
X ***	Public routines are read_index and read_char.
X ***/
X
X#ifndef	MSBITFIRST
X#include "table.h"
Xextern	unsigned char	reverse_byte[];
X#endif	MSBITFIRST
X
Xstatic	void	read_index(), read_char();
X
Xread_font_index_proc	read_PXL_index	= read_index;
X
Xstatic void
Xread_index (fontp)
X        register struct font *fontp;
X{
X	register struct glyph *g;
X        long font_dir_ptr;
X
X	if (debug & DBG_PK)
X	    Printf("Reading header for PXL file %s\n", fontp->filename);
X	fontp->read_char = read_char;
X	if (four(fontp->file) != 1001)
X	    oops("File %s has wrong PXL magic number.\n", fontp->filename);
X	/* seek to trailer info */
X	Fseek(fontp->file, (long) -5 * 4, 2);
X	(void) four(fontp->file);	/* checksum */
X	(void) four(fontp->file);	/* magnify */
X	(void) four(fontp->file);	/* design size */
X        font_dir_ptr = sfour(fontp->file) * 4;
X	(void) four(fontp->file);	/* pxl id word */
X	/* seek to font directory */
X	Fseek(fontp->file, font_dir_ptr, 0);
X	for (g = &fontp->glyph[0]; g < &fontp->glyph[MAXCHARS]; ++g) {
X		g->bitmap.w = two(fontp->file);
X		g->bitmap.h = two(fontp->file);
X		g->x = stwo(fontp->file);
X		g->y = stwo(fontp->file);
X		g->addr = four(fontp->file) * 4;
X		/*
X		**  The TFM-width word is kind of funny in the units
X		**  it is expressed in.  It works this way:
X		**
X		**  If a glyph has width 'w' in a font with design-size
X		**  'd' (both in same units), the TFM-width word is
X		**
X		**                t = (w/d) * 2^20
X		**
X		**  Therefore, in order to find the glyph width in
X		**  DVI units (1 / 2^16 points), we take the design-size
X		**  'd' (in DVI's), the magnification 'm' of the PXL file
X		**  and the TFM-width word 't' to the width (in DVI's)
X		**  as follows:
X		**
X		**                     dmt
X		**                w = -----
X		**                    2^20
X		**
X		**  But the magnification of the PXL file is just the
X		**  scaled size 's' over the design size, so the final
X		**  expression for the width is
X		**
X		**                     st
X		**                w = ----
X		**                    2^20
X		**
X		*/
X
X		g->dvi_adv =
X		    ((double) fontp->scale * four(fontp->file)) / (1 << 20);
X		if (debug & DBG_PK)
X		    Printf("size=%dx%d, dvi_adv=%d\n", g->bitmap.w, g->bitmap.h,
X			g->dvi_adv);
X	}
X}
X
Xstatic void
Xread_char(fontp, ch)
X	register struct font *fontp;
X	ubyte ch;
X{
X	register struct bitmap *bitmap;
X	register BMUNIT *ptr;
X	register int i, j;
X#ifndef	BMLONG
X	register int padding_length;
X#endif	BMLONG
X
X	bitmap = &fontp->glyph[ch].bitmap;
X		/* in file, bitmap rows are multiples of 32 bits wide */
X	alloc_bitmap(bitmap, fontp->fontname, ch);
X	ptr = (BMUNIT *) bitmap->bits;
X#ifndef	BMLONG
X	padding_length = 3 - (bitmap->bytes_wide + 3) % 4;
X#endif	BMLONG
X	for (i = bitmap->h; i > 0; --i) {
X	    for (j = bitmap->bytes_wide; j > 0; j -= BYTES_PER_BMUNIT) {
X#ifndef	MSBITFIRST
X		*ptr = reverse_byte[one(fontp->file)];
X#if	BYTES_PER_BMUNIT > 1
X		*ptr |= reverse_byte[one(fontp->file)] << 8;
X#endif
X#ifdef	BMLONG
X		*ptr |= reverse_byte[one(fontp->file)] << 16;
X		*ptr |= reverse_byte[one(fontp->file)] << 24;
X#endif	BMLONG
X#else	MSBITFIRST
X		*ptr = 0;
X#ifdef	BMLONG
X		*ptr |= one(fontp->file) << 24;
X		*ptr |= one(fontp->file) << 16;
X#endif	BMLONG
X#if	BYTES_PER_BMUNIT > 1
X		*ptr |= one(fontp->file) << 8;
X#endif
X		*ptr |= one(fontp->file);
X#endif	MSBITFIRST
X		++ptr;
X	    }
X#ifndef	BMLONG
X	    for (j = padding_length; j > 0; --j) (void) one(fontp->file);
X#endif	BMLONG
X	}
X}
END_OF_FILE
if test 3474 -ne `wc -c <'pxl.c'`; then
    echo shar: \"'pxl.c'\" unpacked with wrong size!
fi
# end of 'pxl.c'
fi
if test -f 'pxl_open.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'pxl_open.c'\"
else
echo shar: Extracting \"'pxl_open.c'\" \(3332 characters\)
sed "s/^X//" >'pxl_open.c' <<'END_OF_FILE'
X/*
X *	pxl_open.c(path, font, pxlmag, pkmag, name, read_font_index)
X *	Find and open gf, pk, or pxl files in the given path, having the given
X *	name and magnification.  It tries gf files first, followed by pk and pxl
X *	files..  The path variable should be of the form path1:path2:...:pathn,
X *	and each of the paths will be tried successively.  Strings in pathi of
X *	the form %f, %p, and %d will be replaced by the font name, "gf" or "pk"
X *	or "pxl", and the magnification, respectively.  If no %f appears in a
X *	path specifier, then the string "/%f.%d%p" is added on the end.  If
X *	the file is found, then a file pointer is returned, and *name is set to
X *	a string giving the file name.  If the file is not found, then NULL is
X *	returned.  This procedure also returns a pointer to the glyph-reading
X *	procedure associated with the file format.
X * 
X *	Often there are so many fonts that we need to manage the number of
X *	simultaneously open files.  In that case, the variable n_fonts_left
X *	gives the number of open files that are left, (initially MAXINT, set
X *	dynamically) and when it is necessary to close a file, these routines
X *	call close_a_file() which should free up a file descriptor.
X * 
X */
X
X#include <stdio.h>
X#include <string.h>
X#include <errno.h>
X
X#define	PATH_SEP	':'
X#define	DEFAULT_TAIL	"/%f.%d%p"
X
X#ifndef	__STDC__
X#define	OPEN_MODE	"r"
X#else	__STDC__
X#define	OPEN_MODE	"rb"
X#endif	__STDC__
X
Xextern	int	n_fonts_left;
X
X	/* the corresponding read_char procedures are handled in xdvi.h */
Xtypedef	void (*read_font_index_proc)();
X	/* struct font *fontp; */
X
Xread_font_index_proc read_GF_index, read_PK_index, read_PXL_index;
X
Xchar *malloc(), *index(), *sprintf();
X
X#define	Strcpy	(void) strcpy
X#define	Sprintf	(void) sprintf
X
Xstatic FILE *formatted_open(path, font, pxl, mag, name)
Xchar *path, *font, *pxl;
Xint mag;
Xchar **name;
X{
X	char	*p = path,
X		nm[128],
X		*n = nm,
X		c;
X	int	f_used = 0;
X	FILE	*f;
X
X	for (;;) {
X	    c = *p++;
X	    if (c==PATH_SEP || c=='\0') {
X		if (f_used) break;
X		p = DEFAULT_TAIL;
X		continue;
X	    }
X	    if (c=='%') {
X		c = *p++;
X		switch (c) {
X		    case 'f':
X			f_used=1;
X			Strcpy(n, font);
X			break;
X		    case 'p':
X			Strcpy(n, pxl);
X			break;
X		    case 'd':
X			Sprintf(n, "%d", mag);
X			break;
X		    default:
X			*n++ = c;
X			*n = '\0';
X		}
X		n += strlen(n);
X	    }
X	    else *n++ = c;
X	}
X	*n = '\0';
X	f = fopen(nm, OPEN_MODE);
X	if (f == NULL && errno == EMFILE) {
X	    n_fonts_left = 0;
X	    close_a_file();
X	    f = fopen(nm, OPEN_MODE);
X	}
X	if (f != NULL) {
X	    *name = malloc((unsigned) (n - nm));
X	    Strcpy(*name, nm);
X	}
X	return(f);
X}
X
XFILE *pxl_open(path, font, pxlmag, pkmag, name, read_font_index)
Xchar *path, *font;
Xint pxlmag, pkmag;
Xchar **name;
Xread_font_index_proc *read_font_index;
X{
X	char	*p = path;
X	FILE	*f;
X
X	for (;;) {
X	    if (read_GF_index &&
X		(f=formatted_open(p, font, "gf", pkmag, name)) != NULL) {
X		    *read_font_index = read_GF_index;
X		    return(f);
X	    }
X	    if (read_PK_index &&
X		(f=formatted_open(p, font, "pk", pkmag, name)) != NULL) {
X		    *read_font_index = read_PK_index;
X		    return(f);
X	    }
X	    if (read_PXL_index &&
X		(f=formatted_open(p, font, "pxl", pxlmag, name)) != NULL) {
X		    *read_font_index = read_PXL_index;
X		    return(f);
X	    }
X	    p = index(p, PATH_SEP);
X	    if (p == NULL) return(NULL);
X	    ++p;
X	}
X}
END_OF_FILE
if test 3332 -ne `wc -c <'pxl_open.c'`; then
    echo shar: \"'pxl_open.c'\" unpacked with wrong size!
fi
# end of 'pxl_open.c'
fi
if test -f 'xdvi.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xdvi.h'\"
else
echo shar: Extracting \"'xdvi.h'\" \(5355 characters\)
sed "s/^X//" >'xdvi.h' <<'END_OF_FILE'
X/*
X *	Written by Eric C. Cooper, CMU
X */
X/* $Header: xdvi.h,v 10.5 86/02/01 15:45:03 tony Rel $ */
X
X#include <X11/Xos.h>
X#include <setjmp.h>
X
X#define	OPEN_MODE	"r"
X
X#define	Printf	(void) printf
X#define	Fprintf	(void) fprintf
X#define	Sprintf	(void) sprintf
X#define	Fseek	(void) fseek
X#define	Fread	(void) fread
X#define	Fclose	(void) fclose
X
Xunsigned long num();
Xlong snum();
X
X#define one(fp)		((unsigned long) getc(fp) & 0xff)
X#define sone(fp)	((long) getc(fp))
X#define two(fp)		num (fp, 2)
X#define stwo(fp)	snum(fp, 2)
X#define four(fp)	num (fp, 4)
X#define sfour(fp)	snum(fp, 4)
X
Xtypedef	unsigned char ubyte;
X#define	Boolean	char
X#define	True	1
X#define	False	0
X
X#define	MAXINT		32767
X
X#define	pixel_conv(x)	((int) (((x) / shrink_factor) >> 16))
X#define	pixel_round(x)	((int) (((x) / shrink_factor + (1<<15)) >> 16))
X#define	spellfour(f)	((long) (sfour(f) * fraction))
X#define	spellnum(f,n)	((long) (snum(f,n) * fraction))
X#define	pxl2spell(x)	(((long) (x)) * shrink_factor << 16)
X
X#ifdef X10
X#undef	MSBITFIRST
X#undef	BMLONG
X#define	BMSHORT
X#endif X10
X
X#ifdef	BMLONG
X#define	BMUNIT			unsigned long
X#define	BITS_PER_BMUNIT		32
X#define	BYTES_PER_BMUNIT	4
X#else	BMLONG
X#ifdef	BMSHORT
X#define	BMUNIT			unsigned short
X#define	BITS_PER_BMUNIT		16
X#define	BYTES_PER_BMUNIT	2
X#else	BMSHORT
X#define	BMUNIT			unsigned char
X#define	BITS_PER_BMUNIT		8
X#define	BYTES_PER_BMUNIT	1
X#endif	BMSHORT
X#endif	BMLONG
X
X#define	ADD(a, b)	((BMUNIT *) (((char *) a) + b))
X#define	SUB(a, b)	((BMUNIT *) (((char *) a) - b))
X
Xextern	BMUNIT	bit_masks[BITS_PER_BMUNIT + 1];
X
Xstruct frame {
X	long dvi_h, dvi_v, w, x, y, z;
X	int pxl_v;
X};
X
Xextern	struct frame 	*stack;
Xextern	int	stackp;
X
X/* entries below with the characters 'dvi' in them are actually stored in
X   scaled pixel units */
X
X#define DVI_H   stack[stackp].dvi_h
X#define PXL_H   pixel_conv(stack[stackp].dvi_h)
X#define DVI_V   stack[stackp].dvi_v
X#define PXL_V   stack[stackp].pxl_v
X#define WW      stack[stackp].w
X#define XX      stack[stackp].x
X#define YY      stack[stackp].y
X#define ZZ      stack[stackp].z
X#define ROUNDUP(x,y) (((x)+(y)-1)/(y))
X
X#define	PAPER_WIDTH	ROUNDUP(17*pixels_per_inch, shrink_factor*2)
X#define	PAPER_HEIGHT	ROUNDUP(11*pixels_per_inch, shrink_factor)
X
Xextern	int	current_page;
Xextern	int	total_pages;
Xextern	double	fraction;
Xextern	int	maxstack;
Xextern	int	n_fonts_left;		/* for LRU management of fonts */
Xextern	time_t	dvi_time;		/* last mod. time for dvi file */
Xextern	char	*font_path;
Xextern	int	page_w, page_h;
X
X/*
X * Table of page offsets in DVI file, indexed by page number - 1.
X * Initialized in prepare_pages().
X */
Xextern	long	*page_offset;
X
X/*
X * Mechanism for reducing repeated warning about specials.
X */
Xextern	Boolean	spec_warn;
X
X
X/*
X * Bitmap structure for raster ops.
X */
Xstruct bitmap{
X	short w, h;		/* width and height in pixels */
X	short bytes_wide;	/* scan-line width in bytes */
X	char *bits;		/* pointer to the bits */
X};
X
X#define MAXCHARS 128		/* make 256 for 8 bit characters */
X
X/*
X * Per-character information.
X * There is one of these for each character in a font.
X * All fields are filled in at font definition time,
X * except for the bitmap, which is "faulted in"
X * when the character is first referenced.
X */
Xstruct glyph {
X	long addr;		/* address of bitmap in PXL file */
X	long dvi_adv;		/* DVI units to move reference point */
X	short x, y;		/* x and y offset in pixels */
X	struct bitmap bitmap;	/* bitmap for character */
X	short x2, y2;		/* x and y offset in pixels (shrunken bitmap) */
X	struct bitmap bitmap2;	/* shrunken bitmap for character */
X};
X
X/*
X * The layout of a font information block.
X * There is one of these for every loaded font or
X * magnification thereof.
X *
X * Also note the strange units.  The design size is in 1/2^20 point
X * units (also called micro-points), and the individual character widths
X * are in the TFM file in 1/2^20 ems units, i.e. relative to the design size.
X *
X * We then change the sizes to SPELL units (unshrunk pixel / 2^16).
X */
X
Xvoid	alloc_bitmap();
X
Xtypedef	void (*read_char_proc)();
X	/* struct font *fp; */
X	/* ubyte ch; */
X
X	/* the corresponding read_font_index procedures occur in pxl_open.c */
Xtypedef	void (*read_font_index_proc)();
X	/* struct font *fontp; */
X
Xstruct font {
X	struct font *next;		/* link to next font info block */
X	int TeXnumber;			/* font number (in DVI file) */
X	int scale;			/* scaled size in SPELL units */
X	char *fontname;			/* PXL file name */
X	short size;			/* dots per 5 inches */
X	FILE *file;			/* open PXL file or NULL */
X	char *filename;			/* name of PXL file */
X	read_char_proc read_char;	/* function to read bitmap */
X	struct glyph glyph[MAXCHARS];
X};
X
Xextern	struct font	*current_font;
X
X/*
X * Command line flags.
X */
X
Xextern	int	debug;
X
X#define DBG_BITMAP	0x1
X#define DBG_DVI		0x2
X#define DBG_PK          0x4
X#define DBG_BATCH       0x8
X#define	DBG_EVENT	0x10
X#define DBG_ALL		(DBG_BITMAP|DBG_DVI|DBG_PK|DBG_EVENT)
X
Xextern	Boolean	list_fonts;
X
Xextern	int	pixels_per_inch;
Xextern	int	density;
X
Xextern	char	*dvi_name;
Xextern	FILE	*dvi_file;				/* user's file */
Xextern	char	*prog;
X
Xextern	struct	WindowRec {
X	long	win;		/* type Window is not defined yet */
X	int	shrinkfactor;
X	int	base_x, base_y;
X	int	min_x, max_x, min_y, max_y;	/* for pending expose events */
X} mane, alt, curr;
X
X#define	shrink_factor	curr.shrinkfactor
X
Xjmp_buf	dvi_env;		/* mechanism to communicate dvi file errors */
END_OF_FILE
if test 5355 -ne `wc -c <'xdvi.h'`; then
    echo shar: \"'xdvi.h'\" unpacked with wrong size!
fi
# end of 'xdvi.h'
fi
if test -f 'xdvi10.man.s' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xdvi10.man.s'\"
else
echo shar: Extracting \"'xdvi10.man.s'\" \(8408 characters\)
sed "s/^X//" >'xdvi10.man.s' <<'END_OF_FILE'
X.TH XDVI SIPB "17 January 1989" "X Version 10"
X.SH NAME
Xxdvi \- DVI Previewer for the X Window System
X.SH SYNOPSIS
X.B xdvi
X[+[\fIpage\fP]] [\-s \fIshrink\fP] [\-S \fIdensity\fP] [\-p \fIpixels\fP]
X[\-l] [\-rv] [\-fg \fIcolor\fP] [\-bg \fIcolor\fP] [\-hl \fIcolor\fP]
X[\-bd \fIcolor\fP] [\-cr \fIcolor\fP] [\-margins \fIinches\fP]
X[\-sidemargin \fIinches\fP] [\-topmargin \fIinches\fP]
X[\-mgs[\fIn\fP] \fIsize\fP] [\-geometry \fIgeometry\fP | =\fIgeometry\fP]
X[\-display \fIdisplay\fP | \fIhost\fP:\fIdisplay\fP] file
X.SH DESCRIPTION
X.I Xdvi
Xis a program which runs under the X window system. It is used to preview
XDVI files, such as are produced by TeX.
X.PP
XThis program has the capability of
Xshowing the file shrunken by various (integer) factors, and also has a
X``magnifying glass'' which allows one to see a small part of the unshrunk
Ximage momentarily.
X.PP
XAlso, before displaying any page or part thereof, it checks to see if the dvi
Xfile has changed since the last time it was displayed.  If this is the case,
Xthen \fIxdvi\fR will reinitialize itself for the new dvi file.  For this reason,
Xexposing parts of the \fIxdvi\fR window while \fITeX\fR is running should be
Xavoided.  This feature allows you to preview many versions
Xof the same file while running \fIxdvi\fR only once.
X.SH OPTIONS
XIn addition to specifying the .\fPdvi\fR file (with or without the .\fPdvi\fR),
X\fIXdvi\fR supports the following command line options.
XIf the option begins with a
X.RB ` + '
Xinstead of a
X.RB ` \- ',
Xthe option is restored to its default value.  These options override those
Xset in the ``.Xdefaults'' file (via the resource names given in parentheses
Xin the description of each option).
X.TP
X.IB + page
XSpecifies the first page to show.  If \fI+\fR is given without a
Xnumber, the last page is assumed; the first page is the default.
X.TP
X.BI \-s " shrink"
X(shrinkFactor)
XDefines the initial shrink factor.  The default value is 4.
X.TP
X.BI \-S " density"
X(densityPercent)
XDetermines the density used when shrinking bitmaps for fonts.
XA higher value produces a lighter font.  The default value is 40.
X.TP
X.BI \-p " pixels"
X(pixelsPerInch)
XDefines the size of the fonts to use, in pixels per inch.  The
Xdefault value is 300.
X.TP
X.B \-l
X(listFonts)
XCauses the names of the fonts used to be listed.
X.TP
X.B \-rv
X(reverseVideo)
XCauses the page to be displayed with white characters on a
Xblack background, instead of vice versa.
X.TP
X.BI \-bw " width"
X(borderWidth)
XSpecifies the width of the border of the window.
X.TP
X.BI \-borderwidth " width"
XSame as \fB-bw\fR, above.
X.TP
X.BI \-fg " color"
X(foreground)
XDetermines the color of the text (foreground).
X.TP
X.BI \-foreground " color"
XSame as \fB-fg\fR, above.
X.TP
X.BI \-bg " color"
X(background)
XDetermines the color of the background.
X.TP
X.BI \-background " color"
XSame as \fB-bg\fR, above.
X.TP
X.BI \-hl " color"
X(highlight)
XDetermines the color of the page border.
X.TP
X.BI \-bd " color"
X(borderColor)
XDetermines the color of the window border.
X.TP
X.BI \-cr " color"
X(cursorColor)
XDetermines the color of the cursor.  The default is the
Xforeground color.
X.TP
X.BI \-margins " inches"
X(margins)
XSpecifies the size of both the top margin and side margin.  This
Xcan be a decimal number, \fIe.g.\fR, 1.5.  It determines
Xthe ``home'' position of the page within the window as follows.  If the entire
Xpage fits in the window, then the margin settings are ignored.  If, even
Xafter removing the margins from the left, right, top, and bottom, the page
Xstill cannot fit in the window, then the page is put in the window such that
Xthe top and left margins are hidden, and presumably the upper left-hand corner
Xof the text on the page will be in the upper left-hand corner of the window.
XOtherwise, the text is centered in the window.  See also `\fBH\fR' under
Xthe KEY\%STROKES section.
X.TP
X.BI \-sidemargin " inches"
X(sideMargin)
XSpecifies the side margin (see above).
X.TP
X.BI \-topmargin " inches"
X(topMargin)
XSpecifies the top and bottom margins (see above).
X.TP
X.BI \-mgs " size"
X(magnifierSize1)
XSpecifies the size of the window to be used for the
X``magnifying glass'' for the left button.  See the MOUSE ACTIONS section.
XDefault is 200.
X.TP
X.BI \-mgs1 " size"
XSame as \fB-mgs\fR, above.
X.TP
X.BI \-mgs2 " size"
X(magnifierSize2)
XSpecifies the ``magnifying glass'' size for the middle
Xbutton.  Default is 350.
X.TP
X.BI \-mgs3 " size"
X(magnifierSize3)
XSpecifies the ``magnifying glass'' size for the right
Xbutton.  Default is 600.
X.TP
X.BI = geometry
X(geometry)
XSpecifies the initial geometry of the window.
X.TP
X.BI \-geometry " geometry"
XSame as above.
X.TP
X.BI \-display " host:display"
XSpecifies the host and screen to be used for displaying the dvi file.
XThis is normally obtained from the environment variable ``DISPLAY.''
X.SH KEYSTROKES
X\fBXdvi\fR recognizes the following keystrokes when typed in its window.
XEach may optionally be preceded by a (positive or negative) number, whose
Xinterpretation will depend on the particular keystroke.
X.TP
X.B q
XQuits the program.  Control-C and control-D will do this, too.
X.TP
X.B n
XMoves to the next page (or to the \fBn\fRth next page if a number is given).
XSynonyms are `\fBf\fR', Space, Return, and Line Feed.
X.TP
X.B p
XMoves to the previous page (or back \fBn\fR pages).  Synonyms are
X`\fBb\fR', control-H, and Delete.
X.TP
X.B g
XMoves to the page with the given number.  Initially, the first page is assumed
Xto be page number 1, but this can be changed with the `\fBP\fR' keystroke,
Xbelow.  If no page number is given, then it goes to the last page.
X.TP
X.B P
X``This is page number \fBn\fR.''  This can be used to make the `\fBg\fR'
Xkeystroke refer to actual page numbers instead of absolute page numbers.
X.TP
X.B Control-L
XRedisplays the current page.
X.TP
X.B ^
XMove to the ``home'' position of the page.  This is normally the upper
Xleft-hand corner of the page, depending on the margins as described in
Xthe \-margins option, above.
X.TP
X.B u
XMoves up a window-full.
X.TP
X.B d
XMoves down a window-full.
X.TP
X.B l
XMoves left a window-full.
X.TP
X.B r
XMoves right a window-full.
X.TP
X.B c
XMoves the page so that the point currently beneath the cursor is moved to
Xthe middle of the window.  It also (gasp!) warps the cursor to the same place.
X.TP
X.B M
XSets the margins so that the point currently under the cursor is the upper
Xleft-hand corner of the text in the page.
X.TP
X.B s
XChanges the shrink factor to the given number.  If no number is given, the
Xsmallest factor that makes the entire page fit in the window will be used.
X(Margins are ignored in this computation.)
X.TP
X.B S
XSets the density factor to be used when shrinking bitmaps.  This should
Xbe a number between 0 and 100; higher numbers produce lighter characters.
X.TP
X.B R
XForces the dvi file to be reread.  This allows you to preview many versions
Xof the same file while running \fIxdvi\fR only once.
X.SH MOUSE ACTIONS
XIf the shrink factor is set to any number other than one, then clicking
Xany mouse button will pop up a ``magnifying glass'' which shows the unshrunk
Ximage in the vicinity of the mouse click.  This subwindow disappears when
Xthe mouse button is released.  Different mouse buttons produce different sized
Xwindows, as indicated by the \fB\-mgs\fR option, above.
X.SH ENVIRONMENT
XUses the environment variable ``DISPLAY'' to specify which bit map display
Xterminal to use.
X.PP
XThe environment variable ``%%FONT_PATH%%'' determines the path(s) searched for
Xfonts in the following manner.  The string consists of one or more strings
Xseparated by colons.  In each such string, the substring ``%f'' is
Xchanged to the font name; ``%d'' is changed to the magnification; and
X``%p'' is changed to the font family (``gf'', ``pk'', or ``pxl'').  If no
X``%f'' appears in the string, then the string ``/%f.%d%p'' is added on
Xthe end.  For example, if the string is ``/usr/local/tex/fonts'' and the font is
Xcmr10 at 300dpi, then it searches for /usr/local/tex/fonts/cmr10.300gf,
X/usr/local/tex/fonts/cmr10.300pk, and /usr/local/tex/fonts/cmr10.1500pxl,
Xin that order.  If the first character of the ``%%FONT_PATH%%'' variable
Xis a colon, then the system default paths are tried first.
X.SH FILES
X.br
X%%DEFAULT_FONT_PATH%%   Font pixel files.
X.SH "SEE ALSO"
XX(1).
X.SH AUTHORS
XEric Cooper, CMU, did a version for direct output to a QVSS.
XModified for X by
XBob Scheifler, MIT Laboratory for Computer Science.
XModified for X11 by Mark Eichin, MIT SIPB.
XAdditional enhancements by many others.
END_OF_FILE
if test 8408 -ne `wc -c <'xdvi10.man.s'`; then
    echo shar: \"'xdvi10.man.s'\" unpacked with wrong size!
fi
# end of 'xdvi10.man.s'
fi
echo shar: End of archive 3 \(of 3\).
cp /dev/null ark3isdone
MISSING=""
for I in 1 2 3 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 3 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Mike Wexler(wyse!mikew)    Phone: (408)433-1000 x1330
Moderator of comp.sources.x



More information about the Comp.sources.x mailing list