[comp.sources.x] v10i009: xdvi, Patch10, Part01/02

vojta@math.Berkeley.EDU (Paul Vojta) (10/19/90)

Submitted-by: vojta@math.Berkeley.EDU (Paul Vojta)
Posting-number: Volume 10, Issue 9
Archive-name: xdvi/patch10.01
Patch-To: xdvi: Volume 3, Issues 37-39
Patch-To: xdvi: Volume 4, Issue 44 (xdvi, Patch4)
Patch-To: xdvi: Volume 4, Issue 96 (xdvi, dvi previewer, Patch5)
Patch-To: xdvi: Volume 5, Issue 35 (xdvi, dvi previewer, patch 6, part 1/2)
Patch-To: xdvi: Volume 5, Issue 36 (xdvi, dvi previewer, patch 6, part 2/2)
Patch-To: xdvi: Volume 6, Issue  5 (xdvi, Patch7)
Patch-To: xdvi: Volume 6, Issue 49 (xdvi, dvi previewer, patch 8)
Patch-To: xdvi: Volume 7, Issue 52 (xdvi, dvi previewer, patch 9, part 1/2)
Patch-To: xdvi: Volume 7, Issue 53 (xdvi, dvi previewer, patch 9, part 2/2)

This is patch 10 for xdvi.  In addition to the usual bug fixes, it implements:
  1.  Uses the cursor keys as synonyms for 'u', 'd', etc.
  2.  Expert mode (-DBUTTONS only):  hides the buttons.
  3.  +sw option to inhibit warning about specials being ignored.
  4.  -xoffset and -yoffset options to override the 1 inch default margins
  5.  Improvements in font searching:  search for the actual size first,
      and use the magic number in the font file to determine the format.

-- cut here --
diff -cr xdvi_old/Imakefile xdvi_new/Imakefile
*** xdvi_old/Imakefile	Mon Sep 17 17:34:43 1990
--- xdvi_new/Imakefile	Wed Oct 10 13:20:15 1990
***************
*** 1,9 ****
  DEFAULT_FONT_PATH=/usr/local/tex/fonts
  DEFAULT_FONT_SIZES=300:328.6:360:432:518.4:622:746.4
! DEFINES=-DMSBITFIRST \
!   -DBMSHORT
! FONTDEFINES=-DDEFAULT_FONT_PATH=\"$(DEFAULT_FONT_PATH)\" \
!   -DDEFAULT_FONT_SIZES=\"$(DEFAULT_FONT_SIZES)\"
  FONTFORMATS_C=gf.c pk.c pxl.c
  FONTFORMATS_O=gf.o pk.o pxl.o
  
--- 1,6 ----
  DEFAULT_FONT_PATH=/usr/local/tex/fonts
  DEFAULT_FONT_SIZES=300:328.6:360:432:518.4:622:746.4
! DEFS=-DMSBITFIRST -DBMSHORT -DBUTTONS
  FONTFORMATS_C=gf.c pk.c pxl.c
  FONTFORMATS_O=gf.o pk.o pxl.o
  
***************
*** 11,32 ****
  LOCAL_LIBRARIES=XawClientLibs
  MATHLIB=-lm
  SYS_LIBRARIES=$(MATHLIB)
  SRCS=xdvi.c dvi_init.c dvi_draw.c $(FONTFORMATS_C) pxl_open.c tpic.c
  OBJS=xdvi.o dvi_init.o dvi_draw.o $(FONTFORMATS_O) pxl_open.o tpic.o
  
  ComplexProgramTarget(xdvi)
  
- pxl_open.o:
- 	$(CC) -c $(CFLAGS) $(FONTDEFINES) pxl_open.c
- 
  xdvi.man: xdvi_man.sed
  	chmod u+x mksedscript
! 	mksedscript $(DEFAULT_FONT_PATH) $(DEFAULT_FONT_SIZES) $(DEFINES) \
  		> sedscript
  	sed -f sedscript < xdvi_man.sed > xdvi.man
  
  clean::
! 	$(RM) sedscript xdvi.man xdvi10.man.s
! 
! lint::
! 	$(LINT) $(INCLUDES) $(DEFINES) $(FONTDEFINES) $(SRCS)
--- 8,26 ----
  LOCAL_LIBRARIES=XawClientLibs
  MATHLIB=-lm
  SYS_LIBRARIES=$(MATHLIB)
+ LINTLIBS=$(LINTXAW) $(LINTXMU) $(LINTXTOOL) $(LINTEXTENSIONLIB) $(LINTXLIB) -lm
  SRCS=xdvi.c dvi_init.c dvi_draw.c $(FONTFORMATS_C) pxl_open.c tpic.c
  OBJS=xdvi.o dvi_init.o dvi_draw.o $(FONTFORMATS_O) pxl_open.o tpic.o
+ DEFINES=$(DEFS) -DDEFAULT_FONT_PATH=\"$(DEFAULT_FONT_PATH)\" \
+   -DDEFAULT_FONT_SIZES=\"$(DEFAULT_FONT_SIZES)\"
  
  ComplexProgramTarget(xdvi)
  
  xdvi.man: xdvi_man.sed
  	chmod u+x mksedscript
! 	./mksedscript $(DEFAULT_FONT_PATH) $(DEFAULT_FONT_SIZES) $(DEFS) \
  		> sedscript
  	sed -f sedscript < xdvi_man.sed > xdvi.man
  
  clean::
! 	$(RM) sedscript xdvi.man
diff -cr xdvi_old/MAKE_VMS.COM xdvi_new/MAKE_VMS.COM
*** xdvi_old/MAKE_VMS.COM	Mon Sep 17 17:34:45 1990
--- xdvi_new/MAKE_VMS.COM	Sun Aug 12 14:29:23 1990
***************
*** 6,12 ****
  $ CC /DEFINE = (BMLONG, NOTOOL) PK
  $ CC /DEFINE = (BMLONG, NOTOOL) PXL
  $ CC /DEFINE = (BMLONG, NOTOOL, -
!      "DEFAULT_FONT_PATH=""TEX$FONTS""", -
       "DEFAULT_FONT_SIZES=""300/328.6/360/432/518.4/622/746.4""") PXL_OPEN
  $ CC /DEFINE = (BMLONG, NOTOOL) TPIC
  $ CC /DEFINE = (BMLONG, NOTOOL) XDVI
--- 6,12 ----
  $ CC /DEFINE = (BMLONG, NOTOOL) PK
  $ CC /DEFINE = (BMLONG, NOTOOL) PXL
  $ CC /DEFINE = (BMLONG, NOTOOL, -
!      "DEFAULT_FONT_PATH=""TEX_FONTS""", -
       "DEFAULT_FONT_SIZES=""300/328.6/360/432/518.4/622/746.4""") PXL_OPEN
  $ CC /DEFINE = (BMLONG, NOTOOL) TPIC
  $ CC /DEFINE = (BMLONG, NOTOOL) XDVI
diff -cr xdvi_old/Makefile xdvi_new/Makefile
*** xdvi_old/Makefile	Mon Sep 17 17:34:48 1990
--- xdvi_new/Makefile	Wed Oct 10 13:42:41 1990
***************
*** 6,13 ****
  #
  DEFAULT_FONT_PATH=/usr/local/tex/fonts
  DEFAULT_FONT_SIZES=300:328.6:360:432:518.4:622:746.4
! DEFINES=-DMSBITFIRST \
!   -DBMSHORT -DBUTTONS
  FONTDEFINES=-DDEFAULT_FONT_PATH=\"$(DEFAULT_FONT_PATH)\" \
    -DDEFAULT_FONT_SIZES=\"$(DEFAULT_FONT_SIZES)\"
  FONTFORMATS_C=gf.c pk.c pxl.c
--- 6,12 ----
  #
  DEFAULT_FONT_PATH=/usr/local/tex/fonts
  DEFAULT_FONT_SIZES=300:328.6:360:432:518.4:622:746.4
