Default page size

"Russell Lang" <[email protected]> Wed, 16 Feb 2005 13:23:37 +1100
Newsgroups gmane.comp.printing.ghostscript.patches
Message-ID <42134959.27068.380413EF@localhost>
Notes:
Do we want DEFAULTPAPERSIZE to be documented, or internal to 
gs_init.ps?
Should the "/DEFAULTPAGESIZE (a4) def" be put in a separate file
to make it easy for distributions to change?
For 8_1X and HEAD.


Log Message:

Set the default paper size with DEFAULTPAPERSIZE in gs_init.ps,
which only affects devices that default to A4 or letter paper.
This avoids inappropriately setting the bbox device to
A4 or letter size.

DETAILS:
Some linux distributions change the default paper size 
to A4 by uncommenting the following line in gs_init.ps.
  % Optionally choose a default paper size other than U.S. letter.
  % (a4) /PAPERSIZE where { pop pop } { /PAPERSIZE exch def } ifelse

Unfortunately this sets the default paper size for all devices,
including the bbox device for which this is not appropriate.
If the bbox device is set to A4 paper and drawing occurs
outside this area, the bbox device will report an incorrect
bounding box.  There may be custom printer devices which don't 
support A4 or letter paper.

The default paper size is now set with DEFAULTPAPERSIZE,
which sets PAPERSIZE only if the paper size is not otherwise
set, the device defaulted to A4 or letter.



Russell Lang                   [email protected]
Ghostgum Software Pty Ltd      http://www.ghostgum.com.au/

_______________________________________________
gs-code-review mailing list
[email protected]
http://www.ghostscript.com/mailman/listinfo/gs-code-review
defpage2.txt (application/octet-stream, 2.3 KB)
*** l:/cvs/gs/lib/gs_init.ps	Sat Jan 08 03:04:31 2005
--- lib/gs_init.ps	Sat Jan 08 03:40:30 2005
***************
*** 64,70 ****
  systemdict /.languagelevel known not { /.languagelevel 1 def } if
  
  % Optionally choose a default paper size other than U.S. letter.
! % (a4) /PAPERSIZE where { pop pop } { /PAPERSIZE exch def } ifelse
  
  % Turn on array packing for the rest of initialization.
  true setpacking
--- 64,78 ----
  systemdict /.languagelevel known not { /.languagelevel 1 def } if
  
  % Optionally choose a default paper size other than U.S. letter.
! % The default page size for many devices is set at compile time to 
! % letter, but this can be changed to A4 although this is rarely done.  
! % Some devices such as bbox have a different default page size,
! % and should not be set to A4 or letter.
! % When ghostscript is used in countries that use the international
! % standard page size A4 rather than US letter, the page size of 
! % devices that default to letter or A4 can be changed by setting
! % DEFAULTPAPERSIZE.
! % /DEFAULTPAPERSIZE (a4) def
  
  % Turn on array packing for the rest of initialization.
  true setpacking
***************
*** 1678,1683 ****
--- 1686,1713 ----
  % and it is a bad idea because it prevents setting the resolution in this
  % situation, which pstoedit (among other programs) relies on.
  %DISPLAYING not { setdevice (%END DISPLAYING) .skipeof } if
+ 
+ % If the paper size is not specifed and the device defaults to 
+ % letter or A4 paper, select the DEFAULTPAPERSIZE.
+ systemdict /DEFAULTPAPERSIZE known
+ systemdict /PAPERSIZE known not and
+ systemdict /DEVICEWIDTH known not and
+ systemdict /DEVICEHEIGHT known not and
+ systemdict /DEVICEWIDTHPOINTS known not and
+ systemdict /DEVICEHEIGHTPOINTS known not and
+  {
+    defaultdevice mark /PageSize //null .dicttomark .getdeviceparams 
+    .dicttomark /PageSize get
+    dup 0 get 0.5 add cvi 612 eq 1 index 1 get 0.5 add cvi 792 eq and
+    1 index 0 get 0.5 add cvi 595 eq 2 index 1 get 0.5 add cvi 842 eq and
+    or exch pop
+    {
+      % the default paper size was letter, so replace it with DEFAULTPAPERSIZE
+      /PAPERSIZE DEFAULTPAPERSIZE def
+    } if
+  }
+ if
+ 
  systemdict /DEVICEWIDTH known
  systemdict /DEVICEHEIGHT known or
  systemdict /DEVICEWIDTHPOINTS known or