/* @(#)Changes	3.1\t11/16/89 */

/* Change.log for dvi2ps */

/*
 * AUTHOR(s)
 *     Mark Senn wrote the early versions of this program for the
 *     BBN BitGraph.  Stephan Bechtolsheim, Bob Brown, Richard
 *     Furuta, James Schaad and Robert Wells improved it.  Norm
 *     Hutchinson ported the program to the Sun.  Neal Holtz ported
 *     it to the Apollo, and from there to producing PostScript
 *     output. Scott Jones added intelligent font substitution.
 *     Howard Trickey made it read GF files instead of PXL ones.
 *     Les Carr added the capacity for use of LaserWriter builtin fonts.
 *     Larry Denenberg added support for TeX-XeT's extensions.
 *     Meanwhile, Peter Damron had changed the fontpath implementation and 
 *     the font substitution routines. At another point, Van Jacobson adapted
 *     the GF code to read PK files in addition to PXL ones, add support for 
 *     Trevor Darrell's psfig & laserwriter font support (an enhanced version
 *     of LA Carr's work on laserwriter fonts) and added user-selectable
 *     font flushing intervals (to support long documents or complex figures).
 *     Jingbai Wang rewrote the special handling commands, fontpath routines,
 *     and added an on-line help routine and unlimited scaling of all fonts.
 *     Kevin R. Coombes merged these three versions, building principally
 *     on the organization of Larry Denenberg's version.
 */