! DEFS=-DMSBITFIRST -DBMSHORT -DBUTTONS
  FONTDEFINES=-DDEFAULT_FONT_PATH=\"$(DEFAULT_FONT_PATH)\" \
    -DDEFAULT_FONT_SIZES=\"$(DEFAULT_FONT_SIZES)\"
  FONTFORMATS_C=gf.c pk.c pxl.c
***************
*** 14,29 ****
  FONTFORMATS_O=gf.o pk.o pxl.o
  LIBDIR=/usr/custom/x11/lib
  #LIBDIR=/tuna_a/x11r4/lib
! INCDIR=/usr/include
  #INCDIR=/tuna_a/x11r4/include
! XMULIB=
! #XMULIB=-lXmu
  EXTENSIONLIB=-lXext
  DESTDIR=/usr/local/x11
  BINDIR=$(DESTDIR)/bin
  MANDIR=$(DESTDIR)/man
  INCLUDES=-I$(INCDIR)
! CFLAGS=-O $(INCLUDES) $(DEFINES)
  LIBS=-L$(LIBDIR) -lXaw $(XMULIB) -lXt $(EXTENSIONLIB) -lX11 -lm
  SRCS=xdvi.c dvi_init.c dvi_draw.c $(FONTFORMATS_C) pxl_open.c tpic.c
  OBJS=xdvi.o dvi_init.o dvi_draw.o $(FONTFORMATS_O) pxl_open.o tpic.o
--- 13,27 ----
  FONTFORMATS_O=gf.o pk.o pxl.o
  LIBDIR=/usr/custom/x11/lib
  #LIBDIR=/tuna_a/x11r4/lib
! INCDIR=
  #INCDIR=/tuna_a/x11r4/include
! XMULIB=-lXmu
  EXTENSIONLIB=-lXext
  DESTDIR=/usr/local/x11
  BINDIR=$(DESTDIR)/bin
  MANDIR=$(DESTDIR)/man
  INCLUDES=-I$(INCDIR)
! CFLAGS=-O $(INCLUDES) $(DEFS)
  LIBS=-L$(LIBDIR) -lXaw $(XMULIB) -lXt $(EXTENSIONLIB) -lX11 -lm
  SRCS=xdvi.c dvi_init.c dvi_draw.c $(FONTFORMATS_C) pxl_open.c tpic.c
  OBJS=xdvi.o dvi_init.o dvi_draw.o $(FONTFORMATS_O) pxl_open.o tpic.o
***************
*** 46,57 ****
  pk.o:	xdvi.h
  pxl.o:	xdvi.h
  
! pxl_open.o:
  	$(CC) -c $(CFLAGS) $(FONTDEFINES) pxl_open.c
  
  xdvi.man: xdvi_man.sed
  	chmod u+x mksedscript
! 	mksedscript $(DEFAULT_FONT_PATH) $(DEFAULT_FONT_SIZES) $(DEFINES) \
  		> sedscript
  	sed -f sedscript < xdvi_man.sed > xdvi.man
  
--- 44,55 ----
  pk.o:	xdvi.h
  pxl.o:	xdvi.h
  
! pxl_open.o:	xdvi.h
  	$(CC) -c $(CFLAGS) $(FONTDEFINES) pxl_open.c
  
  xdvi.man: xdvi_man.sed
  	chmod u+x mksedscript
! 	./mksedscript $(DEFAULT_FONT_PATH) $(DEFAULT_FONT_SIZES) $(DEFS) \
  		> sedscript
  	sed -f sedscript < xdvi_man.sed > xdvi.man
  
***************
*** 61,67 ****
  
  clean:
  	$(RM) *.o *.BAK *.CKP sedscript xdvi.man xdvi a.out core errs *~
- 	$(RM) xdvi10.man.s
  
  lint:
! 	lint $(INCLUDES) $(DEFINES) $(FONTDEFINES) $(SRCS)
--- 59,64 ----
  
  clean:
  	$(RM) *.o *.BAK *.CKP sedscript xdvi.man xdvi a.out core errs *~
  
  lint:
! 	lint $(INCLUDES) $(DEFS) $(FONTDEFINES) $(SRCS) -lm
diff -cr xdvi_old/Makefile_10 xdvi_new/Makefile_10
*** xdvi_old/Makefile_10	Mon Sep 17 17:34:50 1990
--- xdvi_new/Makefile_10	Thu Oct 11 15:31:59 1990
***************
*** 6,12 ****
  #
  DEFAULT_FONT_PATH=/usr/local/tex/fonts
  DEFAULT_FONT_SIZES=300:328.6:360:432:518.4:622:746.4
! DEFINES=-DX10
  FONTDEFINES=-DDEFAULT_FONT_PATH=\"$(DEFAULT_FONT_PATH)\" \
    -DDEFAULT_FONT_SIZES=\"$(DEFAULT_FONT_SIZES)\"
  FONTFORMATS_C=gf.c pk.c pxl.c
--- 6,12 ----
  #
  DEFAULT_FONT_PATH=/usr/local/tex/fonts
  DEFAULT_FONT_SIZES=300:328.6:360:432:518.4:622:746.4
! DEFS=-DX10
  FONTDEFINES=-DDEFAULT_FONT_PATH=\"$(DEFAULT_FONT_PATH)\" \
    -DDEFAULT_FONT_SIZES=\"$(DEFAULT_FONT_SIZES)\"
  FONTFORMATS_C=gf.c pk.c pxl.c
***************
*** 15,22 ****
  BINDIR=$(DESTDIR)/bin
  MANDIR=$(DESTDIR)/man
  #INCLUDES=-I/usr/include/X
! CFLAGS=-O $(INCLUDES) $(DEFINES)
! LIBS=-lX -lm
  SRCS=xdvi.c dvi_init.c dvi_draw.c $(FONTFORMATS_C) pxl_open.c tpic.c
  OBJS=xdvi.o dvi_init.o dvi_draw.o $(FONTFORMATS_O) pxl_open.o tpic.o
  CC=/tuna_a/gnu/bin/gcc
--- 15,22 ----
  BINDIR=$(DESTDIR)/bin
  MANDIR=$(DESTDIR)/man
  #INCLUDES=-I/usr/include/X
! CFLAGS=-O $(INCLUDES) $(DEFS)
! LIBS=-L/products/ccs/X10/lib -lX -lm
  SRCS=xdvi.c dvi_init.c dvi_draw.c $(FONTFORMATS_C) pxl_open.c tpic.c
  OBJS=xdvi.o dvi_init.o dvi_draw.o $(FONTFORMATS_O) pxl_open.o tpic.o
  CC=/tuna_a/gnu/bin/gcc
***************
*** 38,49 ****
  pk.o:	xdvi.h
  pxl.o:	xdvi.h
  
! pxl_open.o:
  	$(CC) -c $(CFLAGS) $(FONTDEFINES) pxl_open.c
  
  xdvi.man: xdvi_man.sed
  	chmod u+x mksedscript
! 	mksedscript $(DEFAULT_FONT_PATH) $(DEFAULT_FONT_SIZES) $(DEFINES) \
  		> sedscript
  	sed -f sedscript < xdvi_man.sed > xdvi.man
  
--- 38,49 ----
  pk.o:	xdvi.h
  pxl.o:	xdvi.h
  
! pxl_open.o:	xdvi.h
  	$(CC) -c $(CFLAGS) $(FONTDEFINES) pxl_open.c
  
  xdvi.man: xdvi_man.sed
  	chmod u+x mksedscript
! 	./mksedscript $(DEFAULT_FONT_PATH) $(DEFAULT_FONT_SIZES) $(DEFS) \
  		> sedscript
  	sed -f sedscript < xdvi_man.sed > xdvi.man
  
***************
*** 53,59 ****
  
  clean:
  	$(RM) *.o *.BAK *.CKP sedscript xdvi.man xdvi a.out core errs *~
- 	$(RM) xdvi10.man.s
  
  lint:
