*******************************************************************************
  File:     @(#)$Id: gs-mods.txt,v 1.1 2002/07/12 16:11:41 tillkamppeter Exp $
  Contents: Suggested changes to ghostscript's source code or configuration
  Author:   Martin Lottermoser, Greifswaldstrasse 28, 38124 Braunschweig,
            Germany. E-mail: Martin.Lottermoser@t-online.de.

*******************************************************************************
*									      *
*	Copyright (C) 1997, 1998, 1999, 2000, 2001 by Martin Lottermoser      *
*	All rights reserved						      *
*									      *
*******************************************************************************

Changes to source code require recompilation of ghostscript, changes to the
configuration files can be made at any time, even after installation.


Changes to Source Code
**********************

 S1 Present ghostscript versions have a bug in make_adjustment_matrix() when
    given significantly positive lower bounds for size ranges in
    "InputAttributes". I have provided an appropriate patch in
    src/zmedia2.c-N.NN.diff. To test for this bug if you already have a working
    binary of ghostscript including the "bit" device, run

      gs -sDEVICE=bit

    on the following PostScript code:

      << /InputAttributes
	<< 0 << /PageSize [ 100 100 700 900 ] >> >>
      >> setpagedevice
      << /PageSize [ 200 300 ] >> setpagedevice
      matrix defaultmatrix ==
      quit

    This tells ghostscript to assume that the device supports media widths
    between 100 and 700 and heights between 100 and 900 bp, and requests a
    page size 200 bp wide and 300 bp tall. Ghostscript should print

      [1.0 0.0 0.0 -1.0 0.0 300.0]

    on standard output if you don't have the bug and

      [1.0 0.0 0.0 -1.0 200.0 0.0]

    if you do. You can use other drivers to test for this, too, but to reliably
    evaluate the result you need information on the driver's device coordinate
    system.

    A simple visual test can be made by replacing the last two lines in the
    program, "matrix ... quit", by

      /Courier findfont 10 scalefont setfont
      100 150 moveto (Hello) show
      showpage

    and running it through a real device driver, preferably for the screen.
    If you have the bug, the page will be empty, if you don't, you'll see
    "Hello" in the middle.

    If you are unsure whether to apply the patch, proceed without it and do
    the test afterwards. The worst which can happen is that you'll have to
    recompile after patching.

    I had reported this bug to L. Peter Deutsch on 1997-12-02. He promised to
    look at it when he would have time. The bug is still present in gs 7.0,
    released more than three years later.

 S2 There is a bug in the UNIX make files for GNU ghostscript 6.51 which leads
    to a failure during "make install" when trying to install the manual pages.
    Add the line

      man1dir = $(mandir)/man$(man1ext)

    to your platform-specific makefile to fix this problem.



Changes to Configuration Files
******************************

 C1 There is a bug in ghostscript's default configuration for the
    undercolour removal and black generation functions. It shows up when
    printing PostScript documents using the RGB colour space ("setrgbcolor" or
    "sethsbcolor") on a device where the CMYK space is the native colour space;
    this is the case for pcl3 if you specify "-sColourModel=CMYK". The bug
    results in black being printed as a mixture of cyan, magenta, and yellow.
    On my printer, this is a slightly greenish grey with fuzzy edges.

    To check for the presence of this bug, run gs on the following command:

      0 0 0 setrgbcolor [ currentcmykcolor ] ==

    gs will issue "[1.0 1.0 1.0 0.0]" on standard output if it would print the
    mixture and "[0.0 0.0 0.0 1.0]" if it would print true black. You should
    specify a CMYK device like "bitcmyk" for this test.

    To correct this behaviour, you'll have to modify gs_init.ps. Look for the
    following lines (starting at line 1263 in AFPL gs 7.0 and at line 1247 in
    GNU ghostscript 6.51):

      % Set the default screen and BG/UCR.
      /.setdefaultbgucr {
	systemdict /setblackgeneration known {
	  { pop 0 } dup setblackgeneration setundercolorremoval
	} if
      } bind def

    Replace the line containing "setundercolorremoval" with the following:

      {} dup setblackgeneration setundercolorremoval

    I had reported this bug to L. Peter Deutsch on 1998-12-09 and he wrote he
    would change the behaviour in the next release. This happened subsequently
    in gs 6.0 (released 2000-02-03), but gs 6.01 reverted to the previous
    behaviour.

 C2 Ghostscript's default configuration prohibits a driver from seeing the
    value of the standard page device parameter "LeadingEdge" if set from
    PostScript; it is only visible if you set it from the command line. This is
    a logical error in ghostscript because (a) "LeadingEdge" fixes the
    orientation between default user space and the feeding direction which is a
    property of the default CTM, and because (b) determining the default CTM in
    ghostscript is the job of the driver-specific get_initial_matrix device
    procedure. Hence the driver must have access to the value of "LeadingEdge".

    To change this, edit the definition of ".presentspecial" in gs_setpd.ps to
    not include "LeadingEdge". Look for the line "/.presentspecial mark" and
    after that for the following lines (starting at line 356 in
    GNU ghostscript 6.51 and at line 355 in AFPL ghostscript 7.0):

     /InputAttributes false
     .inputattrkeys
       { dup /PageSize eq
	  { pop }
	  { { 2 index /InputAttributes .knownget { null eq } { true } ifelse } }
	 ifelse
       }
     forall

    Replace the line containing "PageSize" with the following:

       { dup dup /PageSize eq exch /LeadingEdge eq or

    You need correct this bug only if you wish to set "LeadingEdge" from
    PostScript. This is normally not necessary except when you are using a
    document manager with pcl3's PPD files to print on a custom page size in a
    non-default orientation.

 C3 Unless your default media size is US Letter, it is a good idea to remove
    the "%" comment in the "% (a4)..." line in gs_init.ps in order to set the
    default page size to ISO A4 instead of US Letter (see also Use.htm in the
    ghostscript distribution). This is essential for correctly printing all
    documents not explicitly requesting a page size.

 C4 If you intend to use PostScript resources, you should also edit the
    definitions of "FontResourceDir" and "GenericResourceDir" in gs_res.ps to
    reflect your local conventions. (And if you don't know what I'm talking
    about you don't need it.)
