summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlgs/Resource/Init/gs_setpd.ps
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/tlgs/Resource/Init/gs_setpd.ps')
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_setpd.ps670
1 files changed, 322 insertions, 348 deletions
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_setpd.ps b/Master/tlpkg/tlgs/Resource/Init/gs_setpd.ps
index e22597ebb5f..f84a495e37a 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_setpd.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_setpd.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2018 Artifex Software, Inc.
+% Copyright (C) 2001-2019 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -18,45 +18,8 @@
languagelevel 1 .setlanguagelevel
level2dict begin
-
% ---------------- Redefinitions ---------------- %
-% Redefine .beginpage and .endpage so that they call BeginPage and
-% EndPage respectively if appropriate.
-
-% We have to guard against the BeginPage procedure not popping its operand.
-% This is really stupid, but the Genoa CET does it.
-/.beginpage { % - .beginpage -
- .currentshowpagecount {
- .currentpagedevice pop
- dup //null ne { /BeginPage .knownget } { pop //false } ifelse {
- % Stack: ... pagecount proc
- count 2 .execn
- % Stack: ... ..???.. oldcount
- count 1 add exch sub { pop } repeat
- } {
- pop
- } ifelse
- } if
-} bind odef
-
-% Guard similarly against EndPage not popping its operand.
-/.endpage { % <reason> .endpage <print_bool>
- .currentshowpagecount {
- 1 index .currentpagedevice pop
- dup //null ne { /EndPage .knownget } { pop //false } ifelse {
- % Stack: ... reason pagecount reason proc
- count 2 .execn
- % Stack: ... ..???.. print oldcount
- count 2 add exch sub { exch pop } repeat
- } {
- pop pop 2 ne
- } ifelse
- } {
- 2 ne
- } ifelse
-} bind odef
-
% Define interpreter callouts for handling gstate-saving operators,
% to make sure that they create a page device dictionary for use by
% the corresponding gstate-restoring operator.
@@ -91,12 +54,258 @@ level2dict begin
% %restorepagedevice, %restore1pagedevice, and %setgstatepagedevice
% are known to the interpreter.
+% ---------------- Keys and Attributes ---------------- %
+
+% We have to deal specially with entries that the driver may change
+% on its own. We also have to deal specially with parameters which the device may
+% change on its own but which we *also* want to transmit to the device. Previously
+% any parameter which was 'dynamic' would not be sent to the device, making it
+% impossible to set a parameter, and later have the device change it. Currently
+% only OutputICCProfile fits this category.
+% This whole area is broken its completely the wrong way round from the way the spec says it should work.
+
+% This dictionary contains the keys we never want to set.
+/.readonlypdkeys mark
+ /.MediaSize dup % because it changes when PageSize is set
+ /PageCount dup
+ /Colors dup
+ /BitsPerPixel dup
+ /ColorValues dup
+.dicttomark readonly def
+
+% Bonkers, but needed by our ridiculous setpagedevice implementation. There are
+% some keys (at the moment, RedValues, GreenValues and BlueValues are known) which
+% only exist in the page device dictionary under some conditions (ProcessColorModel == DeviceRGB)
+% If we change the conditions, so that these keys are no longer present in the params
+% returned by the device, sending these keys to the device can trigger a fault.
+% This is a problem because of our stored dictionary:
+%
+% 1) Set up the inital dictioanry by retrieving the params from the device
+% 2) Change the conditions (ProcessColorModel == DeviceGray)
+% 3) merge any volatile keys from the device. Note that RedValues etc no longer defined.
+% 4) Call .installpagdevice, use the stored dicitonary to set the params
+% 5) The stored RedValues etc, cause an error.
+%
+% The stored dictioanry is readonly (we use forceput to wedge new keys into it) so
+% we can't 'undef' keys from it. (the dictionary is made readonly by the action of zsetpagedevice
+% '.setpagedevice' in PostScrfipt)
+%
+% So the only solution is to have 'write only' keys. These can be written to the device
+% but are not stored in the saved page device dictionary. This means PostScript programs
+% can't interrogate and take action on these, but there's no solution to that except to
+% rewrite this stuff completely so that it actually works properly.
+
+/.writeonlykeys mark
+ /RedValues dup % Set by the device when ProcessColorModel changes
+ /GreenValues dup % Set by the device when ProcessColorModel changes
+ /BlueValues dup % Set by the device when ProcessColorModel changes
+ /GrayValues dup % Set by the device when ProcessColorModel changes
+.dicttomark readonly def
+
+% This dictionary contains the keys we always want to read back from the device.
+/.volatilepdkeys mark
+ /.MediaSize dup % because it changes when PageSize is set
+ /RedValues dup % Set by the device when ProcessColorModel changes
+ /GreenValues dup % Set by the device when ProcessColorModel changes
+ /BlueValues dup % Set by the device when ProcessColorModel changes
+ /GrayValues dup % Set by the device when ProcessColorModel changes
+ /PageCount dup
+ /Colors dup
+ /BitsPerPixel dup
+ /ColorValues dup
+ /OutputICCProfile dup % ColorConversionStrategy can change this
+.dicttomark readonly def
+
+% The implementation of setpagedevice is quite complex. Currently,
+% everything but the media matching algorithm is implemented here.
+
+% By default, we only present the requested changes to the device,
+% but there are some parameters that require special merging action.
+% Define those parameters here, with the procedures that do the merging.
+% The procedures are called as follows:
+% <merged> <key> <new_value> -proc- <merged> <key> <new_value'>
+/.mergespecial mark
+ /InputAttributes
+ { dup //null eq
+ { pop //null
+ }
+ { 3 copy pop .knownget
+ { dup //null eq
+ { pop dup length dict }
+ { dup length 2 index length add dict .copydict }
+ ifelse
+ }
+ { dup length dict
+ }
+ ifelse .copydict readonly
+ }
+ ifelse
+ } bind
+ /OutputAttributes 1 index
+ /Policies
+ { 3 copy pop .knownget
+ { dup length 2 index length add dict .copydict }
+ { dup length dict }
+ ifelse copy readonly
+ } bind
+.dicttomark readonly def
+
+% M. Sweet, Easy Software Products:
+%
+% Define NOMEDIAATTRS to turn off the default (but unimplementable) media
+% selection policies for setpagedevice. This is used by CUPS to support
+% the standard Adobe media attributes.
+NOMEDIAATTRS {
+ % Define only PageSize for input attribute matching.
+ /.inputattrkeys [
+ /PageSize
+ ] readonly def
+ % Define no other keys used in media selection.
+ /.inputselectionkeys [
+ /noInputSelectionsKeys
+ ] readonly def
+
+ % Define no keys used in output attribute matching.
+ /.outputattrkeys [
+ /noOutputAttrKeys
+ ] readonly def
+} {
+ % Define the keys used in input attribute matching.
+ /.inputattrkeys [
+ /PageSize /MediaColor /MediaWeight /MediaType /InsertSheet /ManualFeed
+ % The following are documented in Adobe's supplement for v2017.
+ /LeadingEdge /MediaClass
+ ] readonly def
+ % Define other keys used in media selection.
+ /.inputselectionkeys [
+ /MediaPosition /Orientation
+ ] readonly def
+
+ % Define the keys used in output attribute matching.
+ /.outputattrkeys [
+ /OutputType
+ ] readonly def
+} ifelse
+
+% Define all the parameters that should always be copied to the merged
+% dictionary.
+/.copiedkeys [
+ /OutputDevice
+ //.mergespecial { pop } forall
+ .inputattrkeys aload pop
+ .inputselectionkeys aload pop
+ .outputattrkeys aload pop
+] readonly def
+
+% Define the parameters that should not be presented to the device.
+% The procedures are called as follows:
+% <merged> <key> <value> -proc-
+% The procedure leaves all its operands on the stack and returns
+% true iff the key/value pair should be presented to .putdeviceparams.
+/.presentspecial mark
+ .readonlypdkeys
+ { pop //false }
+ forall
+ % We must ignore an explicit request for .MediaSize,
+ % because media matching always handles this.
+ /.MediaSize //false
+ /Name //false
+ /OutputDevice //false
+ /PageDeviceName //false
+ /PageOffset //false
+ /PageSize //false % obsolete alias for .MediaSize
+ /InputAttributes //false
+ .inputattrkeys
+ { dup dup /PageSize eq exch /LeadingEdge eq or
+ { pop }
+ { { 2 index /InputAttributes .knownget { //null eq } { //true } ifelse } }
+ ifelse
+ }
+ forall
+ .inputselectionkeys { //false } forall
+ /OutputAttributes //false
+ .outputattrkeys
+ { { 2 index /OutputAttributes .knownget { //null eq } { //true } ifelse } }
+ forall
+ /Install //false
+ /BeginPage //false
+ /EndPage //false
+ /Policies //false
+ % Our extensions:
+ /HWColorMap
+ { % HACK: don't transmit the color map, because
+ % window systems can change the color map on their own
+ % incrementally. Someday we'll have a better
+ % solution for this....
+ //false
+ }
+ /ViewerPreProcess //false
+ /ImagingBBox //false % This prevents the ImagingBBox value in the setpagedevice
+ % from affecting the device's ImagingBBox parameter, but
+ % does retain a 'shadow' copy at the PostScript level.
+ % This is done for Adobe compatibility since Adobe does
+ % render marks outside the ImagingBBox (and QuarkXpress
+ % relies on it).
+.dicttomark readonly def
+
+% ---------------- End Keys and Attributes ---------------- %
+
+% Prepare to present parameters to the device, by spreading them onto the
+% operand stack and removing any that shouldn't be presented.
+/.prepareparams % <params> .prepareparams -mark- <key1> <value1> ...
+ { mark exch dup
+ { % Stack: -mark- key1 value1 ... merged key value
+ //.presentspecial 2 index .knownget
+ { exec { 3 -1 roll } { pop pop } ifelse }
+ { 3 -1 roll }
+ ifelse
+ }
+ forall pop
+ } bind def
+
+currentdict /.presentspecial .undef
+
+% Compute the media size and initial matrix from a merged request (after
+% media selection).
+/.computemediasize % <request> .computemediasize
+ % <request> <matrix> <[width height]>
+ { dup /PageSize get % requested page size
+ 1 index /InputAttributes get
+ 2 index (%MediaSource) get get /PageSize get % media size
+ % (may be a range)
+ 2 index /Policies get
+ dup /PageSize .knownget
+ { exch pop } { /PolicyNotFound get } ifelse % PageSize policy,
+ % affects scaling
+ 3 index /Orientation .knownget not { //null } if
+ 4 index /RollFedMedia .knownget not { //false } if
+ matrix .matchpagesize not {
+ % This is a "can't happen" condition!
+ /setpagedevice .systemvar /rangecheck signalerror
+ } if
+ 2 array astore
+ } bind def
+
+% Try setting the device parameters from the merged request.
+/.trysetparams % <merged> <(ignored)> <device> <Policies>
+ % .trysetparams
+ { //true 4 index //.prepareparams exec
+ % Add the computed .MediaSize.
+ % Stack: merged (ignored) device Policies -true-
+ % -mark- key1 value1 ...
+ counttomark 5 add index //.computemediasize exec
+ exch pop exch pop /.MediaSize exch
+SETPDDEBUG { (Putting.) = pstack flush } if
+ .putdeviceparamsonly
+SETPDDEBUG { (Result of putting.) = pstack flush } if
+ } bind executeonly odef
+
/.installpagedevice
{ % Since setpagedevice doesn't create new device objects,
% we must (carefully) reinstall the old parameters in
% the same device.
.currentpagedevice pop //null currentdevice //null
- { .trysetparams } .internalstopped
+ { //.trysetparams } //.internalstopped exec
{
//null
} if
@@ -104,7 +313,7 @@ level2dict begin
{ pop pop }
{
SETPDDEBUG { (Error in .trysetparams!) = pstack flush } if
- {cleartomark pop pop pop} .internalstopped pop
+ {cleartomark pop pop pop} //.internalstopped exec pop
% if resetting the entire device state failed, at least put back the
% security related key
currentdevice //null //false mark /.LockSafetyParams
@@ -121,46 +330,33 @@ level2dict begin
/.uninstallpagedevice
{
- {2 .endpage { .currentnumcopies //false .outputpage } if} .internalstopped pop
+ {2 .endpage { .currentnumcopies //false .outputpage } if} //.internalstopped exec pop
nulldevice
- } bind def
+ } bind executeonly def
(%grestorepagedevice) cvn
{
.uninstallpagedevice
grestore
- .installpagedevice
+ //.installpagedevice exec
} bind def
(%grestoreallpagedevice) cvn
- { .uninstallpagedevice grestore .installpagedevice grestoreall
+ { .uninstallpagedevice grestore //.installpagedevice exec grestoreall
} bind def
(%restore1pagedevice) cvn
- { .uninstallpagedevice grestore .installpagedevice restore
+ { .uninstallpagedevice grestore //.installpagedevice exec restore
} bind def
(%restorepagedevice) cvn
- { .uninstallpagedevice restore .installpagedevice
+ { .uninstallpagedevice restore //.installpagedevice exec
} bind def
(%setgstatepagedevice) cvn
- { .uninstallpagedevice setgstate .installpagedevice
+ { .uninstallpagedevice setgstate //.installpagedevice exec
} bind def
-% Redefine .currentnumcopies so it consults the NumCopies device parameter.
-/.numcopiesdict mark
- /NumCopies dup
-.dicttomark readonly def
-
-/.currentnumcopies
- { currentdevice //.numcopiesdict .getdeviceparams
- dup type /integertype eq
- { exch pop exch pop }
- { cleartomark #copies }
- ifelse
- } bind odef
-
% Redefine .currentpagedevice and .setpagedevice so they convert between
% null and a fixed empty directionary.
/.nullpagedevice 0 dict readonly def
@@ -258,77 +454,17 @@ level2dict begin
% Define currentpagedevice so it creates the dictionary on demand if needed,
% adding all the required entries defined just above.
-% We have to deal specially with entries that the driver may change
-% on its own. We also have to deal specially with parameters which the device may
-% change on its own but which we *also* want to transmit to the device. Previously
-% any parameter which was 'dynamic' would not be sent to the device, making it
-% impossible to set a parameter, and later have the device change it. Currently
-% only OutputICCProfile fits this category.
-% This whole area is broken its completely the wrong way round from the way the spec says it should work.
-
-% This dictionary contains the keys we never want to set.
-/.readonlypdkeys mark
- /.MediaSize dup % because it changes when PageSize is set
- /PageCount dup
- /Colors dup
- /BitsPerPixel dup
- /ColorValues dup
-.dicttomark readonly def
-
-% Bonkers, but needed by our ridiculous setpagedevice implementation. There are
-% some keys (at the moment, RedValues, GreenValues and BlueValues are known) which
-% only exist in the page device dictionary under some conditions (ProcessColorModel == DeviceRGB)
-% If we change the conditions, so that these keys are no longer present in the params
-% returned by the device, sending these keys to the device can trigger a fault.
-% This is a problem because of our stored dictionary:
-%
-% 1) Set up the inital dictioanry by retrieving the params from the device
-% 2) Change the conditions (ProcessColorModel == DeviceGray)
-% 3) merge any volatile keys from the device. Note that RedValues etc no longer defined.
-% 4) Call .installpagdevice, use the stored dicitonary to set the params
-% 5) The stored RedValues etc, cause an error.
-%
-% The stored dictioanry is readonly (we use forceput to wedge new keys into it) so
-% we can't 'undef' keys from it. (the dictionary is made readonly by the action of zsetpagedevice
-% '.setpagedevice' in PostScrfipt)
-%
-% So the only solution is to have 'write only' keys. These can be written to the device
-% but are not stored in the saved page device dictionary. This means PostScript programs
-% can't interrogate and take action on these, but there's no solution to that except to
-% rewrite this stuff completely so that it actually works properly.
-
-/.writeonlykeys mark
- /RedValues dup % Set by the device when ProcessColorModel changes
- /GreenValues dup % Set by the device when ProcessColorModel changes
- /BlueValues dup % Set by the device when ProcessColorModel changes
- /GrayValues dup % Set by the device when ProcessColorModel changes
-.dicttomark readonly def
-
-% This dictionary contains the keys we always want to read back from the device.
-/.volatilepdkeys mark
- /.MediaSize dup % because it changes when PageSize is set
- /RedValues dup % Set by the device when ProcessColorModel changes
- /GreenValues dup % Set by the device when ProcessColorModel changes
- /BlueValues dup % Set by the device when ProcessColorModel changes
- /GrayValues dup % Set by the device when ProcessColorModel changes
- /PageCount dup
- /Colors dup
- /BitsPerPixel dup
- /ColorValues dup
- /OutputICCProfile dup % ColorConversionStrategy can change this
-.dicttomark readonly def
-
/.makecurrentpagedevice { % - .makecurrentpagedevice <dict>
currentdevice //null .getdeviceparams
% Make the dictionary large enough to add defaulted entries.
- counttomark 2 idiv .requiredattrs length add dict
+ counttomark 2 idiv //.requiredattrs length add dict
counttomark 2 idiv { dup 4 2 roll put } repeat exch pop
% Add any missing required attributes.
% Make a writable and (if possible) local copy of any default
% dictionaries, to work around a bug in the output of WordPerfect,
% which assumes that these dictionaries are writable and local.
.currentglobal exch dup gcheck .setglobal
- .requiredattrs {
+ //.requiredattrs {
2 index 2 index known {
1 index /Policies eq {
% Merge policies from the device driver with defaults
@@ -355,10 +491,18 @@ level2dict begin
.writeonlykeys {2 index exch undef pop} forall
dup .setpagedevice
} bind def
+
+% Copy a dictionary recursively.
+/.copytree { % <dict> .copytree <dict'>
+ dup length dict exch {
+ dup type /dicttype eq { .copytree } if 2 index 3 1 roll put
+ } forall
+} bind def
+
/currentpagedevice {
.currentpagedevice {
dup length 0 eq {
- pop .makecurrentpagedevice
+ pop //.makecurrentpagedevice exec
} {
% If any of the dynamic keys have changed,
% we must update the page device dictionary.
@@ -407,7 +551,7 @@ level2dict begin
3 -1 roll dup length dict .copydict
3 1 roll
} if
- .copytree 2 index 3 1 roll put
+ //.copytree exec 2 index 3 1 roll put
} {
pop pop
} ifelse
@@ -426,145 +570,6 @@ level2dict begin
} if
} bind odef
-% Copy a dictionary recursively.
-/.copytree { % <dict> .copytree <dict'>
- dup length dict exch {
- dup type /dicttype eq { .copytree } if 2 index 3 1 roll put
- } forall
-} bind def
-
-% The implementation of setpagedevice is quite complex. Currently,
-% everything but the media matching algorithm is implemented here.
-
-% By default, we only present the requested changes to the device,
-% but there are some parameters that require special merging action.
-% Define those parameters here, with the procedures that do the merging.
-% The procedures are called as follows:
-% <merged> <key> <new_value> -proc- <merged> <key> <new_value'>
-/.mergespecial mark
- /InputAttributes
- { dup //null eq
- { pop //null
- }
- { 3 copy pop .knownget
- { dup //null eq
- { pop dup length dict }
- { dup length 2 index length add dict .copydict }
- ifelse
- }
- { dup length dict
- }
- ifelse .copydict readonly
- }
- ifelse
- } bind
- /OutputAttributes 1 index
- /Policies
- { 3 copy pop .knownget
- { dup length 2 index length add dict .copydict }
- { dup length dict }
- ifelse copy readonly
- } bind
-.dicttomark readonly def
-
-% M. Sweet, Easy Software Products:
-%
-% Define NOMEDIAATTRS to turn off the default (but unimplementable) media
-% selection policies for setpagedevice. This is used by CUPS to support
-% the standard Adobe media attributes.
-NOMEDIAATTRS {
- % Define only PageSize for input attribute matching.
- /.inputattrkeys [
- /PageSize
- ] readonly def
- % Define no other keys used in media selection.
- /.inputselectionkeys [
- /noInputSelectionsKeys
- ] readonly def
-
- % Define no keys used in output attribute matching.
- /.outputattrkeys [
- /noOutputAttrKeys
- ] readonly def
-} {
- % Define the keys used in input attribute matching.
- /.inputattrkeys [
- /PageSize /MediaColor /MediaWeight /MediaType /InsertSheet /ManualFeed
- % The following are documented in Adobe's supplement for v2017.
- /LeadingEdge /MediaClass
- ] readonly def
- % Define other keys used in media selection.
- /.inputselectionkeys [
- /MediaPosition /Orientation
- ] readonly def
-
- % Define the keys used in output attribute matching.
- /.outputattrkeys [
- /OutputType
- ] readonly def
-} ifelse
-
-% Define all the parameters that should always be copied to the merged
-% dictionary.
-/.copiedkeys [
- /OutputDevice
- .mergespecial { pop } forall
- .inputattrkeys aload pop
- .inputselectionkeys aload pop
- .outputattrkeys aload pop
-] readonly def
-
-% Define the parameters that should not be presented to the device.
-% The procedures are called as follows:
-% <merged> <key> <value> -proc-
-% The procedure leaves all its operands on the stack and returns
-% true iff the key/value pair should be presented to .putdeviceparams.
-/.presentspecial mark
- .readonlypdkeys
- { pop //false }
- forall
- % We must ignore an explicit request for .MediaSize,
- % because media matching always handles this.
- /.MediaSize //false
- /Name //false
- /OutputDevice //false
- /PageDeviceName //false
- /PageOffset //false
- /PageSize //false % obsolete alias for .MediaSize
- /InputAttributes //false
- .inputattrkeys
- { dup dup /PageSize eq exch /LeadingEdge eq or
- { pop }
- { { 2 index /InputAttributes .knownget { //null eq } { //true } ifelse } }
- ifelse
- }
- forall
- .inputselectionkeys { //false } forall
- /OutputAttributes //false
- .outputattrkeys
- { { 2 index /OutputAttributes .knownget { //null eq } { //true } ifelse } }
- forall
- /Install //false
- /BeginPage //false
- /EndPage //false
- /Policies //false
- % Our extensions:
- /HWColorMap
- { % HACK: don't transmit the color map, because
- % window systems can change the color map on their own
- % incrementally. Someday we'll have a better
- % solution for this....
- //false
- }
- /ViewerPreProcess //false
- /ImagingBBox //false % This prevents the ImagingBBox value in the setpagedevice
- % from affecting the device's ImagingBBox parameter, but
- % does retain a 'shadow' copy at the PostScript level.
- % This is done for Adobe compatibility since Adobe does
- % render marks outside the ImagingBBox (and QuarkXpress
- % relies on it).
-.dicttomark readonly def
-
% Define access to device defaults.
/.defaultdeviceparams
{ finddevice //null .getdeviceparams
@@ -634,7 +639,7 @@ NOMEDIAATTRS {
SETPDDEBUG { (Rolling back.) = pstack flush } if
3 index 2 index 3 -1 roll .forceput
4 index 1 index .knownget
- { 4 index 3 1 roll .forceput }
+ { 4 index 3 1 roll .forceput } executeonly
{ 3 index exch .undef }
ifelse
} bind executeonly odef
@@ -675,19 +680,6 @@ currentdict /0Policy undef
currentdict /1Policy undef
currentdict /7Policy undef
-% Prepare to present parameters to the device, by spreading them onto the
-% operand stack and removing any that shouldn't be presented.
-/.prepareparams % <params> .prepareparams -mark- <key1> <value1> ...
- { mark exch dup
- { % Stack: -mark- key1 value1 ... merged key value
- .presentspecial 2 index .knownget
- { exec { 3 -1 roll } { pop pop } ifelse }
- { 3 -1 roll }
- ifelse
- }
- forall pop
- } bind def
-
% Put device parameters without resetting currentpagedevice.
% (.putdeviceparams clears the current page device.)
/.putdeviceparamsonly % <device> <Policies|null> <require_all> -mark-
@@ -705,40 +697,30 @@ currentdict /7Policy undef
ifelse
} bind def
-% Try setting the device parameters from the merged request.
-/.trysetparams % <merged> <(ignored)> <device> <Policies>
- % .trysetparams
- { //true 4 index .prepareparams
- % Add the computed .MediaSize.
- % Stack: merged (ignored) device Policies -true-
- % -mark- key1 value1 ...
- counttomark 5 add index .computemediasize
- exch pop exch pop /.MediaSize exch
-SETPDDEBUG { (Putting.) = pstack flush } if
- .putdeviceparamsonly
-SETPDDEBUG { (Result of putting.) = pstack flush } if
- } bind def
-% Compute the media size and initial matrix from a merged request (after
-% media selection).
-/.computemediasize % <request> .computemediasize
- % <request> <matrix> <[width height]>
- { dup /PageSize get % requested page size
- 1 index /InputAttributes get
- 2 index (%MediaSource) get get /PageSize get % media size
- % (may be a range)
- 2 index /Policies get
- dup /PageSize .knownget
- { exch pop } { /PolicyNotFound get } ifelse % PageSize policy,
- % affects scaling
- 3 index /Orientation .knownget not { //null } if
- 4 index /RollFedMedia .knownget not { //false } if
- matrix .matchpagesize not {
- % This is a "can't happen" condition!
- /setpagedevice .systemvar /rangecheck signalerror
- } if
- 2 array astore
- } bind def
+/.postinstall { % mark ... <failed> <merged> .postinstall -
+ matrix currentmatrix .setdefaultmatrix
+ % Erase and initialize the page.
+ initgraphics
+ currentoverprint //false setoverprint 1 setcolor
+ .fillpage
+ 0 setcolor setoverprint
+ .beginpage
+
+ % Clean up, calling PolicyReport if needed.
+ % Stack: mark ... <failed> <merged>
+SETPDDEBUG { (Finishing.) = pstack flush } if
+
+ exch dup length 0 ne
+ { 1 index /Policies get /PolicyReport get
+ counttomark 1 add 2 roll cleartomark
+ exec
+ }
+ { cleartomark
+ }
+ ifelse pop
+
+} def
% ---------------- setpagedevice itself ---------------- %
@@ -760,7 +742,7 @@ SETPDDEBUG { (Result of putting.) = pstack flush } if
% (to satisfy the WordPerfect bug).
dup /..StartupGlobal known
{
- currentglobal exch true setglobal
+ currentglobal exch //true setglobal
dup /..StartupGlobal undef
} {
% ensure that we are always in local VM mode to avoid
@@ -769,7 +751,7 @@ SETPDDEBUG { (Result of putting.) = pstack flush } if
% (see .makecurrentpagdevice) and we can't store local objects
% in a global object, so we must ensure teh dictionary returned
% from currentpagedevice is in local VM.
- currentglobal exch false setglobal
+ currentglobal exch //false setglobal
} ifelse
%% We used to execute endpage after .tsrysetparams, but that actually alters
@@ -781,7 +763,7 @@ SETPDDEBUG { (Result of putting.) = pstack flush } if
%% Bug 690667.
2 .endpage
{ 1 //true .outputpage
- (>>setpagedevice, press <return> to continue<<\n) .confirm
+ (>>setpagedevice, press <return> to continue<<\n) //.confirm exec
}
if
% We mustn't pop the argument until the very end,
@@ -816,10 +798,10 @@ SETPDDEBUG { (Checking.) = pstack flush } if
dup //null eq
{ pop
}
- { exch pop .defaultdeviceparams
+ { exch pop //.defaultdeviceparams exec
% In case of duplicate keys, .dicttomark takes the entry
% lower on the stack, so we can just append the defaults here.
- .requiredattrs { exec } forall .dicttomark
+ //.requiredattrs { exec } forall .dicttomark
}
ifelse
@@ -846,7 +828,7 @@ SETPDDEBUG { (Merging.) = pstack flush } if
% Stack: <orig> <request> <merged>
dup 2 index
{ % stack: <orig> <request> <merged> <merged> <rkey> <rvalue>
- .mergespecial 2 index .knownget { exec } if
+ //.mergespecial 2 index .knownget { exec } if
put dup
}
forall pop
@@ -855,7 +837,7 @@ SETPDDEBUG { (Merging.) = pstack flush } if
FIXEDRESOLUTION { dup /HWResolution .undef } if
% Hack: if FIXEDMEDIA is true, discard any attempt to change
% PageSize or HWSize unless the PageSize Policy 13 (for FitPage).
- dup /Policies get /PageSize get 13 ne FIXEDMEDIA and
+ dup /Policies get /PageSize get 13 ne FIXEDMEDIA and
{ dup /PageSize 4 index /PageSize get put
dup /HWSize 4 index /HWSize get put
} if
@@ -876,11 +858,11 @@ SETPDDEBUG { (Selecting.) = pstack flush } if
0 dict % <failed>
1 index /InputAttributes .knownget
{ 2 index /Policies get
- .inputattrkeys (%MediaSource) cvn .selectmedia
+ .inputattrkeys (%MediaSource) cvn //.selectmedia exec
} if
1 index /OutputAttributes .knownget
{ 2 index /Policies get
- .outputattrkeys (%MediaDestination) cvn .selectmedia
+ .outputattrkeys (%MediaDestination) cvn //.selectmedia exec
} if
3 -1 roll 4 1 roll % temporarily swap orig & request
.applypolicies
@@ -905,7 +887,7 @@ SETPDDEBUG { (Constructing.) = pstack flush } if
%**************** we don't. This is WRONG.
%****************copydevice
2 index /Policies get
- .trysetparams
+ //.trysetparams
dup type /booleantype ne
{ % The request failed.
% Stack: ... <orig> <request> <merged> <failed> <device>
@@ -919,7 +901,7 @@ SETPDDEBUG { (Recovering.) = pstack flush } if
6 2 roll 3 -1 roll 4 1 roll
.applypolicies
3 -1 roll 4 1 roll 6 -2 roll
- .trysetparams % shouldn't fail!
+ //.trysetparams % shouldn't fail!
dup type /booleantype ne
{ 2 { counttomark 1 add 1 roll cleartomark } repeat
/setpagedevice .systemvar exch signalerror
@@ -984,7 +966,7 @@ SETPDDEBUG { (Installing.) = pstack flush } if
} ifelse .copydict
% Initialize the default matrix, taking media matching
% into account.
- .computemediasize pop initmatrix concat
+ //.computemediasize exec pop initmatrix concat
dup /PageOffset .knownget
{ % Translate by the given number of 1/72" units in device X/Y.
dup 0 get exch 1 get
@@ -1013,12 +995,12 @@ SETPDDEBUG { (Installing.) = pstack flush } if
exch 4 2 roll exch 4 2 roll .applypolicies exch 4 2 roll exch 4 2 roll
% Now execute the old Install -- failures after this are not handled
dup /Install .knownget { { .execinstall } stopped { pop } if } if
- .postinstall stop
+ //.postinstall exec stop
} {
- .postinstall
+ //.postinstall exec
} ifelse
} {
- .postinstall
+ //.postinstall exec
} ifelse
setglobal % return to original VM allocation mode
} bind executeonly odef
@@ -1041,29 +1023,21 @@ SETPDDEBUG { (Installing.) = pstack flush } if
pop % See above.
} odef
-/.postinstall { % mark ... <failed> <merged> .postinstall -
- matrix currentmatrix .setdefaultmatrix
- % Erase and initialize the page.
- initgraphics
- currentoverprint //false setoverprint 1 setcolor
- .fillpage
- 0 setcolor setoverprint
- .beginpage
-
- % Clean up, calling PolicyReport if needed.
- % Stack: mark ... <failed> <merged>
-SETPDDEBUG { (Finishing.) = pstack flush } if
-
- exch dup length 0 ne
- { 1 index /Policies get /PolicyReport get
- counttomark 1 add 2 roll cleartomark
- exec
- }
- { cleartomark
- }
- ifelse pop
-
-} odef
+[
+ /.computemediasize
+ /.prepareparams
+ /.selectmedia
+ /.trysetparams
+ /.installpagedevice
+ /.postinstall
+ /.copytree
+ /.defaultdeviceparams
+ /.makecurrentpagedevice
+ /.mergespecial
+ /.requiredattrs
+% /.uninstallpagedevice % (called from C code)
+]
+{currentdict exch .forceundef} forall
end % level2dict
.setlanguagelevel