! 	lint $(INCLUDES) $(DEFINES) $(FONTDEFINES) $(SRCS)
--- 53,58 ----
  
  clean:
  	$(RM) *.o *.BAK *.CKP sedscript xdvi.man xdvi a.out core errs *~
  
  lint:
! 	lint $(INCLUDES) $(DEFS) $(FONTDEFINES) $(SRCS) -lm
diff -cr xdvi_old/README xdvi_new/README
*** xdvi_old/README	Mon Sep 17 17:34:54 1990
--- xdvi_new/README	Wed Oct 10 13:34:24 1990
***************
*** 1,7 ****
  INSTALLATION INSTRUCTIONS
  
  To install, do the following:
!     1.	Read the ENVIRONMENTS section of xdvi.man.sed to determine the correct
  	default values for the XDVIFONTS and XDVISIZES environment variables.
  	Edit the Imakefile or Makefile and change the values of the make
  	variables DEFAULT_FONT_PATH and DEFAULT_FONT_SIZES to these values.
--- 1,7 ----
  INSTALLATION INSTRUCTIONS
  
  To install, do the following:
!     1.	Read the ENVIRONMENT section of xdvi_man.sed to determine the correct
  	default values for the XDVIFONTS and XDVISIZES environment variables.
  	Edit the Imakefile or Makefile and change the values of the make
  	variables DEFAULT_FONT_PATH and DEFAULT_FONT_SIZES to these values.
***************
*** 28,41 ****
  	to reflect which font formats are actually used at your site.
  
  Other compilation flags are:
! 	FONT_PATH	(xdvi.c)  Name of the environment variable to use when
! 			searching for the font path
! 	DEFAULT_FONT_PATH  (xdvi.c)  Name of the default font path to use when
! 			the above environment variable is not set.  See the
! 			ENVIRONMENT section of the man page for details on
! 			how to get xdvi to recognize the directory structure
! 			you use for storing fonts.
! 	SYSV		(dvi_init pxl_open xdvi.c)  Set for System V
  			compilation.
  	VMS		Set for VMS compilation.
  	MSBITFIRST	(X11 only; xdvi.c dvi_draw.c gf.c pk.c pxl.c)  Store
--- 28,34 ----
  	to reflect which font formats are actually used at your site.
  
  Other compilation flags are:
! 	SYSV		(dvi_init.c pxl_open.c xdvi.c)  Set for System V
  			compilation.
  	VMS		Set for VMS compilation.
  	MSBITFIRST	(X11 only; xdvi.c dvi_draw.c gf.c pk.c pxl.c)  Store
***************
*** 63,70 ****
  			window for commonly used commands.
  	A4		(xdvi.c)  Use European size paper by default.
  
! All flags should be set in the appropriate Makefile via the variable
! ``DEFINES''.
  
  ================================================================
  
--- 56,62 ----
  			window for commonly used commands.
  	A4		(xdvi.c)  Use European size paper by default.
  
! All flags should be set in the appropriate Makefile via the variable ``DEFS''.
  
  ================================================================
  
***************
*** 180,184 ****
--- 172,179 ----
  --  Patchlevel 9:  --
     23.	Removed obsolete '#' and '=' options from the X11 version:  they
  	interfere with emacs.
+ --  Patchlevel 10: --
+    24.	Implemented arrow keys, expert mode, searching for the font's actual
+ 	size first, the -[xy]offset and -sw options, and numerous bug fixes.
  
  Paul Vojta, vojta@math.berkeley.edu
diff -cr xdvi_old/README.VMS xdvi_new/README.VMS
*** xdvi_old/README.VMS	Mon Sep 17 17:35:05 1990
--- xdvi_new/README.VMS	Mon Oct 15 12:41:40 1990
***************
*** 6,14 ****
  SYNOPSIS
  --------
  
!    XDVI [+[page]] [-s shrink] [-density density] [-p pixels] [-l] [-rv]
          [-bw width] [-fg color] [-bg color] [-hl color] [-bd color] [-cr color]
!         [-margins inches] [-sidemargin inches] [-topmargin inches]
          [-paper papertype] [-mgs[n] size] [-altfont font] [-thorough] [-copy]
          [-geometry geometry] [-icongeometry geometry] [-iconic]
          [-display display] dvi_file
--- 6,15 ----
  SYNOPSIS
  --------
  
!    XDVI [+[page]] [-s shrink] [-density density] [-p pixels] [-l] [-rv] [-sw]
          [-bw width] [-fg color] [-bg color] [-hl color] [-bd color] [-cr color]
!         [-margins dimen] [-sidemargin dimen] [-topmargin dimen]
!         [-offsets dimen] [-xoffset dimen] [-yoffset dimen]
          [-paper papertype] [-mgs[n] size] [-altfont font] [-thorough] [-copy]
          [-geometry geometry] [-icongeometry geometry] [-iconic]
          [-display display] dvi_file
***************
*** 60,65 ****
--- 61,70 ----
                           white characters on a black background, instead of vice
                           versa.
  
+    -sw                   (.specialWarn)  Causes XDVI to warn the user when it
+                          encounters a \special string which it cannot process.
+                          This option is on by default; to turn it off, use +sw.
+ 
     -bw <width>           (.borderWidth)  Specifies the width of the border of
                           the window.
  
***************
*** 85,109 ****
     -cr <color>           (.cursorColor)  Determines the color of the cursor.
                           The default is the color of the page border.
  
!    -margins <inches>     (.margins)  Specifies the size of both the top and side
!                          margins.  This can be a decimal number, e.g., 1.5.
!                          XDVI determines the "home" position of the page within
!                          the window as follows.  If the entire page fits in the
!                          window, then the margin settings are ignored.  If, even
!                          after removing the margins from the left, right, top,
!                          and bottom, the page still cannot fit in the window,
!                          then the page is put in the window such that the top
!                          and left margins are hidden, and presumably the upper
                           left-hand corner of the text on the page will be in the
                           upper left-hand corner of the window.  Otherwise, the
                           text is centered in the window.  See also `M' under the
                           KEYSTROKES section.
  
!    -sidemargin <inches>  (.sideMargin)  Specifies the side margin (see above).
  
!    -topmargin <inches>   (.topMargin)  Specifies the top and bottom margins (see
                           above).
  
     -paper <papertype>    (.paper)  Specifies the size of the printed page.  This
                           may be of the form WxH (or WxHcm), where W is the width
                           in inches (or cm) and H is the height in inches (or
--- 90,132 ----
     -cr <color>           (.cursorColor)  Determines the color of the cursor.
                           The default is the color of the page border.
  
!    -margins <dimen>      (.Margin)  Specifies the size of both the top and side
!                          margins.  This should be a decimal number optionally
!                          followed by "cm", e.g., 1.5 or 3cm, giving a
!                          measurement in inches or centimeters.  XDVI determines
!                          the "home" position of the page within the window as
!                          follows.  If the entire page fits in the window, then
!                          the margin settings are ignored.  If, even after
!                          removing the margins from the left, right, top, and
!                          bottom, the page still cannot fit in the window, then
!                          the page is put in the window such that the top and
!                          left margins are hidden, and presumably the upper
                           left-hand corner of the text on the page will be in the
                           upper left-hand corner of the window.  Otherwise, the
                           text is centered in the window.  See also `M' under the
                           KEYSTROKES section.
  
!    -sidemargin <dimen>   (.sideMargin)  Specifies the side margin (see above).
  
!    -topmargin <dimen>    (.topMargin)  Specifies the top and bottom margins (see
                           above).
  
