diff options
-rw-r--r-- | gs/Resource/Init/gs_init.ps | 61 | ||||
-rw-r--r-- | gs/Resource/Init/gs_setpd.ps | 7 | ||||
-rw-r--r-- | gs/Resource/Init/gs_statd.ps | 45 |
3 files changed, 47 insertions, 66 deletions
diff --git a/gs/Resource/Init/gs_init.ps b/gs/Resource/Init/gs_init.ps index 354966049..9a2a5136a 100644 --- a/gs/Resource/Init/gs_init.ps +++ b/gs/Resource/Init/gs_init.ps @@ -1752,27 +1752,20 @@ defaultdevice % If the paper size is not specifed and the device defaults to % letter or A4 paper, select the DEFAULTPAPERSIZE. -systemdict /DEFAULTPAPERSIZE known not - { - % Use .defaultpapersize if it returns a known paper size - .defaultpapersize - { - false statusdict /.pagetypenames get - { - 2 index eq { pop true exit } if - } - forall - {systemdict exch /DEFAULTPAPERSIZE exch put} - {QUIET - { pop } - { (Unknown .defaultpapersize: ) print ==only (.) = } - ifelse - } - ifelse - } - if - } -if +systemdict /DEFAULTPAPERSIZE known not { + % Use .defaultpapersize if it returns a known paper size + .defaultpapersize { + statusdict /.pagetypeprocs get 1 index known { + systemdict exch /DEFAULTPAPERSIZE exch put + } { + QUIET { + pop + } { + (Unknown .defaultpapersize: ) print ==only (.) = + } ifelse + } ifelse + } if +} if systemdict /DEFAULTPAPERSIZE known systemdict /PAPERSIZE known not and systemdict /DEVICEWIDTH known not and @@ -1805,23 +1798,15 @@ systemdict /PAPERSIZE known systemdict /DEVICEWIDTH known not and systemdict /DEVICEHEIGHT known not and systemdict /DEVICEWIDTHPOINTS known not and -systemdict /DEVICEHEIGHTPOINTS known not and - { % Convert the paper size to device dimensions. - true statusdict /.pagetypenames get - { PAPERSIZE eq - { PAPERSIZE load - dup 0 get /DEVICEWIDTHPOINTS exch def - 1 get /DEVICEHEIGHTPOINTS exch def - pop false exit - } - if - } - forall - { (Unknown paper size: ) print PAPERSIZE ==only (.) = - } - if - } -if +systemdict /DEVICEHEIGHTPOINTS known not and { + % Convert the paper size to device dimensions. + statusdict /.pagetypeprocs get PAPERSIZE .knownget { + dup 0 get /DEVICEWIDTHPOINTS exch def + 1 get /DEVICEHEIGHTPOINTS exch def + } { + (Unknown paper size: ) print PAPERSIZE ==only (.) = + } ifelse +} if % Adjust the device parameters per the command line. % It is possible to specify resolution, pixel size, and page size; % since any two of these determine the third, conflicts are possible. diff --git a/gs/Resource/Init/gs_setpd.ps b/gs/Resource/Init/gs_setpd.ps index fc0a61a7b..3e6de3a75 100644 --- a/gs/Resource/Init/gs_setpd.ps +++ b/gs/Resource/Init/gs_setpd.ps @@ -201,11 +201,14 @@ level2dict begin % First put the device's default page size in slot 0 % This satifies those that have devices built with a4 as the default 0 mark /PageSize currentdevice /PageSize gsgetdeviceprop .dicttomark + statusdict /.pagetypenames get { + statusdict /.pagetypeprocs get + exch get 0 2 getinterval cvlit counttomark 1 sub 2 idiv exch mark exch /PageSize exch - % stack: mark --dict-- --dict-- ... key mark /PageSize pagetypename + % stack: mark --dict-- --dict-- ... key mark /PageSize [x y] % see note above about pagetype executable array contents. - load dup 0 get exch 1 get 2 array astore .dicttomark + .dicttomark } forall % If NORANGEPAGESIZE is defined, (-dNORANGEPAGESIZE), then don't add % the 'match any' PageSize entry diff --git a/gs/Resource/Init/gs_statd.ps b/gs/Resource/Init/gs_statd.ps index ad0022829..21007e620 100644 --- a/gs/Resource/Init/gs_statd.ps +++ b/gs/Resource/Init/gs_statd.ps @@ -22,21 +22,27 @@ systemdict begin % We make statusdict a little larger for Level 2 stuff. % Note that it must be allocated in local VM. .currentglobal false .setglobal - /statusdict 89 dict .forcedef % statusdict is local, sys'dict global + /statusdict 91 dict .forcedef % statusdict is local, sys'dict global % To support the Level 2 job control features, % serverdict must also be in local VM. /serverdict 10 dict .forcedef % serverdict is local, sys'dict global .setglobal end +statusdict begin + +% Keep the table of named paper sizes as procedures. Reuse them later +% as compatibility operators. +/.pagetypeprocs 70 dict begin + % Define various paper formats. The Adobe documentation defines only these: % 11x17, a3, a4, a4small, b5, ledger, legal, letter, lettersmall, note. % These procedures are also accessed as data structures during initialization, % so the page dimensions must be the first two elements of the procedure. /.setpagesize { /statusdict .systemvar begin .setpagesize end } bind def -userdict begin - % Page sizes defined by Adobe documentation + + % Page sizes defined by Adobe documentation % Note: these executable arrays should all begin with two % integers which are the width and height (see gs_setpd.ps). /11x17 {792 1224 //.setpagesize exec} bind def % 11x17 portrait @@ -120,30 +126,16 @@ STRICT { (%END SIZES) .skipeof } if /ANSI_E {2448 3168 //.setpagesize exec} bind def /ANSI_F {2016 2880 //.setpagesize exec} bind def %END SIZES -end -currentdict /.setpagesize .undef - -statusdict begin +currentdict end +dup /.setpagesize .undef +userdict begin dup { def } forall end % reuse! +readonly def % Define the pagetype values for the known page formats. -% The values for all but letter and note are arbitrary. -/.pagetypenames - [ /letter /note %do not change this line, needed by 'setpagetype' - /legal /lettersmall - /11x17 /ledger - /a4small /a3 /a4 -STRICT { (%END SIZES) .skipeof } if - /a0 /a1 /a2 /a5 /a6 /a7 /a8 /a9 /a10 - /archA /archB /archC /archD /archE - /b0 /b1 /b2 /b3 /b4 /b5 /b6 - /c0 /c1 /c2 /c3 /c4 /c5 /c6 - /flsa /flse /halfletter - /isob0 /isob1 /isob2 /isob3 /isob4 /isob5 /isob6 - /jisb0 /jisb1 /jisb2 /jisb3 /jisb4 /jisb5 /jisb6 - /pa4 /hagaki - /ANSI_A /ANSI_B /tabloid /ANSI_C /ANSI_D /ANSI_E /ANSI_F -%END SIZES - ] readonly def +% This array is now used for deterministic enumeration of .pagetypeprocs +/.pagetypenames [ .pagetypeprocs { pop } bind forall ] + { .namestring exch .namestring gt } bind .sort + readonly def %%%%%% The following items were suggested by a user as useful. @@ -270,11 +262,12 @@ STRICT { (%END SIZES) .skipeof } if % The Adobe documentation only defines setpagetype % (a Level 1 operator) as accepting the values 0 and 1, % so we do too. - dup .pagetypenames 0 2 getinterval exch get + {/letter /note} 1 index get //systemdict /userdict get exch get cvx exec /pagetype exch def end } bind def + /setpassword {exch checkpassword {statusdict exch /.password exch put true} |