/* Change log:
 *
 * Early '85 (nmh) -- ported sun version to Apollo.
 * ... later (nmh) -- changed to continue on in the event of missing
 *		      font files.
 * 30-Mar-85 (nmh) -- added -a option to specify a different PXL area
 * 30-Mar-85 (nmh) -- changed default PXL area to /pxl118
 * 31-Mar-85 (nmh) -- fixed bug in OpenFontFile() regarding more than MAXOPEN
 *		      PXL files; changed to mark files as closed in font_entry.
 *  7-Apr-85 (nmh) -- made command line argument decoding case insensitive.
 *		      cleaned up handling of DVI file name argument.
 * 30-May-85 (nmh) -- new version; hacked to output PostScript commands
 *  6-Jun-85 (nmh) -- added relative positioning (20% less PostScript output)
 *		      add -m option to specify mag
 * 11-Jun-85 (nmh) -- fixed bug regarding char spacings in very long "words"
 * 12-Jun-85 (nmh) -- v1.02 - process DVI pages in reverse order
 * 13-Jun-85 (nmh) -- fixed bug:  PXL files opened too often when no PreLoad
 * 14-Jun-85 (nmh) -- font dict created in PostScript only when 1st char of
 *		      font downloaded; add -m0 -mh -m1 etc. to specify magsteps
 * 16-Aug-85 (nmh) -- added -c option to create output in spool area (Apollo)
 *		      added -h option to copy header file to output
 *		      added -o option to pass options through to PostScript
 * 20-Aug-85 (nmh) -- v1.03
 * 24-Aug-85 (nmh) -- add -q option (for quiet operation).
 *		      changed -o option to check PostScript option
 *		      changed to output coordinates in TeX system (but
 *		      scaled to raster units) -- (0,0) at 1" in and down from
 *		      top left (better for use with different size paper).
 *		   -- v2.00
 * 25-Aug-85 (nmh) -- added dictionary enclosure to Tex.ps, and output
 *		      suitable prolog here.
 * 26-Aug-85 (nmh) -- changes to tex.ps to support Macintosh documents.
 * 14-Sep-85 (nmh) -- added keyword=value decoding to \special;
 * 15-Sep-85 (nmh) -- added -i file option.
 * 23-Sep-85 (saj) -- added font substitution for case when font is
 *		      unavailable at requested mag. (a frequent occurrence
 *		      with some macro packages like LaTeX)
 *  7-Jun-86 (hwt) -- use gf files ("pxl" survives in variable names)
 *  8-Aug-86 (rkf) -- merged together the pxl and the gf versions.  Define
 *		      USEPXL should you want PXL files---gf is the default
 **************************************************************************
 *  Here a branch occurs. Main branch:
 **************************************************************************
*BRANCH I*
 * 15-Jan-86 (drp) -- look for TEXFONTS env variable first
 * 13-Mar-87 (lac) -- added -x option for Soton user
 * 18-Mar-87 (lac) -- new version which uses built-in fonts on the Apple
 *		      LaserWriter and allows the use of psfig
 **************************************************************************
 *  Here another branch occurs. Main branch continues:
 **************************************************************************
*BRANCH I A*
 * 22-Dec-87 (pam) -- suppress (but do not remove) the function of the -d
 *		      flag for debugging, so that it can be used to specify
 *		      print-engine resolution (inspired by the VariTyper 600).
 *  5-Jan-88 (pam) -- provide for 256 character gf fonts.
 *  4-Apr-88 (lad) -- merge last five updates from different versions
 * 12-Apr-88 (lad) -- allow list of pathnames in TEXFONTS;  allow
 *		      absolute fontnames
 * 10-May-88 (lad) -- handle reflection commands produced by TeX-XeT; many
 *		      minor bug fixes;  break into small files and clean up;
 *		      v2.30
 *
 **************************************************************************
 *  First divergent branch:
 **************************************************************************
*BRANCH II*
 *  14-Dec-87 (peterd) -- Changed sub-directory structure used by findfile.
 *                      Style names are used for subdirectories, not style
 *                      plus design size.
 *                      Changed font substitutions to compare <design size>
 *                      * <mag size>, not design and mag separately.
 *                      Changed all progress messages to go through Progress().
 *                      Changed all warning messages to go through Warning().
 *                      Note that Stats and Debug still use stderr.
 *                      Added support for font paths (multiple -a options).
 *                      Added support for environment variable for font path.
 *
 **************************************************************************
 *  Second divergent branch:
 **************************************************************************
*BRANCH I B*
******************* The Following is added in by JB Wang *******************
  Jingbai Wang at University of Pittsburgh re-added "psfile" option into
  the \special in 9/1988 so that the user does not have to include
  Trevor Darrel's psfig.tex before he can include a PostScript file,
  besides, \psfig needs too good PostScript files -- nonrealistic

 1. psfile in \special  Syntax:
    \special{psfile=mypsfile.ps}
    This makes makes \special much more conventional (there was a
    "psfile" thing before, but when psfig was implemented, this function
    was damaged (in the header file tex.ps).

 2. Jingbai Wang  added in the option "pspage" in the \special,
    this is very convenient when a full/multi page (11x8.5 inches) PostScript
    image/text is to be inserted.

 3. Jingbai Wang  added a optional flag =, so that the user does not
    have to re-direct the standard-out into a file all the time, i.e.,

    $dvi2ps mytex -=
 
    will convert mytex.dvi into mytex.ps

 4. Jingbai Wang  added a optional flag M to include the Macintosh
    PostScript dictionary  once for all, e.g.,

    $dvi2ps -M mytex -=
 
 5. "ps-string" in \special is added by Jingbai Wang for direct inclusion
    of PostScript command string 11/1988

 6. Jingbai Wang also added an optional argument "-K path" for searching user's
    pk file. dvi2ps will search for the default PK file first, if failed
    search for the user's. For example,

    $dvi2ps -K ~/tex mytex -=

    which means there are pk files in ~/tex/pk subdirectory.

 7. JB Wang added "-H dvi2ps/tex/latex" option for on-line help

    $dvi2ps -H

    displays dvi2ps.doc (dvi2ps help),

    $dvi2ps -H tex

    displays texint.doc (TeX/LaTeX help)


 8. JB Wang modified mag and scaling handling in the following way,
    a) If right font and right mag is found, use the PK file
    b) If no right font or mag is found, use the closest PK file  AND
       use PostScript scaling to scale the font to fit exactly the font
       space given by TeX TFM.

 9. Mark Leisher modified Mapping file to contain better TFM width
    value for "chfont[0-n]" entries.  Also fixed is a "findfont" is
    added when defining the Chinese fonts because the printer wasn't
    finding the Chinese fonts.
    (mleisher@nmsu.edu Mon Dec 17 19:34:20 1990)
 */