+    -offsets <dimen>      (.Offset)  Specifies the size of both the horizontal
+                          and vertical offsets of the output on the page.  This
+                          should be a decimal number optionally followed by "cm",
+                          e.g., 1.5 or 3cm, giving a measurement in inches or
+                          centimeters.  By decree of the Stanford TeX Project,
+                          the default TeX page origin is always 1 inch over and
+                          down from the top-left page corner, even when
+                          non-American paper sizes are used.  Therefore, the
+                          default offsets are 1.0 inch.
+ 
+    -xoffset <dimen>      (.xOffset)  Specifies the size of the horizontal
+                          offset of the output on the page (see above).
+ 
+    -yoffset <dimen>      (.yOffset)  Specifies the size of the vertical offset
+                          of the output on the page (see above).
+ 
     -paper <papertype>    (.paper)  Specifies the size of the printed page.  This
                           may be of the form WxH (or WxHcm), where W is the width
                           in inches (or cm) and H is the height in inches (or
***************
*** 168,177 ****
     q    Quits the program.  Control-C and control-D will do this, too.
  
     n    Moves to the next page (or to the nth next page if a number is given).
!         Synonyms are `f', Space, Return, and Line Feed.
  
     p    Moves to the previous page (or back n pages).  Synonyms are `b',
!         control-H, and Delete.
  
     g    Moves to the page with the given number.  Initially, the first page is
          assumed to be page number 1, but this can be changed with the `P'
--- 191,200 ----
     q    Quits the program.  Control-C and control-D will do this, too.
  
     n    Moves to the next page (or to the nth next page if a number is given).
!         Synonyms are `f', Space, Return, Line Feed, and <Next Screen>.
  
     p    Moves to the previous page (or back n pages).  Synonyms are `b',
!         control-H, Delete, and <Prev Screen>.
  
     g    Moves to the page with the given number.  Initially, the first page is
          assumed to be page number 1, but this can be changed with the `P'
***************
*** 187,199 ****
          left-hand corner of the page, depending on the margins as described in
          the -margins option, above.
  
!    u    Moves up two thirds of a window-full.
  
!    d    Moves down two thirds of a window-full.
  
!    l    Moves left two thirds of a window-full.
  
!    r    Moves right two thirds of a window-full.
  
     c    Moves the page so that the point currently beneath the cursor is moved
          to the middle of the window.  It also (gasp!) warps the cursor to the
--- 210,226 ----
          left-hand corner of the page, depending on the margins as described in
          the -margins option, above.
  
!    u    Moves up two thirds of a window-full.  The <Up Arrow> key is a synonym
!         for this keystroke.
  
!    d    Moves down two thirds of a window-full.  The <Down Arrow> key is a
!         synonym for this keystroke.
  
!    l    Moves left two thirds of a window-full.  The <Left Arrow> key is a
!         synonym for this keystroke.
  
!    r    Moves right two thirds of a window-full.  The <Right Arrow> key is a
!         sysnonym for this keystroke.
  
     c    Moves the page so that the point currently beneath the cursor is moved
          to the middle of the window.  It also (gasp!) warps the cursor to the
***************
*** 251,265 ****
     the font name; "%d" is changed to the magnification; and "%p" is changed to
     the font family ("gf", "pk", or "pxl").  If no "%f" appears in the string,
     then the string ":%f.%d%p" is added on the end.  For example, if the string
!    is "TEX$DISK:[TEX.FONTS.%d]%f.%p" and the font is cmr10 at 300 dpi, then XDVI
!    looks for TEX$DISK:[TEX.FONTS.300]CMR10.GF, TEX$DISK:[TEX.FONTS.300]CMR10.PK,
!    and TEX$DISK:[TEX.FONTS.1500]CMR10.PXL, in that order.  If the first
!    character of the "XDVIFONTS" logical name is a slash, then the system default
!    directories are tried first.  If the font is not found in the desired size,
!    then XDVI will try to find the nearest size.  If the font cannot be found at
!    all, then XDVI will try to vary the point size of the font (within a certain
!    range), and if this fails, then it will use the font specified as the
!    alternate font (cf. -altfont).
  
     The logical name "XDVISIZES" must be set to indicate which sizes of fonts are
     available.  It should consists of a list of numbers separated by slashes.  If
--- 278,292 ----
     the font name; "%d" is changed to the magnification; and "%p" is changed to
     the font family ("gf", "pk", or "pxl").  If no "%f" appears in the string,
     then the string ":%f.%d%p" is added on the end.  For example, if the string
!    is "TEX_DISK:[TEX.FONTS.%d]%f.%p" and the font is cmr10 at 300 dpi, then XDVI
!    looks for TEX_DISK:[TEX.FONTS.300]CMR10.GF, TEX_DISK:[TEX.FONTS.300]CMR10.PK,
!    and TEX_DISK:[TEX.FONTS.1500]CMR10.PXL, in that order.  An extra slash
!    anywhere in the "XDVIFONTS" logical name causes the system default
!    directories to be tried at that point.  If the font is not found in the
!    desired size, then XDVI will try to find the nearest size.  If the font
!    cannot be found at all, then XDVI will try to vary the point size of the font
!    (within a certain range), and if this fails, then it will use the font
!    specified as the alternate font (cf. -altfont).
  
     The logical name "XDVISIZES" must be set to indicate which sizes of fonts are
     available.  It should consists of a list of numbers separated by slashes.  If
***************
*** 267,278 ****
     Sizes are expressed in dots per inch; decimals may be used for "pxl" files:
     for example, a 300 dots per inch file magnified by half a step comes out to
     1643 dots per five inches, which should be encoded as 328.6.  The current
!    default set of sizes is 300/328.6/360/432/518.4/622/746.4.
  
  FILES
  -----
  
!    TEX$FONTS   System default directory for font pixel files.
  
  RESOURCE NAMES
  --------------
--- 294,306 ----
     Sizes are expressed in dots per inch; decimals may be used for "pxl" files:
     for example, a 300 dots per inch file magnified by half a step comes out to
     1643 dots per five inches, which should be encoded as 328.6.  The current
!    default set of sizes is 300/328.6/360/432/518.4/622/746.4.  XDVI will also
!    try the actual size of the font before trying any of the given sizes.
  
  FILES
  -----
  
!    TEX_FONTS   System default directory for font pixel files.
  
  RESOURCE NAMES
  --------------
***************
*** 287,293 ****
        XDvi.copy: off
        XDvi.thorough: on
        XDvi.shrinkFactor: 2
!       XDvi.margins: 0.95
        XDvi*geometry: 1015x750+3+25
  
     When XDVI is invoked, it would behave as if it had been invoked with the
--- 315,321 ----
        XDvi.copy: off
        XDvi.thorough: on
        XDvi.shrinkFactor: 2
!       XDvi.Margin: 0.95
        XDvi*geometry: 1015x750+3+25
  
     When XDVI is invoked, it would behave as if it had been invoked with the
***************
*** 334,351 ****
        $!
        $! Define the virtual disk devices.
        $!
        $ DEFINE /PROCESS /TRANSLATE = (CONCEAL, TERMINAL) PIXELS$    'PIXELS'
        $ DEFINE /PROCESS /TRANSLATE = (CONCEAL, TERMINAL) LPIXELS$   'LPIXELS'
        $!
        $! Define the directories for TeX and its related TeXware.
        $!
!       $ DEFINE TEX$          TEX$DISK:[LOCAL.PROGRAMS]
!       $ DEFINE TEX$PIXELS    PIXELS$, LPIXELS$
        $!
        $! Define the information necessary to run XDVI.
        $!
!       $ XDVI :== "$TEX$:XDVI"
!       $ DEFINE XDVIFONTS "TEX$PIXELS:[DPI%d]%f.%p"
        $ DEFINE XDVISIZES -
                "300/328.6/360/432/518.4/600/622/746.4/895.8/1075/1200/1290/1548"
        $ EXIT
--- 362,380 ----
        $!
        $! Define the virtual disk devices.
        $!
+       $ DEFINE /PROCESS /TRANSLATE = (CONCEAL, TERMINAL) TEX_DISK   'TEXDISK'
        $ DEFINE /PROCESS /TRANSLATE = (CONCEAL, TERMINAL) PIXELS$    'PIXELS'
        $ DEFINE /PROCESS /TRANSLATE = (CONCEAL, TERMINAL) LPIXELS$   'LPIXELS'
        $!
        $! Define the directories for TeX and its related TeXware.
        $!
!       $ DEFINE TEX_EXE       TEX_DISK:[LOCAL.PROGRAMS]
!       $ DEFINE TEX_PIXELS    PIXELS$, LPIXELS$
        $!
        $! Define the information necessary to run XDVI.
        $!
!       $ XDVI :== "$TEX_EXE:XDVI"
!       $ DEFINE XDVIFONTS "TEX_PIXELS:[DPI%d]%f.%p"
        $ DEFINE XDVISIZES -
                "300/328.6/360/432/518.4/600/622/746.4/895.8/1075/1200/1290/1548"
        $ EXIT
diff -cr xdvi_old/XDVI.RNH xdvi_new/XDVI.RNH
*** xdvi_old/XDVI.RNH	Mon Sep 17 17:35:18 1990
--- xdvi_new/XDVI.RNH	Mon Oct 15 12:41:41 1990
***************
*** 7,12 ****
--- 7,13 ----
  .! please let me know.  Pete Siemsen,  siemsen@usc.edu
  .!
  .! Merged with patchlevel 8.001 help file for VMS by Scott Allendorf.
+ .! Added new switches for patchlevel 10.  Scott Allendorf.
  .!
  .NO PAGING
  .NO FLAGS ALL
***************
*** 206,211 ****
--- 207,226 ----
  .SKIP
  The resource name is ".pixelsPerInch".
  .INDENT -1
+ 3 -offsets
+ .BREAK
+ -offsets <dimen>
+ .SKIP
+ Specifies the size of both the horizontal and vertical offsets of the
+ output on the page.  This should be a decimal number optionally followed by
+ "cm", e.g., 1.5 or 3cm, giving a measurement in inches or centimeters.
+ By decree
+ of the Stanford TeX Project, the default TeX page origin is always 1 inch
+ over and down from the top-left page corner, even when non-American paper
+ sizes are used.  Therefore, the default offsets are 1.0 inch.
+ .SKIP
+ The resource name is ".Offset".
+ .INDENT -1
  3 -paper
  .BREAK
  -paper <papertype>
***************
*** 221,230 ****
  .INDENT -1
  3 -margins
  .BREAK
! -margins <inches>
  .SKIP
! Specifies the size of both the top and side margins.  This can
! be a decimal number, e.g., 1.5.  XDVI determines the "home" position of
  the page within the window as follows.  If the entire page fits in the
  window, then the margin settings are ignored.  If, even after removing
  the margins from the left, right, top, and bottom, the page still
--- 236,247 ----
  .INDENT -1
  3 -margins
  .BREAK
! -margins <dimen>
  .SKIP
! Specifies the size of both the top and side margins.  This should be a
! decimal number optionally followed by "cm", e.g., 1.5 or 3cm, giving a
! measurement in inches or centimeters.
! XDVI determines the "home" position of
  the page within the window as follows.  If the entire page fits in the
  window, then the margin settings are ignored.  If, even after removing
  the margins from the left, right, top, and bottom, the page still
***************
*** 234,240 ****
  left-hand corner of the window.  Otherwise, the text is centered in
  the window.  See also `M' under the Keystrokes help entry.
  .SKIP
! The resource name is ".margins".
  .INDENT -1
  3 -mgs[n]
  .BREAK
--- 251,257 ----
  left-hand corner of the window.  Otherwise, the text is centered in
  the window.  See also `M' under the Keystrokes help entry.
  .SKIP
! The resource name is ".Margin".
  .INDENT -1
  3 -mgs[n]
  .BREAK
***************
*** 269,280 ****
  .INDENT -1
  3 -sidemargin
  .BREAK
! -sidemargin <inches>
  .SKIP
  Specifies the side margin (see -margins).
  .SKIP
  The resource name is ".sideMargin".
  .INDENT -1
  3 -thorough
  .BREAK
  XDVI will usually try to ensure that overstrike characters (e.g.,
--- 286,304 ----
  .INDENT -1
  3 -sidemargin
  .BREAK
! -sidemargin <dimen>
  .SKIP
  Specifies the side margin (see -margins).
  .SKIP
  The resource name is ".sideMargin".
  .INDENT -1
+ 3 -sw
+ .BREAK
+ Causes XDVI to warn the user when it encounters a \special string which it
+ cannot process.  This option is on by default; to turn it off, use  +sw.
+ .SKIP
+ The resource name is ".specialWarn".
+ .INDENT -1
  3 -thorough
  .BREAK
  XDVI will usually try to ensure that overstrike characters (e.g.,
***************
*** 290,300 ****
  .INDENT -1
  3 -topmargin
  .BREAK
! -topmargin <inches>
  .SKIP
  Specifies the top and bottom margins (see -margins).
  .SKIP
  The resource name is ".topMargin".
  
  .INDENT -1
  2 Keystrokes
--- 314,342 ----
  .INDENT -1
  3 -topmargin
  .BREAK
! -topmargin <dimen>
  .SKIP
  Specifies the top and bottom margins (see -margins).
  .SKIP
  The resource name is ".topMargin".
+ .INDENT -1
+ 3 -xoffset
+ .BREAK
+ -xoffset <dimen>
+ .SKIP
+ Specifies the size of the horizontal offset of the output on the page (see
+ -offsets).
+ .SKIP
+ The resource name is ".xOffset".
+ .INDENT -1
+ 3 -yoffset
+ .BREAK
+ -yoffset <dimen>
+ .SKIP
+ Specifies the size of the vertical offset of the output on the page (see
+ -offsets).
+ .SKIP
+ The resource name is ".yOffset".
  
  .INDENT -1
  2 Keystrokes
***************
*** 311,322 ****
  3 n
  .BREAK
  Moves to the next page (or to the nth next page if a number is given).
! Synonyms are `f', Space, Return, and Line Feed.
  .INDENT -1
  3 p
  .BREAK
  Moves to the previous page (or back n pages).  Synonyms are
! `b', control-H, and Delete.
  .INDENT -1
  3 g
  .BREAK
--- 353,364 ----
  3 n
  .BREAK
  Moves to the next page (or to the nth next page if a number is given).
! Synonyms are `f', Space, Return, Line Feed, and <Next Screen>.
  .INDENT -1
  3 p
  .BREAK
  Moves to the previous page (or back n pages).  Synonyms are
! `b', control-H, Delete, and <Prev Screen>.
  .INDENT -1
  3 g
  .BREAK
***************
*** 341,359 ****
  .INDENT -1
  3 u
  .BREAK
! Moves up two thirds of a window-full.
  .INDENT -1
  3 d
  .BREAK
! Moves down two thirds of a window-full.
  .INDENT -1
  3 l
  .BREAK
! Moves left two thirds of a window-full.
  .INDENT -1
  3 r
  .BREAK
! Moves right two thirds of a window-full.
  .INDENT -1
  3 c
  .BREAK
--- 383,405 ----
  .INDENT -1
  3 u
  .BREAK
! Moves up two thirds of a window-full.  The <Up Arrow> key is a synonym for this
! keystroke.
  .INDENT -1
  3 d
  .BREAK
! Moves down two thirds of a window-full.  The <Down Arrow> key is a synonym for
! this keystroke.
  .INDENT -1
  3 l
  .BREAK
! Moves left two thirds of a window-full.  The <Left Arrow> key is a synonym for
! this keystroke.
  .INDENT -1
  3 r
  .BREAK
! Moves right two thirds of a window-full.  The <Right Arrow> key is a synonym for
! this keystroke.
  .INDENT -1
  3 c
  .BREAK
***************
*** 432,445 ****
  "%p" is changed to the font family ("gf", "pk", or "pxl").  If no "%f"
  appears in the string, then the string ":%f.%d%p" is added on the end.
  .SKIP
! For example, if the string is "TEX$DISK:[TEX.FONTS.%d]%f.%p" and the font is
! cmr10 at 300dpi, then XDVI looks for TEX$DISK:[TEX.FONTS.300]CMR10.GF,
! TEX$DISK:[TEX.FONTS.300]CMR10.PK, and TEX$DISK:[TEX.FONTS.1500]CMR10.PXL,
  in that order.
  .SKIP
! If the first character of the "XDVIFONTS" logical name is a slash, then
! the system default directories are tried first.  If the font is not found in
! the desired size, then XDVI will try to find the nearest size.  If the
  font cannot be found at all, then XDVI will try to vary the point size
  of the font (within a certain range), and if this fails, then it will
  use the font specified as the alternate font (cf. -altfont).
--- 478,491 ----
  "%p" is changed to the font family ("gf", "pk", or "pxl").  If no "%f"
  appears in the string, then the string ":%f.%d%p" is added on the end.
  .SKIP
! For example, if the string is "TEX_DISK:[TEX.FONTS.%d]%f.%p" and the font is
! cmr10 at 300dpi, then XDVI looks for TEX_DISK:[TEX.FONTS.300]CMR10.GF,
! TEX_DISK:[TEX.FONTS.300]CMR10.PK, and TEX_DISK:[TEX.FONTS.1500]CMR10.PXL,
  in that order.
  .SKIP
! An extra slash anywhere in the the "XDVIFONTS" logical name causes the
! system default directories to be tried at that point.  If the font is not
! found in the desired size, then XDVI will try to find the nearest size.  If the
  font cannot be found at all, then XDVI will try to vary the point size
  of the font (within a certain range), and if this fails, then it will
  use the font specified as the alternate font (cf. -altfont).
***************
*** 453,459 ****
  inch; decimals may be used for "pxl" files: for example, a 300 dots
  per inch file magnified by half a step comes out to 1643 dots per five
  inches, which should be encoded as 328.6.  The current default set of
! sizes is 300/328.6/360/432/518.4/622/746.4.
  
  .INDENT -1
  2 Resource_Names
--- 499,506 ----
  inch; decimals may be used for "pxl" files: for example, a 300 dots
  per inch file magnified by half a step comes out to 1643 dots per five
  inches, which should be encoded as 328.6.  The current default set of
! sizes is 300/328.6/360/432/518.4/622/746.4.  XDVI will also try the actual
! size of the font before trying any of the given sizes.
  
  .INDENT -1
  2 Resource_Names
***************
*** 469,475 ****
     XDvi.copy: off
     XDvi.thorough: on
     XDvi.shrinkFactor: 2
!    XDvi.margins: 0.95
     XDvi*geometry: 1015x750+3+25
  .END LITERAL
  .SKIP
--- 516,522 ----
     XDvi.copy: off
     XDvi.thorough: on
     XDvi.shrinkFactor: 2
!    XDvi.Margin: 0.95
     XDvi*geometry: 1015x750+3+25
  .END LITERAL
  .SKIP
diff -cr xdvi_old/dvi_draw.c xdvi_new/dvi_draw.c
*** xdvi_old/dvi_draw.c	Mon Sep 17 17:35:29 1990
--- xdvi_new/dvi_draw.c	Fri Sep  7 12:57:55 1990
***************
*** 34,44 ****
  
  /*
   *	Explanation of the following constant:
!  *	pixels_per_inch << 16:	one inch margin
   *	shrink_factor << 16:	one pixel page border
   *	shrink_factor << 15:	rounding for pixel_conv
   */
! #define PAGE_OFFSET	(pixels_per_inch << 16) + (shrink_factor * 3 << 15)
  
  struct frame	*stack;
  struct frame	*stackp;
--- 34,45 ----
  
  /*
   *	Explanation of the following constant:
!  *	offset_[xy]   << 16:	margin (defaults to one inch)
   *	shrink_factor << 16:	one pixel page border
   *	shrink_factor << 15:	rounding for pixel_conv
   */
! #define OFFSET_X	(offset_x << 16) + (shrink_factor * 3 << 15)
! #define OFFSET_Y	(offset_y << 16) + (shrink_factor * 3 << 15)
  
  struct frame	*stack;
  struct frame	*stackp;
***************
*** 74,79 ****
--- 75,81 ----
  #endif	/* BMLONG */
  
  char	*malloc();
+ void	exit();
  Boolean	check_dvi_file();
  void	applicationDoSpecial();
  
***************
*** 94,103 ****
  #else
  		for (i = BITS_PER_BMUNIT - 1; i >= 0; --i)
  #endif
! 		    putchar((*ptr & (1 << i)) ? '@' : ' ');
  		++ptr;
  	    }
! 	    putchar('\n');
  	}
  }
  
