]> git.lizzy.rs Git - plan9front.git/blob - sys/lib/ghostscript/gsnup.ps
etherbcm: handle 64-bit host addresses, use PCIWADDR() instead of PADDR()
[plan9front.git] / sys / lib / ghostscript / gsnup.ps
1 %!
2 %    Copyright (C) 1999 Aladdin Enterprises.  All rights reserved.
3
4 % This software is provided AS-IS with no warranty, either express or
5 % implied.
6
7 % This software is distributed under license and may not be copied,
8 % modified or distributed except as expressly authorized under the terms
9 % of the license contained in the file LICENSE in this distribution.
10
11 % For more information about licensing, please refer to
12 % http://www.ghostscript.com/licensing/. For information on
13 % commercial licensing, go to http://www.artifex.com/licensing/ or
14 % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
15 % San Rafael, CA  94903, U.S.A., +1(415)492-9861.
16
17 % $Id: gsnup.ps,v 1.5 2005/06/07 19:24:33 ray Exp $
18 % Prefix this to very well-behaved PostScript files for n-up printing.
19
20 /cdef { 1 index where { pop pop } { def } ifelse } def
21
22 %%%%%%%%%%%%%%%% Begin parameters %%%%%%%%%%%%%%%%
23
24 % All parameters are also settable from the command line with -d, e.g.,
25 % -d.Nx=3
26
27 /.Nx 2 cdef                     % # of pages across the physical page
28 /.Ny 2 cdef                     % # of pages down the physical page
29 /.Landscape false cdef          % if true, rotate page by 90 degrees
30
31 %%%%%%%%%%%%%%%% End parameters %%%%%%%%%%%%%%%%
32
33 vmstatus pop pop 0 eq { save pop } if
34 .Landscape {
35   currentpagedevice /PageSize get aload pop
36   exch 2 array astore
37   1 dict dup /PageSize 4 -1 roll put
38   setpagedevice
39 } if
40 /.BP currentpagedevice /BeginPage get def
41 /.EP currentpagedevice /EndPage get def
42 /.Ps 1 string def       % survive save/restore
43 /.Pn { .Ps 0 get } def
44 true setglobal          % protect from restore
45 /.ELevel [0] def
46 /.Rmat matrix def
47 false setglobal
48 /.max { 2 copy lt { exch } if pop } cdef
49 % Work around the common save ... showpage ... restore locution.
50 /restore {
51   .Rmat currentmatrix pop restore
52   vmstatus pop pop .ELevel 0 get lt { .Rmat setmatrix } if
53 } bind def
54 <<
55   /BeginPage {
56     .Nx .Ny .max
57     gsave
58       initclip clippath pathbbox exch 4 -1 roll sub 3 1 roll exch sub
59     grestore
60     2 copy exch .Nx div exch .Ny div
61     .Pn dup .Nx mod exch .Nx idiv .Ny 1 sub exch sub
62                 % Stack: nmax pw ph pw/nx ph/ny ix iy
63     exch 3 index mul exch 2 index mul
64     translate
65                 % Stack: nmax pw ph pw/nx ph/ny
66     4 -1 roll 4 index div 4 -1 roll 4 index div
67                 % Stack: nmax pw/nx ph/ny pw/nmax ph/nmax
68     exch 4 -1 roll exch sub 2 div
69     3 1 roll sub 2 div
70     translate
71                 % Stack: nmax
72     1 exch div dup scale
73     .BP
74   }
75   /EndPage {
76     dup 2 lt {
77       .ELevel 0 vmstatus pop pop put
78       .Ps 0 .Pn 1 add .Nx .Ny mul mod put    
79       .Pn 0 eq {
80         .EP
81       } {
82         pop pop false
83       } ifelse
84     } {
85       pop pop false
86     } ifelse
87   }
88 >> setpagedevice
89 /.EOJ {
90   { .Pn 0 eq { exit } if showpage } loop
91 } def
92
93 { currentfile cvx exec .EOJ } exec