/**************************************************************************
 *	7 Sept 89: Merger of these divergent branches. Produced a version
 * which had the following features: (i) ability to use GF, PK, or PXL
 * files. Can be set at compile time. (ii) Intelligent searching for fonts.
 * We first search the entire directory tree for the right font at the right
 * magnification. If not found, we search the whole tree for the best fit
 * in that font style, and use postscript to scale it to the right size.
 * (iii) Flexible font organization in terms of subdirectories, and support
 * for environment variables. (iv) Restored case insensitivity of the command
 * line. (v) Uses builtin fonts. Only reencodes a style once. Ditto for
 * special stuff like Obliques and SmallCaps. (vi) Ability to specify
 * resolution of printer with the -d option. (vii) Ability to create
 * output files with the -c option (foo.dvi becomes foo.ps, except on
 * Apollo's). (viii) Supports raw postscript specials and psfig.
 * (ix) Allows 256 character fonts. (ix) Allow reflection commands.
 * (x) Fullpage postscript specials. (xi) Removed Wang's gethelp option
 * and restructured it as a standalone program. (xii) Changed some of the
 * mysterious matrix manipulations in the header to try to align page
 * origin and individual characters along pixel boundaries. (xiii) Fixed
 * header so that all postscript calls are safe---everything works as long
 * as all the commands detailed in the Adobe PS Reference Manual are
 * available. NOTE: Many features can be turned on or off at compile time
 * using -D options in the Makefile.
 *	15 Sept 89: Enabled the -l option, so that it really does create
 * log files. Since this feature had obviously been broken for a long time,
 * I reversed the polarity. That is, the default is no log; specifying -l
 * turns the log file on. This is compatible with the use of Stats and Debug.
 * Added numerous casts to (void) to make lint happy. Current version is
 * very nearly lint-free.
 *	22 Sept 89: Added enhanced page specification options to the -x
 * argument. Can now specify single pages, ranges of pages, and ranges of
 * pages with an option to print every nth page. So two sided copies can
 * be produced.
 *	29 Sept 89: Added twoup postscript option to put two pages side
 * by side on a single page. Made it possible to process command line
 * with getopt (controlled in Makefile at compile time). Gave up on case
 * insensitivity; there are just too many options. Redid log mechanism.
 * Creating a logfile is the default. Errors during command line processing
 * are logged correctly.
 *	11 Oct 89: Packaged everything as Version 2.90. (Not quite optimistic
 * enough to go to 3.00 right away.) Minor chnages to 2.91 to make SCCS happy.
 *	13 Oct 89: Version 2.92.  Changed output routine by replacing all those
 * rmoveto shows by a revised version of the kernshow command from the Adobe
 * Green Book. Single characters output as one-character strings; it's faster
 * to do the computation in C than in PostScript. 
 * Changed Header to admit 256 character fonts.
 * Changed CopyFile so it does NOT transmit control characters.
 * Made preparations to include Oostrum's VM budget and positioning routines.
 * Added "-b" option to override tfmpath.
 * Fixed message regarding creation of logfile.
 * Fixed bug in implementation of FNT1 (didn't skip correctly).
 * Optimized code in GetFontDef, following Oostrum.
 * Installed Wang's new version of gethelp.
 *	19 Oct 89: Reorganized code by introduction of prelim.c. Added
 * ability to put command line options into a setup file in current
 * directory or home directory. Consequently, removed the macintosh code
 * option. All true-false variables are declared to be of type bool 
 * (which is typedef char). Completed merger of two versions
 * of decode args, to make it more maintainable. Moved declaration of
 * most command line variables into the file decode.c. Fixed a minor bug in 
 * logfile mechanism (which made -lc incompatible).
 *	20 Oct 89: Began preparations for merging in Oostrum's version.
 * Here is the section of his change log which differs from the above. It
 * begins after the change dated 23-Sep-85.
 ************** Oostrum's Version ***************************************
 * 29-May-86 (pvo) -- modified to read PK files rather than pxl files
 * 02-Jun-86 (pvo) -- modified to limit VM usage for big characters
 * 10-Jul-86 (pvo) -- modified area handling to include TEXFONTS path
 * 10-Jul-86 (pvo) -- modified positioning to use Knuth's algorithm
				 (more or less)
 * 11-May-87 (pvo) -- general cleanup
 * 13-Mar-87 (lac) -- added -x option for Soton user
 * ??-Mar-87 (lac) -- added pstext \special keyword
 * 18-Mar-87 (lac) -- new version which uses built-in fonts on the Apple
 *		      LaserWriter and allows the use of psfig
 * 12-May-87 (pvo) -- merges (lac) and (pvo) changes
 * 14-May-87 (pvo) -- rewrote tfm file reading
 * 27-May-87 (pvo) -- changed SetString to check for rounding errors
 * 05-Jun-87 (pvo) -- include path search for fontmap and tfm files
 * 06-Nov-87 (pvo) -- enhanced the x option to include ranges.
 * 30-Mar-89 (pvo) -- applied a patch from Mario Wolczko in main
 *                    (case FNT*)
 * 04-Apr-89 (pvo) -- introduced compile time parameter PAPERSIZE
 * 05-Apr-89 (pvo) -- introduced option -P instead of -x (this change was
 *                    lost somewhere)
 * 27-Apr-89 (pvo) -- introduced options -E/-O for even/odd page selection
 * 02-May-89 (pvo) -- restored code for -P option that I removed. It caused
 * 	 	      the -P to fail
 * 22-May-89 (pvo) -- Hack to solve :=) rounding problems with builtin fonts
 * 08-Jun-89 (pvo) -- Bug in fread for pxlfiles in pxlfile.c
 * 13-Jul-89 (pvo) -- Put some code in #ifdef BUILTIN that incorrectly
                      wasn't conditionalized 
 **************************************************************************
 *
 *	25 Oct 89: Added correct positioning algorithm from Oostrum.
 * Added Oostrum's routines to control virtual memory. Modified these so
 * that fonts are flushed and you start over whenever VM usage exceeds
 * 90% of estimated available VM. Necessary(?) so that faster PostScript
 * routines don't get watered down. Modified those routines slightly.
 * Added EvenOnly -E and OddOnly -O options, using my pagelist system.
 * Added option -B so user can select VM budget.
 * Removed -F option.
 * Changed gf reading routines to be more compatible with pk version.
 * Merged the two different versions of PK reading routines into a
 * single more-structured version.
 * Made BUILTIN stuff yet another compile option.
 *
 *	26 Oct 89: Prepared to merge changes from Greg Lee's version.
 * This version began life as a merger of Peter Damron's version 2.10
 * crossed with Piet van Oostrum's version 2.30. Thus it's change log 
 * begins after changes dated 23-Sep-85 (saj) in the main branch, and
 * changes dated 05-Jun-87 (pvo) in Oostrum's branch. Remaining change
 * log is as follows:
 **************************************************************************
 *     Greg Lee merged _some_ of the changes of 2.30 into version
 *     2.10, omitting (rightly or wrongly) the above mentioned
 *     support for built-in fonts (it's done a different way),
 *     positioning code, and the code for reading tfm files.
 *    Feb-87 (gl)  -- native laserwriter fonts.
 *    Mar-87 (gl)  -- fixed bug: don't define non-existent characters.
 *    May-87 (gl)  -- for Specials, just pass text through to ps interpreter.
 *    Dec-87 (gl)  -- added translation of some characters to Adobe encoding.
 *		      fixed bug in SetString that prevented use of characters
 *		        above ascii 127.
 **************************************************************************
 *
 *	27 Oct 89: Merged some of Greg Lee's changes. Used his version of 
 * command line processing with getopt (available as a compile option).
 * Took his ideas for nativefonts and text specials under advisement. Some
 * form of these will be incorporated later. Will not use his idea of
 * concatenating strings and spaces to use widthshow since (i) my kernshow
 * method was faster in test of both equations and text and (ii) it doesn't
 * seem to be compatible with the correct positioning algorithm.
 *	27 Oct 89: Prepared to merge changes from version of JTEX. Their change
 * log agrees with the main branch until the entry dated 23 Sept 85 (saj).
 * Further change log follows:
 **************************************************************************
 * 24-Jun-86 (jfl) -- Support Mac illustrations produced by LaserWriter
 *                    driver 3.0  Changed tex.ps
 *                    Added rotation for \special inclusions
 *                    Embedded ^D are ignored in included PostScript files
 * 14-Mar-87 (ts)  -- added LW buil-in font support and 256 size pxl file
 *		      support.
 *		      no font substitution for now.
 * 12-Jan-88 (ts)  -- added pk font support.
 *
 * Their version also supports ``-o envelope''. OpenOutput assigns priorities
 * to decide which fontfile to close. Changes to char_entry for builtins.
 * Ditto for font_entry. Extra struct openfont_list. Uses gf, pk or pxl.
 * special extensions "lw" and "lwtex". Special prefixes "jis", "dm", "dg"
 * for PK, PXL, or GF fonts.
 **************************************************************************
 *	31 Oct 89: Removed support for TeX reflection commands. Since the
 * DVI format number is different, and since Denenberg's ivd2dvi exists,
 * and since it was too hard to get the positioning algorithm right, this
 * seemed the best course of action.
 * Added support for ``chfont''.
 * Changed SignExtend to be (hopefully) compiler independent.
 *	1 Nov 89: Rewrote \special routines. Can now really handle the old
 * direct psfile options, and is compatible with psfig V 1.2.
 *
 *	7 Nov 89: Reimplemented asian fonts along the lines of JTUG.
 * Should also be compatible with chfont.
 * Removed option of USERELPOS, and made it automatic.
 * Improved documentation---created Installation file.
 *
 *    15 Nov 89: Fixed two bugs. One with positioning and builtin fonts,
 * the other with handling @newfonts, @sf correctly in context of budgeting.
 *
 */