--- 96,105 ----
  #else
  		for (i = BITS_PER_BMUNIT - 1; i >= 0; --i)
  #endif
! 		    Putchar((*ptr & (1 << i)) ? '@' : ' ');
  		++ptr;
  	    }
! 	    Putchar('\n');
  	}
  }
  
***************
*** 109,115 ****
  	Printf("char %d", ch);
  	if (isprint(ch))
  		Printf(" (%c)", ch);
! 	putchar('\n');
  	Printf("x = %d, y = %d, dvi = %d\n",
  		g->x, g->y, g->dvi_adv);
  	print_bitmap(&g->bitmap);
--- 111,117 ----
  	Printf("char %d", ch);
  	if (isprint(ch))
  		Printf(" (%c)", ch);
! 	Putchar('\n');
  	Printf("x = %d, y = %d, dvi = %d\n",
  		g->x, g->y, g->dvi_adv);
  	print_bitmap(&g->bitmap);
***************
*** 139,145 ****
  		Printf("SETCHAR%-3d", ch - SETCHAR0);
  		if (isprint(ch))
  			Printf(" (%c)", ch);
! 		putchar('\n');
  		return;
  	}
  	else if (ch < FNTNUM0) s = dvi_table1[ch - 128];
--- 141,147 ----
  		Printf("SETCHAR%-3d", ch - SETCHAR0);
  		if (isprint(ch))
  			Printf(" (%c)", ch);
! 		Putchar('\n');
  		return;
  	}
  	else if (ch < FNTNUM0) s = dvi_table1[ch - 128];
***************
*** 468,475 ****
  			    case BOP:
  				Fseek(dvi_file, (long) 11*4, 1);
  				stackp = stack;
! 				DVI_H = DVI_V = PAGE_OFFSET;
! 				PXL_V = pixel_conv(PAGE_OFFSET);
  				WW = XX = YY = ZZ = 0;
  				break;
  
--- 470,478 ----
  			    case BOP:
  				Fseek(dvi_file, (long) 11*4, 1);
  				stackp = stack;
! 				DVI_H = OFFSET_X;
! 				DVI_V = OFFSET_Y;
! 				PXL_V = pixel_conv(DVI_V);
  				WW = XX = YY = ZZ = 0;
  				break;
  
***************
*** 633,638 ****
  {
  	Fprintf(stderr, "%s: ", prog);
  	Fprintf(stderr, message, a, b, c, d, e, f);
! 	putc('\n', stderr);
  	exit(1);
  }
--- 636,641 ----
  {
  	Fprintf(stderr, "%s: ", prog);
  	Fprintf(stderr, message, a, b, c, d, e, f);
! 	Putc('\n', stderr);
  	exit(1);
  }
diff -cr xdvi_old/dvi_init.c xdvi_new/dvi_init.c
*** xdvi_old/dvi_init.c	Mon Sep 17 17:35:35 1990
--- xdvi_new/dvi_init.c	Wed Sep 26 12:37:09 1990
***************
*** 27,32 ****
--- 27,41 ----
   *	A4	use European size paper
   */
  
+ #define	GF_PRE		247
+ #define	GF_ID_BYTE	131
+ #define	GF_MAGIC	(GF_PRE << 8) + GF_ID_BYTE
+ #define	PK_PRE		247
+ #define	PK_ID		89
+ #define	PK_MAGIC	(PK_PRE << 8) + PK_ID
+ #define	PXL_MAGIC1	0
+ #define	PXL_MAGIC2	1001
+ 
  #include <stdio.h>
  #include <ctype.h>
  #include "xdvi.h"
***************
*** 36,41 ****
--- 45,52 ----
  #define	dvi_oops(str)	longjmp(dvi_env, (int) str);
  #define XtOffset(type, field)    ((unsigned int)&(((type)NULL)->field))
  
+ read_font_index_proc read_GF_index, read_PK_index, read_PXL_index;
+ 
  static	struct stat fstatbuf;		/* mechanism to see if file was */
  time_t	dvi_time;			/* modified since last usage */
  
***************
*** 48,59 ****
  int	n_fonts_left	= 32767;	/* for LRU management of fonts */
  
  char	*realloc();
  
  /*
   * DVI preamble and postamble information.
   */
  int	current_page;
! Boolean	spec_warn;
  int	total_pages;
  double	fraction;
  int	maxstack;
--- 59,71 ----
  int	n_fonts_left	= 32767;	/* for LRU management of fonts */
  
  char	*realloc();
+ void	exit();
  
  /*
   * DVI preamble and postamble information.
   */
  int	current_page;
! Boolean	spec_warn_now;
  int	total_pages;
  double	fraction;
  int	maxstack;
***************
*** 90,95 ****
--- 102,108 ----
          register struct font *fontp;
  	struct font **fontpp = old_fonts;
  	struct font *fontp1;
+ 	float	fsize;
  	int len;
  	int design;
  	int size;
***************
*** 108,115 ****
  	if(debug & DBG_PK)
  	  Printf("Define font \"%s\" scale=%d design=%d\n",
  	    fontp->fontname, fontp->scale, design);
! 	fontp->size = size = ((double) fontp->scale / design * magnification
! 	    * pixels_per_inch * 0.005) + 0.5;
  	fontp->scale = fontp->scale * fraction;
  	/*
  	 * reuse font if possible
--- 121,129 ----
  	if(debug & DBG_PK)
  	  Printf("Define font \"%s\" scale=%d design=%d\n",
  	    fontp->fontname, fontp->scale, design);
! 	fsize = (float) fontp->scale / design * magnification
! 	    * pixels_per_inch * 0.005;
! 	fontp->size = size = fsize + 0.5;
  	fontp->scale = fontp->scale * fraction;
  	/*
  	 * reuse font if possible
***************
*** 121,132 ****
  		char	*font_found;
  		int	size_found;
  		int	dpi = (size + 2) / 5;
  
  		if (n_fonts_left == 0)
  		    close_a_file();
  		fontp->file = pxl_open(fontp->fontname, &font_found,
! 		    size, &size_found, &fontp->factor, &fontp->filename,
! 		    &read_font_index);
  		if (fontp->file == NULL) {
  		    Fprintf(stderr, "Can't find font %s.\n", fontp->fontname);
  		    font_not_found = True;
--- 135,146 ----
  		char	*font_found;
  		int	size_found;
  		int	dpi = (size + 2) / 5;
+ 		int	magic;
  
  		if (n_fonts_left == 0)
  		    close_a_file();
  		fontp->file = pxl_open(fontp->fontname, &font_found,
! 		    fsize, &size_found, &fontp->factor, &fontp->filename);
  		if (fontp->file == NULL) {
  		    Fprintf(stderr, "Can't find font %s.\n", fontp->fontname);
  		    font_not_found = True;
***************
*** 140,152 ****
  		    free(fontp->fontname);
  		    fontp->fontname = font_found;
  		}
! 		else if (25 * size_found > 26 * size ||
! 			25 * size > 26 * size_found)
  		    Fprintf(stderr,
  			"Can't find font %s at %d dpi; using %d dpi instead.\n",
  			fontp->fontname, dpi, (size_found + 2) / 5);
! 		fontp->factor = fontp->factor * size / size_found;
  		maxchar = 255;
  		(*read_font_index)(fontp);
  		while (maxchar > 0 && fontp->glyph[maxchar].addr == 0)
  		    --maxchar;
--- 154,175 ----
  		    free(fontp->fontname);
  		    fontp->fontname = font_found;
  		}
! 		else if (size_found > (int) (1.002 * fsize + 0.5) ||
! 			size_found < (int) (0.998 * fsize + 0.5))
  		    Fprintf(stderr,
  			"Can't find font %s at %d dpi; using %d dpi instead.\n",
  			fontp->fontname, dpi, (size_found + 2) / 5);
! 		fontp->factor = fontp->factor * fsize / size_found;
  		maxchar = 255;
+ 		magic = two(fontp->file);
+ 		if (magic == GF_MAGIC) read_font_index = read_GF_index;
+ 		else if (magic == PK_MAGIC) read_font_index = read_PK_index;
+ 		else if (magic == PXL_MAGIC1 && two(fontp->file) == PXL_MAGIC2)
+ 		    read_font_index = read_PXL_index;
+ 		else oops("Cannot recognize format for font file %s",
+ 		    fontp->filename);
+ 		if (read_font_index == NULL)
+ 		    oops("%s: unsupported font format.", fontp->filename);
  		(*read_font_index)(fontp);
  		while (maxchar > 0 && fontp->glyph[maxchar].addr == 0)
  		    --maxchar;
***************
*** 162,169 ****
  		free(fontp->fontname);
  		free((char *) fontp);
  		fontp = fontp1;
! 		if (list_fonts)
! 		    fputs("(reusing) ",stdout);
  		break;
  	    }
  	    fontpp = &fontp1->next;
--- 185,191 ----
  		free(fontp->fontname);
  		free((char *) fontp);
  		fontp = fontp1;
! 		if (list_fonts) Fputs("(reusing) ", stdout);
  		break;
  	    }
  	    fontpp = &fontp1->next;
***************
*** 204,227 ****
   *      find_postamble locates the beginning of the postamble
   *	and leaves the file ready to start reading at that location.
   */
  static
  find_postamble()
  {
! 	ubyte byte;
  
! 	Fseek(dvi_file, (long) -4, 2);
! 	while (four(dvi_file) !=
! 		((long) TRAILER << 24 | TRAILER << 16 | TRAILER << 8 | TRAILER))
! 	    Fseek(dvi_file, (long) -5, 1);
! 	Fseek(dvi_file, (long) -5, 1);
  	for (;;) {
! 		byte = one(dvi_file);
! 		if (byte != TRAILER) break;
! 		Fseek(dvi_file, (long) -2, 1);
  	}
  	if (byte != 2)
! 		dvi_oops("Wrong version of DVI output for this program");
! 	Fseek(dvi_file, (long) -5, 1);
  	Fseek(dvi_file, sfour(dvi_file), 0);
  }
  
--- 226,263 ----
   *      find_postamble locates the beginning of the postamble
   *	and leaves the file ready to start reading at that location.
   */
+ #define	TMPSIZ	516	/* 4 trailer bytes + 512 junk bytes allowed */
  static
  find_postamble()
  {
! 	long	pos;
! 	ubyte	temp[TMPSIZ];
! 	ubyte	*p;
! 	ubyte	*p1;
! 	ubyte	byte;
  
! 	Fseek(dvi_file, (long) 0, 2);
! 	pos = ftell(dvi_file) - TMPSIZ;
! 	if (pos < 0) pos = 0;
! 	Fseek(dvi_file, pos, 0);
! 	p = temp + fread((char *) temp, sizeof(char), TMPSIZ, dvi_file);
  	for (;;) {
! 	    p1 = p;
! 	    while (p1 > temp && *(--p1) != TRAILER) ;
! 	    p = p1;
! 	    while (p > temp && *(--p) == TRAILER) ;
! 	    if (p <= p1 - 4) break;	/* found 4 TRAILER bytes */
! 	    if (p <= temp) dvi_oops("DVI file corrupted");
  	}
+ 	pos += p - temp;
+ 	byte = *p;
+ 	while (byte == TRAILER) {
+ 	    Fseek(dvi_file, --pos, 0);
+ 	    byte = one(dvi_file);
+ 	}
  	if (byte != 2)
! 	    dvi_oops("Wrong version of DVI output for this program");
! 	Fseek(dvi_file, pos - 4, 0);
  	Fseek(dvi_file, sfour(dvi_file), 0);
  }
  
***************
*** 244,253 ****
  		  ||  magnification != four(dvi_file))
  	    dvi_oops("Postamble doesn't match preamble");
  		/* read largest box height and width */
! 	unshrunk_page_h = (spellfour(dvi_file) >> 16) + pixels_per_inch;
  	if (unshrunk_page_h < unshrunk_paper_h)
  	    unshrunk_page_h = unshrunk_paper_h;
! 	unshrunk_page_w = (spellfour(dvi_file) >> 16) + pixels_per_inch;
  	if (unshrunk_page_w < unshrunk_paper_w)
  	    unshrunk_page_w = unshrunk_paper_w;
  	maxstack = two(dvi_file);
--- 280,289 ----
  		  ||  magnification != four(dvi_file))
  	    dvi_oops("Postamble doesn't match preamble");
  		/* read largest box height and width */
! 	unshrunk_page_h = (spellfour(dvi_file) >> 16) + offset_y;
  	if (unshrunk_page_h < unshrunk_paper_h)
  	    unshrunk_page_h = unshrunk_paper_h;
! 	unshrunk_page_w = (spellfour(dvi_file) >> 16) + offset_x;
  	if (unshrunk_page_w < unshrunk_paper_w)
  	    unshrunk_page_w = unshrunk_paper_w;
  	maxstack = two(dvi_file);
***************
*** 344,350 ****
  	prepare_pages();
  	init_page();
  	if (current_page >= total_pages) current_page = total_pages - 1;
! 	spec_warn = True;
  }
  
  /**
--- 380,386 ----
  	prepare_pages();
  	init_page();
  	if (current_page >= total_pages) current_page = total_pages - 1;
! 	spec_warn_now = spec_warn;
  }
  
  /**
***************
*** 408,414 ****
  		dvi_file = fopen(dvi_name, OPEN_MODE);
  		if (dvi_file == NULL)
  		    dvi_oops("Cannot reopen dvi file.");
! 		if (list_fonts) putchar('\n');
  		init_dvi_file();
  		redraw_page();
  		return False;
--- 444,450 ----
  		dvi_file = fopen(dvi_name, OPEN_MODE);
  		if (dvi_file == NULL)
  		    dvi_oops("Cannot reopen dvi file.");
! 		if (list_fonts) Putchar('\n');
  		init_dvi_file();
  		redraw_page();
  		return False;
diff -cr xdvi_old/gf.c xdvi_new/gf.c
*** xdvi_old/gf.c	Mon Sep 17 17:35:40 1990
--- xdvi_new/gf.c	Mon Sep 17 12:23:33 1990
***************
*** 71,83 ****
  
  	fontp->read_char = read_char;
  	GF_file = fontp->file;
- /*
-  *	Read the preamble.
-  */
  	if (debug & DBG_PK)
! 	    Printf("Reading header for GF pixel file %s\n", fontp->filename);
! 	expect(PRE);
! 	expect(GF_ID_BYTE);
  /*
   *	Find postamble.
   */
--- 71,78 ----
  
  	fontp->read_char = read_char;
  	GF_file = fontp->file;
  	if (debug & DBG_PK)
! 	    Printf("Reading GF pixel file %s\n", fontp->filename);
  /*
   *	Find postamble.
   */
diff -cr xdvi_old/patchlevel.h xdvi_new/patchlevel.h
*** xdvi_old/patchlevel.h	Mon Sep 17 17:35:43 1990
--- xdvi_new/patchlevel.h	Wed Sep 26 13:09:55 1990
***************
*** 1 ****
! #define PATCHLEVEL 9
--- 1 ----
! #define PATCHLEVEL 10
diff -cr xdvi_old/pk.c xdvi_new/pk.c
*** xdvi_old/pk.c	Mon Sep 17 17:35:49 1990
--- xdvi_new/pk.c	Mon Sep 17 12:25:49 1990
***************
*** 123,141 ****
  register struct font *fontp;
  {
    int hppp, vppp;
!   /*
!    * Read the header of a packed pixel file.
!    */
    fontp->read_char = read_char;
    if (debug & DBG_PK)
!     Printf("Reading header for PK pixel file %s\n", fontp->filename);
  
-   if (one(fontp->file) != PK_PRE)
-     oops("File %s lacks preamble command", fontp->fontname);
- 
-   if (one(fontp->file) != PK_ID)
-     oops("File %s has wrong PK id", fontp->fontname);
- 
    Fseek(fontp->file, (long) one(fontp->file), 1);	/* skip comment */
  
    (void) four(fontp->file);		/* skip design size */
--- 123,133 ----
  register struct font *fontp;
  {
    int hppp, vppp;
! 
    fontp->read_char = read_char;
    if (debug & DBG_PK)
!     Printf("Reading PK pixel file %s\n", fontp->filename);
  
    Fseek(fontp->file, (long) one(fontp->file), 1);	/* skip comment */
  
    (void) four(fontp->file);		/* skip design size */
***************
*** 143,149 ****
    hppp = sfour(fontp->file);
    vppp = sfour(fontp->file);
    if( debug && hppp != vppp )
!     oops("Warning: aspect ratio not 1:1 for font %s", fontp->fontname);
    /*fontp->f_scale = (int)((((float) hppp * 72.27) / (float) 65536) + 0.5);*/
  
    /*if (fontp->f_scale == 0) fontp->f_scale = 1000;*/
--- 135,142 ----
    hppp = sfour(fontp->file);
    vppp = sfour(fontp->file);
    if( debug && hppp != vppp )
!     Fprintf(stderr, "Warning: aspect ratio not 1:1 for font %s\n",
!       fontp->fontname);
    /*fontp->f_scale = (int)((((float) hppp * 72.27) / (float) 65536) + 0.5);*/
  
    /*if (fontp->f_scale == 0) fontp->f_scale = 1000;*/
***************
*** 237,243 ****
  	if (g->bitmap.w != 0)
  	    Printf(", size=%dx%d, dvi_adv=%d", g->bitmap.w, g->bitmap.h,
  		g->dvi_adv);
! 	putchar('\n');
      }
  
      alloc_bitmap(&g->bitmap, fontp->fontname, ch);
--- 230,236 ----
  	if (g->bitmap.w != 0)
  	    Printf(", size=%dx%d, dvi_adv=%d", g->bitmap.w, g->bitmap.h,
  		g->dvi_adv);
! 	Putchar('\n');
      }
  
      alloc_bitmap(&g->bitmap, fontp->fontname, ch);
diff -cr xdvi_old/pxl.c xdvi_new/pxl.c
*** xdvi_old/pxl.c	Mon Sep 17 17:35:52 1990
--- xdvi_new/pxl.c	Mon Sep 17 17:37:22 1990
***************
*** 52,65 ****
  	register struct font *fontp;
  {
  	register struct glyph *g;
! 	register FILE *fp;
  	long font_dir_ptr;
  
  	if (debug & DBG_PK)
! 	    Printf("Reading header for PXL file %s\n", fontp->filename);
  	fontp->read_char = read_char;
- 	if (four(fp = fontp->file) != 1001)
- 	    oops("File %s has wrong PXL magic number.", fontp->filename);
  	/* seek to trailer info */
  	Fseek(fp, (long) -4, 2);
  	while (four(fp) != 1001)
--- 52,63 ----
  	register struct font *fontp;
  {
  	register struct glyph *g;
! 	register FILE *fp	= fontp->file;
  	long font_dir_ptr;
  
  	if (debug & DBG_PK)
! 	    Printf("Reading PXL file %s\n", fontp->filename);
  	fontp->read_char = read_char;
  	/* seek to trailer info */
  	Fseek(fp, (long) -4, 2);
  	while (four(fp) != 1001)

dan
----------------------------------------------------
O'Reilly && Associates   argv@sun.com / argv@ora.com
Opinions expressed reflect those of the author only.