diff options
Diffstat (limited to 'Master/tlpkg/tlgs/Resource/Init')
55 files changed, 2346 insertions, 2509 deletions
diff --git a/Master/tlpkg/tlgs/Resource/Init/FCOfontmap-PCLPS2 b/Master/tlpkg/tlgs/Resource/Init/FCOfontmap-PCLPS2 index b94b0327420..c54e61d16e1 100644 --- a/Master/tlpkg/tlgs/Resource/Init/FCOfontmap-PCLPS2 +++ b/Master/tlpkg/tlgs/Resource/Init/FCOfontmap-PCLPS2 @@ -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 diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_agl.ps b/Master/tlpkg/tlgs/Resource/Init/gs_agl.ps index 61329dc326f..c30b631fac8 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_agl.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_agl.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 diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_btokn.ps b/Master/tlpkg/tlgs/Resource/Init/gs_btokn.ps index c7fdcba82ac..3d6de33eb76 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_btokn.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_btokn.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 @@ -141,7 +141,7 @@ mark % 480 /DeviceN % 481 -- end -.packtomark .installsystemnames +//.packtomark exec .installsystemnames % Define printobject and writeobject. % These are mostly implemented in PostScript, so that we don't have to @@ -169,7 +169,7 @@ mark dup type //cntdict exch get exec } .bind def cntdict /arraytype { - dup dup length 5 -1 roll add 4 2 roll { .cntobj } forall + dup dup length 5 -1 roll add 4 2 roll { //.cntobj exec } forall } bind put cntdict /dicttype { WRITEDICTS { @@ -177,7 +177,7 @@ cntdict /dicttype { % We have to use .execn here, rather than simply rolling the % value under the top elements, because key might involve arrays % or dictionaries. - cvlit {.cntobj} exch 2 .execn .cntobj + cvlit {//.cntobj exec} exch 2 .execn //.cntobj exec } forall } { /writeobject .systemvar /typecheck signalerror @@ -217,7 +217,7 @@ cntdict /dicttype { dup length 0 3 -1 roll % Stack: file tag -mark- #refs #chars array - dup 4 1 roll { .cntobj } forall + dup 4 1 roll { //.cntobj exec } forall % Write the header. @@ -226,7 +226,7 @@ cntdict /dicttype { % Stack: -mark- array1 ... (array|dict)N tag #refs #chars file dup counttomark 1 sub index length 4 index 3 bitshift 4 index add - (xxxxxxxx) .bosheader writestring + (xxxxxxxx) //.bosheader exec writestring % Write the objects per se. @@ -277,39 +277,41 @@ cntdict /dicttype { } .bind def +/.writeobject { + 3 copy exch + % We must allocate the array in local VM + % to avoid a possible invalidaccess. + .currentglobal //false .setglobal exch 1 array astore exch .setglobal + //.writeobjects exec pop pop pop +} .bind def + /printobject { % <obj> <tag> printobject - currentobjectformat 0 eq { /printobject .systemvar /undefined signalerror } if - (%stdout) (w) file 2 index 2 index .writeobject pop pop + (%stdout) (w) file 2 index 2 index //.writeobject exec pop pop } odef + /writeobject { % <file> <obj> <tag> writeobject - currentobjectformat 0 eq { /writeobject .systemvar /undefined signalerror } if 2 .argindex pop % check # of args - .writeobject + //.writeobject exec } odef -/.writeobject { - 3 copy exch - % We must allocate the array in local VM - % to avoid a possible invalidaccess. - .currentglobal //false .setglobal exch 1 array astore exch .setglobal - .writeobjects pop pop pop -} .bind def % Implement binary error message output. /.objectprinttest { % <obj> .objectprinttest - % This is a pseudo-operator so it will restore the stack % if it gets an error. - mark 0 0 3 .argindex .cntobj cleartomark pop -} bind odef + mark 0 0 3 .argindex //.cntobj exec cleartomark pop +} bind def /.printerror { $error /binary get .languagelevel 2 ge and { currentobjectformat 0 ne { [ /Error $error /errorname get $error /command get % Convert the object with cvs if it isn't printable. - dup { .objectprinttest } .internalstopped { + dup { //.objectprinttest exec } //.internalstopped exec { pop 100 string cvs } if //false ] 250 printobject @@ -328,3 +330,13 @@ currentdict /w2dict .undef end .setlanguagelevel + +% undefine things defined in this file and not referenced elsewhere +[ + /.objectprinttest + /.bosheader + /.cntobj + /.writeobject + /.writeobjects +] +{level2dict exch .forceundef} forall diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_cet.ps b/Master/tlpkg/tlgs/Resource/Init/gs_cet.ps index d3e1686409b..54f17c645d6 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_cet.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_cet.ps @@ -1,31 +1,34 @@ -%!PS % Set defaults for Ghostscript to match Adobe CPSI behaviour for CET -% do this in the server level so it is persistent across jobs -//true 0 startjob not { - (*** Warning: CET startup is not in server default) = flush +% skip if we've already run this -- based on fake "product" +systemdict /product get (PhotoPRINT SE 5.0v2) readonly eq +{ + (%END GS_CET) .skipeof } if +% Note: this must be run at save level 0 and when systemdict is writeable +currentglobal //true setglobal +systemdict dup dup dup +/version (3017.102) readonly .forceput % match CPSI 3017.102 +/product (PhotoPRINT SE 5.0v2) readonly .forceput % match CPSI 3017.102 +/revision 0 put % match CPSI 3017.103 Tek shows revision 5 +/serialnumber dup {233640} readonly .makeoperator .forceput % match CPSI 3017.102 Tek shows serialnumber 1401788461 + +systemdict /.odef { % <name> <proc> odef - + 1 index exch //.makeoperator def +} .bind .forceput % this will be undefined at the end + 300 .sethiresscreen % needed for language switch build since it % processes gs_init.ps BEFORE setting the resolution 0 array 0 setdash % CET 09-08 wants local setdash -currentglobal //true setglobal -{ - systemdict dup dup dup - /version (3017.102) readonly put % match CPSI 3017.102 - /product (PhotoPRINT SE 5.0v2) readonly put % match CPSI 3017.102 - /revision 0 put % match CPSI 3017.103 Tek shows revision 5 - /serialnumber dup {233640} readonly .makeoperator put % match CPSI 3017.102 Tek shows serialnumber 1401788461 - systemdict /deviceinfo undef % for CET 20-23-1 -% /UNROLLFORMS true put % CET files do unreasonable things inside forms -} 1183615869 internaldict /superexec get exec - -/UNROLLFORMS true def - -{ } bind dup +/UNROLLFORMS //true def + +(%.defaultbgrucrproc) cvn { } bind def + +(%.defaultbgrucrproc) cvn load dup setblackgeneration setundercolorremoval 0 array cvx readonly dup dup dup setcolortransfer @@ -66,10 +69,62 @@ dup 7 -1 put % and GS_CHAR_FILL are now dynamic. Force CPSI compatibility. //true .setCPSImode +% Some QL jobs (/23-12B.PS for example) do: +% '(%stdin) (r) file' +% expecting that they are being read from stdin. +% if that is not the case, they block waiting for input +% from stdin. +% This hooks the 'file' operator', so if a job tries to +% open %stdin, and we're *not* reading the job from stdin +% it'll return currentfile instead. +/ofile /file load def +/file +{ + 1 index (%stdin) eq 2 index (%stdin%) eq or + { + ofile dup currentfile eq not + { + pop currentfile + }if + } + { + ofile + } ifelse +} bind //.odef exec +currentdict /ofile undef + +% One QL job (23-12B.PS) effectively does: +% (%stdin) (r) file 0 setfileposition +% expecting it to throw an ioerror (stdin not being a positionable +% stream. +% With the above 'file' hook, when running from a file +% rather than stdin, setfileposition will succeed, and we hit +% an infinite loop - '0 setfileposition' meaning we restart intepreting +% from the beginning of the file. +% Hook setfileposition to throw an error attempting to reposition +% the current file. +/osetfileposition /setfileposition load def +/setfileposition +{ + 1 index currentfile eq + { + /setfileposition cvx /ioerror signalerror + } + { + osetfileposition + } ifelse +} bind //.odef exec +currentdict /osetfileposition undef + setglobal -% Remove all but 'letter' page size +% Remove all but the default page size (the 0 entry in the InputAttributes +% dictionary). This is usually 'letter'. << +% As we're removing all but the default, make sure we're +% using the default. +/PageSize currentpagedevice /InputAttributes get 0 get /PageSize get + currentpagedevice /InputAttributes get 1 1 2 index length 1 sub { 1 index exch undef @@ -86,8 +141,8 @@ userdict /.smoothness currentsmoothness put } { /setsmoothness .systemvar /typecheck signalerror } ifelse -} bind odef -/currentsmoothness { userdict /.smoothness get } bind odef % for 09-55.PS, 09-57.PS . +} bind //.odef exec +/currentsmoothness { userdict /.smoothness get } bind //.odef exec % for 09-55.PS, 09-57.PS . % slightly nasty hack to give consistent cluster results /ofnfa systemdict /filenameforall get def @@ -106,6 +161,8 @@ userdict /.smoothness currentsmoothness put } ifelse ofnfa } bind def -% end of slightly nasty hack to give consistent cluster results -//false 0 startjob pop % re-enter encapsulated mode +systemdict /.odef .undef + +% end of slightly nasty hack to give consistent cluster results +%END GS_CET diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_cff.ps b/Master/tlpkg/tlgs/Resource/Init/gs_cff.ps index b60e3740572..125906132b7 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_cff.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_cff.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 @@ -33,33 +33,6 @@ % Load a font file that might be an OpenType CFF font set. -% <file> .loadfontfile - -/.loadnonottofontfile /.loadfontfile load def -/.loadfontfile { - dup (12345678) .peekstring pop (wOFFOTTO) eq - { - .init_wOFF_otto_font_file - //true //false - }{//true} ifelse - - { - dup 4 string .peekstring pop (OTTO) eq - { - % If this is a font at all, it's an OpenType CFF font set. - .init_otto_font_file //true - } - { //false } ifelse - } if - - { % Use a random FontSet resource name. ****** WRONG ****** - realtime rand xor =string cvs exch //false //false - ReadData pop - } { - % Not a TrueType font. - .loadnonottofontfile - } ifelse -} bind def - % <file> .init_otto_font_file <file> /.init_otto_font_file { /FontSetInit /ProcSet findresource begin @@ -79,7 +52,7 @@ exch 3 -1 roll 1 add 16 mul 12 add sub f exch subfilefilter flushfile % skip to start f exch subfilefilter end -} bind def +} .bind executeonly odef % <file> .init_otto_font_file <file> /.init_wOFF_otto_font_file { @@ -116,8 +89,37 @@ { pop f exch subfilefilter /FlateDecode filter} ifelse end } bind def -20 dict begin +% <file> .loadfontfile - +/.loadnonottofontfile /.loadfontfile load def +/.loadfontfile { + dup (12345678) .peekstring pop (wOFFOTTO) eq + { + //.init_wOFF_otto_font_file exec + //true //false + }{//true} ifelse + + { + dup 4 string .peekstring pop (OTTO) eq + { + % If this is a font at all, it's an OpenType CFF font set. + .init_otto_font_file //true + } + { //false } ifelse + } if + + { % Use a random FontSet resource name. ****** WRONG ****** + realtime rand xor =string cvs exch //false //false + ReadData pop + } { + % Not a TrueType font. + .loadnonottofontfile + } ifelse +} bind executeonly def + +currentdict /.init_wOFF_otto_font_file .forceundef + +20 dict begin % ------ Utilities ------ % /subfilefilter { % <file> <length> subfilefilter <filter> diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_cidcm.ps b/Master/tlpkg/tlgs/Resource/Init/gs_cidcm.ps index 60b0fdb2971..5ec2fa343ac 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_cidcm.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_cidcm.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 diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_ciddc.ps b/Master/tlpkg/tlgs/Resource/Init/gs_ciddc.ps index f83e960b129..f0fb5d81c36 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_ciddc.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_ciddc.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 diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_cidfm.ps b/Master/tlpkg/tlgs/Resource/Init/gs_cidfm.ps index 16ef97f0b5c..c0237283cd8 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_cidfm.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_cidfm.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 @@ -165,7 +165,7 @@ currentdict end def .libfile {closefile pop} { - {(r) file} .internalstopped + {(r) file} //.internalstopped exec {pop pop 2 index exch .undef} {closefile pop} ifelse } ifelse diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_cidfn.ps b/Master/tlpkg/tlgs/Resource/Init/gs_cidfn.ps index 74f1446bcd5..80b8008cf30 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_cidfn.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_cidfn.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 @@ -52,12 +52,14 @@ % FDArray. dup 0 { - 9 .checkfonttype { + 9 //.checkfonttype exec { /CIDInit /ProcSet findresource begin .completefont9 end } if - 1 index exch .buildfont9 exch pop + 1 index exch .buildfont9 + .currentresourcefile dup type /filetype eq { //.filename {1 index exch /ResourcePath exch put} if }{ pop} ifelse + exch pop } put % Don't bind it here, because gs_fapi.ps redefines .buildfont9 % Add entries to a new CIDFontType 0 font per documentation (FontMatrix) @@ -137,15 +139,19 @@ dup 0 { % ------ CIDFontType 1 (FontType 10) ------ % dup 1 { - 10 .checkfonttype pop - 1 index exch .buildfont10 exch pop + 10 //.checkfonttype exec pop + 1 index exch .buildfont10 + .currentresourcefile dup type /filetype eq { //.filename {1 index exch /ResourcePath exch put} if }{ pop} ifelse + exch pop } put % Don't bind it here because gs_fapi.ps redefines .buildfont10 % ------ CIDFontType 2 (FontType 11) ------ % dup 2 { - 11 .checkfonttype pop - 1 index exch .buildfont11 exch pop + 11 //.checkfonttype exec pop + 1 index exch .buildfont11 + .currentresourcefile dup type /filetype eq { //.filename {1 index exch /ResourcePath exch put} if }{ pop} ifelse + exch pop } put % Don't bind it here because gs_fapi.ps redefines .buildfont11 pop % .cidfonttypes @@ -172,7 +178,7 @@ pop % .cidfonttypes exch pop {stop}if }if currentfile fileposition - } .internalstopped { + } //.internalstopped exec { % File is not positionable, or uses hex data. % Load the data now. cleartomark exch @@ -282,7 +288,7 @@ currentdict end /.readglyphdata { currentfont exch .type9mapcid FDArray exch get exch -} bind def +} bind executeonly def % BuildGlyph procedure for CIDFontType 0. % The name %Type9BuildGlyph is known to the interpreter. @@ -290,9 +296,9 @@ currentdict end (%Type9BuildGlyph) cvn { % <cidfont> <cid> %Type9BuildGlyph - .currentglobal 3 1 roll 1 index gcheck .setglobal 1 index begin - dup .readglyphdata dup //null eq { + dup //.readglyphdata exec dup //null eq { % Substitute CID 0. **** WRONG **** - pop pop 0 .readglyphdata + pop pop 0 //.readglyphdata exec } if % Stack: cidfont cid subfont charstring dup //null eq { pop pop pop pop } { %**** WRONG **** @@ -302,7 +308,7 @@ currentdict end } ifelse %**** WRONG **** end .setglobal -} bind def +} bind executeonly def % ------ CIDFontType 2 ------ % @@ -310,12 +316,12 @@ currentdict end % The name %Type11BuildGlyph is known to the interpreter. (%Type11BuildGlyph) cvn { % <cidfont> <cid> %Type11BuildGlyph - % We must be prepared for out-of-range CIDs. - 2 copy { .type11mapcid } .internalstopped { + 2 copy { .type11mapcid } //.internalstopped exec { pop /CharStrings get /.notdef get } if % Stack: cidfont cid glyphindex 1 index exch .type42execchar -} bind def +} bind executeonly def % ---------------- Define resources ---------------- % @@ -346,7 +352,7 @@ languagelevel exch 2 .setlanguagelevel /ProvideUnicodeDecoding get exec } if dup /CIDFontType get //.cidfonttypes exch get exec -} odef +} bind executeonly odef /CIDFont /Generic /Category findresource dup length dict .copydict dup /InstanceType /dicttype put @@ -371,9 +377,9 @@ dup /DefineResource { } bind def dup /.LoadResource { currentglobal { - .loadcidfontresource + //.loadcidfontresource exec } { - //true setglobal {.loadcidfontresource} stopped //false setglobal {stop} if + //true setglobal {//.loadcidfontresource exec} stopped //false setglobal {stop} if } ifelse } bind put @@ -411,3 +417,10 @@ dup /.CheckResource { %% Replace 1 (gs_ciddc.ps) (gs_ciddc.ps) runlibfile + +% Undef these, not needed outside this file +[ + /.checkfonttype + /.loadcidfontresource + /.readglyphdata +] {systemdict exch .forceundef} forall diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_cidtt.ps b/Master/tlpkg/tlgs/Resource/Init/gs_cidtt.ps index a8aa10c98e0..12ade5e5908 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_cidtt.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_cidtt.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 @@ -116,7 +116,7 @@ currentdict /super.complete_instance currentdict /complete_instance get put } if closefile } { - (r) { file } .internalstopped + (r) { file } //.internalstopped exec { (Can't find the font file ) print = /findfont cvx /undefinedfilename signalerror diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_cmap.ps b/Master/tlpkg/tlgs/Resource/Init/gs_cmap.ps index a01afc23feb..2733ea3b14c 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_cmap.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_cmap.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 @@ -74,7 +74,7 @@ CMap /WMode .knownget { /WMode exch def } if /FontType 0 def pop pop currentdict end -} bind odef +} bind executeonly odef % composefont doesn't appear in CMap files -- it's documented in % the "PostScript Language Reference Manual Supplement". @@ -118,7 +118,7 @@ } bind def /endcmap { % - endcmap - - .rewriteTempMapsNotDef + //.rewriteTempMapsNotDef exec CMAPDEBUG { 2 (*** undefined charmap ***) @@ -539,11 +539,13 @@ dup /DefineResource { } bind executeonly put /Category defineresource pop % We might have loaded CID font support already. -/CIDInit /ProcSet 2 copy { findresource } .internalstopped +/CIDInit /ProcSet 2 copy { findresource } //.internalstopped exec % An interior `stopped' might have reset VM allocation to local. //true .setglobal { pop pop 3 -1 roll } { dup length 4 index length add dict .copydict 4 -1 roll exch .copydict } ifelse exch defineresource pop +currentdict /.rewriteTempMapsNotDef .undef + .setlanguagelevel diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_cspace.ps b/Master/tlpkg/tlgs/Resource/Init/gs_cspace.ps index c612ea9acf4..ff5955a9577 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_cspace.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_cspace.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 @@ -62,19 +62,6 @@ end % colorspacedict /DeviceCMYK_array /DeviceCMYK 1 array astore readonly def % -% - initgraphics - -% -% Although the internal routine gs_initgraphics resets the color space, -% it does not reset the color space we store in the 'interpreter' -% graphics state (so that we can hand it back in currentcolorspace). -% So we need to do that in the PostScript world. -% -% -/initgraphics - { initgraphics systemdict /DeviceGray_array get setcolorspace } -.bind odef - -% % These routines used for the NOSUBSTDEVICECOLORS switch. This prevents % substitution of DeviceGray, DeviceRGB and DeviceCMYK with a Default* % colour space when /UseCIEColors is true. If the job includes a @@ -92,6 +79,8 @@ end % colorspacedict % If the boolean is true then the C code must set the additional colour space % and execute .includecolorspace before finally setting a DeviceGray space. % +% called from C code, can't undef. Use this to trigger the code: +% -sDEVICE=pkmraw -dMaxBitmap=4000m -r72 -dNOSUBSTDEVICECOLORS ./tests/Ghent_V3.0/110_defaultcolourspace_x3.pdf /..nosubstdevicetest { //false mark 3 -1 roll @@ -118,67 +107,6 @@ end % colorspacedict } ifelse }bind def -% -% <color_space_name> ..includecolorspace - -% -/..includecolorspace -{ - % If we have already recorded this space, don't repeat it. - systemdict /..page_default_spaces get 1 index known { - pop - } { - mark exch - { - % Check to see if this space was defined by defineresource, if so then - % the job defined it, otherwise its the usual default, so ignore it. - dup /ColorSpace resourcestatus { - pop 0 eq { - % Job defined /Default*, so record it and allow the device access to it - systemdict /..page_default_spaces get 1 index //true put - gsave - { dup /ColorSpace findresource //setcolorspace exec .includecolorspace - } stopped pop - grestore - } if - } if - } stopped pop - cleartomark - } ifelse -} bind def - -% -% <color_space> <color_space_name> cs_substitute_generic <color_space1> <color_space2> -% -/cs_substitute_generic -{ .getuseciecolor - {NOSUBSTDEVICECOLORS - { //..includecolorspace exec dup } - { /ColorSpace findresource } - ifelse - } - { pop dup } - ifelse -} -bind def - -% -% <color_space> <color_space_name> cs_substitute_DeviceRGB_for_PDFX_or_PDFA <color_space1> <color_space2> -% -/cs_substitute_DeviceRGB_for_PDFX_or_PDFA -{ systemdict /PDFX .knownget not { //false } if - systemdict /PDFA .knownget not { //false } {0 eq {//false}{//true} ifelse} ifelse - or { - dup /ColorSpace resourcestatus { - pop pop - } { - (Error: Need a /DefaultRGB /ColorSpace resource for generating a PDF/X or PDF/A document.) = - /cs_substitute_DeviceRGB_for_PDFX_or_PDFA cvx /undefined signalerror - } ifelse - /ColorSpace findresource - } { - //cs_substitute_generic exec - } ifelse -} bind def end % diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_dbt_e.ps b/Master/tlpkg/tlgs/Resource/Init/gs_dbt_e.ps index 54692f447d3..01e3c8240ba 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_dbt_e.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_dbt_e.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 diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_diskn.ps b/Master/tlpkg/tlgs/Resource/Init/gs_diskn.ps index fd694bc44b5..d3402782d81 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_diskn.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_diskn.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 @@ -51,7 +51,7 @@ systemdict begin mark 5 1 roll ] mark exch { { } forall } forall ] //systemdict /.searchabledevs 2 index .forceput exch .setglobal - } + } executeonly if } .bind executeonly odef % must be bound and hidden for .forceput @@ -129,7 +129,7 @@ systemdict begin 2 index 0 get 37 eq { [ () ] } { .getsearchabledevs } ifelse { 3 index concatstrings % prepend the device { - 2 index //file } .internalstopped not { + 2 index //file } //.internalstopped exec not { 4 1 roll pop pop pop //true exit % exit with success } { @@ -151,7 +151,7 @@ systemdict begin //false % success code 1 index 0 get 37 eq { [ () ] } { .getsearchabledevs } ifelse { 2 index concatstrings % prepend the device - { //deletefile } .internalstopped exch pop not { + { //deletefile } //.internalstopped exec exch pop not { pop //true exit % exit with success } if @@ -166,7 +166,7 @@ systemdict begin //false % success code 1 index 0 get 37 eq { [ () ] } { .getsearchabledevs } ifelse { 2 index concatstrings % prepend the device - { //status } .internalstopped not { + { //status } //.internalstopped exec not { { //true 7 -2 roll pop pop //true exit } % exit with success if } @@ -187,7 +187,7 @@ systemdict begin //false % success code 2 index 0 get 37 eq { [ () ] } { .getsearchabledevs } ifelse { dup 4 index concatstrings % prepend the device - { (r) //file } .internalstopped + { (r) //file } //.internalstopped exec not { closefile exch pop //true exit % exit with success } { diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_dpnxt.ps b/Master/tlpkg/tlgs/Resource/Init/gs_dpnxt.ps deleted file mode 100644 index 8e7e241d612..00000000000 --- a/Master/tlpkg/tlgs/Resource/Init/gs_dpnxt.ps +++ /dev/null @@ -1,133 +0,0 @@ -% Copyright (C) 2001-2018 Artifex Software, Inc. -% All Rights Reserved. -% -% This software is provided AS-IS with no warranty, either express or -% implied. -% -% This software is distributed under license and may not be copied, -% modified or distributed except as expressly authorized under the terms -% of the license contained in the file LICENSE in this distribution. -% -% Refer to licensing information at http://www.artifex.com or contact -% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato, -% CA 94945, U.S.A., +1(415)492-9861, for further information. -% - -% gs_dpnxt.ps -% NeXT Display PostScript extensions - -% Define the operation values for compositing. These must match the values -% in gsdpnext.h, which also are the ones from the NeXT documentation. -% We put them in systemdict, which seems like as good a place as any. -mark - /Clear /Copy /Sover /Sin /Sout /Satop /Dover /Din /Dout /Datop /Xor - /PlusD /PlusL /Highlight % not sure about Highlight -counttomark { counttomark 1 sub def } repeat pop - -% We implement readimage and sizeimage using the following 3 otherwise -% undocumented lower-level operators: -% -% <x> <y> <width> <height> <matrix> .sizeimagebox -% <dev_x> <dev_y> <dev_width> <dev_height> <matrix> -% -% - .sizeimageparams <bits/sample> <multiproc> <ncolors> -% -% <device> <x> <y> <width> <max_height> <alpha?> <std_depth|null> -% <string> .getbitsrect <height> <substring> -% -% NOTE: These operators are subject to change without notice! - -% Implement readimage using .getbitsrect. Experimentation on a NeXT system -% shows that the data is always returned in order of increasing device Y, -% regardless of the CTM. -% -% Note that we can't make stack protection work for this operator, -% because it must remove its operands from the stack before calling -% the supplied procedure(s). - -/readimage { % <x> <y> <width> <height> <proc> [... <procN-1>] - % <string> <alpha?> readimage - - .sizeimageparams exch { - % multiproc = true. If N > 1, store the procedures in an array. - exch pop 1 index { 1 add } if - % Stack: ... string alpha? nprocs - dup 1 eq { - pop //false % only 1 procedure, multiproc is irrelevant - } { - dup array 4 1 roll 3 add 2 roll astore 3 1 roll //true - } ifelse - } { - % multiproc = false. - pop pop //false - } ifelse - % Map the rectangle to device coordinates. - % Stack: x y w h proc(s) str alpha? multi? - 8 -4 roll matrix .sizeimagebox pop 8 4 roll - % Make sure we allocate the operand array in local VM - % to avoid a possible invalidaccess. - .currentglobal //false .setglobal 9 1 roll - exch { 1 } { 0 } ifelse exch % alpha is last, if present - exch 4 1 roll 8 array astore exch .setglobal - { % Read out a block of scan lines and pass them to the procedure. - % Stack: [x y w h alpha? proc(s) str multi?] -- we must consume this. - dup 3 get 0 eq { pop exit } if - aload 9 1 roll pop exch pop currentdevice 7 1 roll - % Always read out the data as standard (not native) pixels. - .sizeimageparams pop pop exch .getbitsrect - % Stack: [x y w h alpha? proc(s) str multi?] hread substr - 3 -1 roll - % Stack: hread substr [x y w h alpha? proc(s) str multi?] - dup 1 2 copy get 5 index add put - % Stack: hread substr [x y' w h alpha? proc(s) str multi?] - dup 3 2 copy get 6 -1 roll sub put - % Stack: substr [x y' w h' alpha? proc(s) str multi?] - dup 5 get exch 7 get { - % multiproc = true, pass each plane to a different procedure. - % Stack: substr procs - 0 1 2 index length 1 sub { - % Push 1 plane and its procedure under the top 2 elements. - % Stack: ... substr procs plane# - 2 index length 2 index length idiv % bytes per plane - dup 2 index mul exch - % Stack: ... substr procs plane# start length - 4 index 3 1 roll getinterval 4 1 roll - 2 copy get 4 1 roll pop - } for - exch pop length 2 mul .execn - } { - % multiproc = false, just call the procedure. - exec - } ifelse - } //systemdict /exec get 3 packedarray cvx loop -} bind odef - -% -% <w> <h> <bpc> <mtx> <dsrc0> ... <multi> <ncomp> alphaimage - -% -img_utils_dict begin -/.alphaimage where - { - pop - .currentglobal //true .setglobal - /alphaimage - { - //true - //.colorimage - stopped - { /alphaimage .systemvar $error /errorname get signalerror } - if - } - .bind systemdict begin odef end - .setglobal - } -if -end - -% Implement sizeimage using lower-level operators. - -/sizeimage { % <x> <y> <width> <height> <matrix> sizeimage - % <devwidth> <devheight> <bits/sample> <matrix> - % <multiproc> <ncolors> - .sizeimagebox 5 -2 roll pop pop - .sizeimageparams 3 -1 roll 4 1 roll -} bind odef diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_dps.ps b/Master/tlpkg/tlgs/Resource/Init/gs_dps.ps deleted file mode 100644 index 00c14d53204..00000000000 --- a/Master/tlpkg/tlgs/Resource/Init/gs_dps.ps +++ /dev/null @@ -1,222 +0,0 @@ -% Copyright (C) 2001-2018 Artifex Software, Inc. -% All Rights Reserved. -% -% This software is provided AS-IS with no warranty, either express or -% implied. -% -% This software is distributed under license and may not be copied, -% modified or distributed except as expressly authorized under the terms -% of the license contained in the file LICENSE in this distribution. -% -% Refer to licensing information at http://www.artifex.com or contact -% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato, -% CA 94945, U.S.A., +1(415)492-9861, for further information. -% - -% Initialization file for Display PostScript functions. - -% ------ Errors ------ % - -% These errors are only defined in DPS. -{ /invalidcontext /invalidid } { .registererror } forall - -% ------ Contexts ------ % - -% To create a context with private local VM, we use the .localfork -% operator to actually create the context, the new VM, and an empty -% userdict, and then we call the .initlocaldicts procedure to make -% local copies of the initial contents of the dictionaries in local VM. -% savedlocaldicts in systemdict is a global read-only dictionary whose -% elements are global read-only copies of these initial contents; -% we just copy its elements into local VM and install them in systemdict. -% userdict and internaldict require special handling. - -% Switching between contexts with different local VMs requires -% changing the bindings in systemdict that reference local objects. -% For this purpose, each userdict has an entry called localdicts -% which holds the local copies of the elements of savedlocaldicts, -% plus internaldict. The context switching code in the interpreter -% effectively copies this dictionary into systemdict. -% NOTE: the name localdicts is known to the interpreter. - -% Switching between contexts also requires resetting the user parameters. -% The interpreter records the value of userparams (a local dictionary -% referenced from systemdict) for each context, and uses it for this. -% See gs_lev2.ps for more details. -% NOTE: the name userparams is known to the interpreter. - -% Save copies of local dictionaries at the end of system initialization. -% Also save the initial gstate. -/.savelocalstate { - .currentglobal //true .setglobal - //systemdict /savedlocaldicts mark //systemdict { - dup gcheck { - pop pop - } { - dup type /dicttype eq { - % Save a copy of this dictionary in global VM. - dup maxlength dict .copydict readonly - } { - pop pop - } ifelse - } ifelse - } forall .dicttomark readonly put - % Create localdicts for the current context. - //false .setglobal - userdict /localdicts mark savedlocaldicts { - pop dup load - } forall /internaldict dup load - .dicttomark readonly put - % Save a copy of the initial gstate. - //systemdict /savedinitialgstate gstate readonly .forceput - .setglobal -} .bind executeonly odef % must be bound and hidden for .forceput - -% Initialize local dictionaries and gstate when creating a new context. -% Note that until this completes, we are in the anomalous situation of -% having systemdict point to dictionaries that are in a non-current -% local VM. Because of this, we turn off garbage collection temporarily. -/.copylocal { % <name> <dict> .copylocal <name> <dict'> - % Copy a dictionary to the current (local) VM, - % and make it read-only if its current definition is. - dup maxlength dict .copydict - 1 index load wcheck not { readonly } if -} .bind def -% When this is called, the dictionary stack is in its initial state, -% and there is (anomalously) only one gstate on the gstate stack. -/.initlocaldicts { % - .initlocaldicts - - -2 vmreclaim - .currentglobal //systemdict begin - //false .setglobal - % Since localdicts doesn't exist yet, references from - % systemdict to local objects won't get restored if - % a context switch happens in this code. Therefore, - % until localdicts is defined, we have to keep all our - % state on the operand stack. - - % Acquire userdict. - %****** WRONG IF NON-STANDARD INITIAL DSTACK ****** - countdictstack array dictstack - { dup gcheck not { exit } if pop } forall - % Create localdicts with a local copy of each dictionary, - % except for userdict and userparams, which just need - % to be filled in. - mark savedlocaldicts { - 1 index /userdict eq { - % Stack: userdict mark ... /userdict inituserdict - counttomark 1 add index .copydict - } { - 1 index /userparams eq { - % Stack: userdict mark ... /userparams inituserparams - userparams .copydict - } { - .copylocal - } ifelse - } ifelse - } forall /internaldict dup .makeinternaldict .makeoperator - .dicttomark readonly /localdicts exch put - % localdicts is now defined in userdict. - % Copy the definitions into systemdict. - localdicts { .forcedef } forall - % Set the user parameters. - userparams readonly .setuserparams - % Establish the initial gstate(s). - /savedinitialgstate .systemvar setgstate gsave - % Wrap up. - end .setglobal -} bind executeonly odef - -% Check whether an object is a procedure. -/.proccheck { % <obj> .proccheck <bool> - dup xcheck - exch type dup /arraytype eq exch /packedarraytype eq or and -} bind def - -% Create a context with private local VM. -% The .localfork operator does all the work, but we must ensure that -% .initlocaldicts gets called when the new context starts up. -/localfork { % <mark> <obj1> ... <objN> <proc> - % <stdin|null> <stdout|null> - % localfork <context> - .currentglobal //true .setglobal 3 index - dup .proccheck not { - pop .setglobal /localfork .systemvar /typecheck signalerror - } if - {exec .initlocaldicts} aload pop - 3 1 roll 3 packedarray cvx - 4 1 roll 5 -1 roll pop .setglobal .localfork -} odef - -% Fork a context that shares VM. The .fork operator creates an empty -% userparams dictionary for the context, but we still need to initialize -% this dictionary when the new context starts up. -/.postfork { % - .postfork - - % Initialize the user parameters. - savedlocaldicts /userparams get userparams .copydict readonly pop -} odef -/fork { % <mark> <obj1> ... <objN> <proc> fork <context> - .currentglobal //false .setglobal 1 index - dup .proccheck not { - pop .setglobal /fork .systemvar /typecheck signalerror - } if - {exec .postfork} aload pop - 3 1 roll 3 packedarray cvx - 3 1 roll exch pop .setglobal .fork -} odef - -% ------ Halftone phase ------ % - -/sethalftonephase { % <x> <y> sethalftonephase - - -1 2 index 2 index .setscreenphase pop pop -} odef -/currenthalftonephase { % - currenthalftonephase <x> <y> - 0 .currentscreenphase -} odef - -% ------ Device-source images ------ */ - -.imagetypes 2 /.image2 load put - -% ------ Device information ------ % - -/.deviceinfodict mark - /Colors //null /GrayValues //null /RedValues //null /GreenValues //null - /BlueValues //null /ColorValues //null -.dicttomark readonly def -/deviceinfo { % - deviceinfo <dict> - currentdevice //.deviceinfodict .getdeviceparams .dicttomark - dup begin - /ColorValues .knownget { - 0 le - { currentdict /ColorValues undef } - { - % hack around devices that incorrect set GrayValues - Colors 3 eq { 1 } { GrayValues } ifelse - RedValues mul GreenValues mul BlueValues mul ColorValues ne - { currentdict /GrayValues undef - currentdict /RedValues undef - currentdict /GreenValues undef - currentdict /BlueValues undef - } if - } - ifelse - } if - currentdict end readonly -} odef - -% The current implementation allocates a 2-element array each time. -% Perhaps we should change this to 2 separate parameters for X and Y? -/.wtdict mark - /wtranslation //null -.dicttomark readonly def -/wtranslation { % - wtranslation <x> <y> - currentdevice //.wtdict .getdeviceparams exch pop exch pop aload pop -} odef -currentdict /.wtdict .undef - -% ------ View clipping ------ % - -/rectviewclip { % <x> <y> <width> <height> rectviewclip - - % <numarray|numstring> rectviewclip - - newpath .rectappend viewclip -} odef diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_dps1.ps b/Master/tlpkg/tlgs/Resource/Init/gs_dps1.ps index ec5db61b9f0..7cf29b46b81 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_dps1.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_dps1.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 @@ -33,14 +33,17 @@ systemdict begin /SharedFontDirectory .FontDirectory .gcheck { .currentglobal //false .setglobal + currentdict /LocalFontDirectory .FontDirectory dup maxlength dict copy - .forcedef % LocalFontDirectory is local, systemdict is global + .forceput % LocalFontDirectory is local, systemdict is global .setglobal .FontDirectory - } - { /LocalFontDirectory .FontDirectory - .forcedef % LocalFontDirectory is local, systemdict is global + } executeonly + { + currentdict + /LocalFontDirectory .FontDirectory + .forceput % LocalFontDirectory is local, systemdict is global 50 dict - } + }executeonly ifelse def end % systemdict @@ -55,7 +58,7 @@ level2dict begin { //SharedFontDirectory } { /LocalFontDirectory .systemvar } % can't embed ref to local VM ifelse .forceput pop % LocalFontDirectory is local, systemdict is global - } .bind odef + } .bind executeonly odef % Don't just copy (load) the definition of .setglobal: % it gets redefined for LL3. /setshared { /.setglobal .systemvar exec } odef @@ -67,25 +70,26 @@ level2dict begin /selectfont % <fontname> <size> selectfont - { - { 1 .argindex findfont + { + 1 .argindex findfont 1 index dup type /arraytype eq { makefont } { scalefont } ifelse setfont pop pop } stopped { /selectfont .systemvar $error /errorname get signalerror } if } odef % undefinefont has to take local/global VM into account. /undefinefont % <fontname> undefinefont - - { .FontDirectory 1 .argindex .forceundef % FontDirectory is readonly + { //.FontDirectory 1 .argindex .forceundef % FontDirectory is readonly .currentglobal { % Current mode is global; delete from local directory too. //systemdict /LocalFontDirectory .knownget - { 1 index .forceundef } % LocalFontDirectory is readonly + { 1 index .forceundef } executeonly % LocalFontDirectory is readonly if } { % Current mode is local; if there was a shadowed global % definition, copy it into the local directory. //systemdict /SharedFontDirectory .knownget { 1 index .knownget - { .FontDirectory 2 index 3 -1 roll { put } systemdict /superexec known {//superexec}{1183615869 internaldict /superexec get exec} ifelse } % readonly + { //.FontDirectory 2 index 3 -1 roll .forceput } % readonly if } if @@ -126,7 +130,7 @@ level2dict begin } ifelse } forall - pop counttomark 2 idiv { .forceundef } repeat pop % readonly + pop counttomark 2 idiv { .forceundef } executeonly repeat pop % readonly } if //SharedFontDirectory exch .forcecopynew pop diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_dps2.ps b/Master/tlpkg/tlgs/Resource/Init/gs_dps2.ps index 64faeda37e0..fe3ca27dd5b 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_dps2.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_dps2.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 @@ -34,7 +34,7 @@ level2dict begin { { exch pop } % halftone { /HalftoneType 1 % screen { /Frequency /Angle /SpotFunction } - .makestackdict readonly + //.makestackdict exec readonly } { /HalftoneType 2 % colorscreen { /RedFrequency /RedAngle /RedSpotFunction @@ -42,11 +42,13 @@ level2dict begin /BlueFrequency /BlueAngle /BlueSpotFunction /GrayFrequency /GrayAngle /GraySpotFunction } - .makestackdict readonly + //.makestackdict exec readonly } } exch get exec } odef +currentdict /.makestackdict undef + % Define sethalftone so it converts types 1-4 to type 5. /.makehalftoneRGBV { % <dict> <type> <keys> <keysRGBV> 4 -1 roll exch { 1 index exch get exch } forall 15 1 roll @@ -79,7 +81,7 @@ systemdict begin /GreenFrequency /GreenAngle /GreenSpotFunction /BlueFrequency /BlueAngle /BlueSpotFunction /GrayFrequency /GrayAngle /GraySpotFunction - } .makehalftoneRGBV + } //.makehalftoneRGBV exec } bind def 3 { mark exch /Default exch .dicttomark { .sethalftone5 } @@ -90,7 +92,7 @@ systemdict begin /GreenWidth /GreenHeight /GreenThresholds /BlueWidth /BlueHeight /BlueThresholds /GrayWidth /GrayHeight /GrayThresholds - } .makehalftoneRGBV + } //.makehalftoneRGBV exec } bind def 5 { pop dup length dict copy @@ -115,6 +117,8 @@ systemdict begin } bind def end end +currentdict /.makehalftoneRGBV undef + /sethalftone { % <dict> sethalftone - % We must create the new dictionary in the same VM as the % operand; otherwise, invalidaccess errors may occur. @@ -144,16 +148,18 @@ end } bind def /setscreen % <ignore*2> <dict> setscreen - { dup type /dicttype eq - { .fixsethalftonescreen sethalftone pop pop pop } + { //.fixsethalftonescreen exec sethalftone pop pop pop } { //setscreen } ifelse } .bind odef /setcolorscreen % <ignore*11> <dict> setcolorscreen - { dup type /dicttype eq - { .fixsethalftonescreen sethalftone 12 { pop } repeat } + { //.fixsethalftonescreen exec sethalftone 12 { pop } repeat } { //setcolorscreen } ifelse } .bind odef +currentdict /.fixsethalftonescreen undef + % Redefine currentscreen and currentcolorscreen to extract the Frequency % and Angle from Type 1 halftones, per Adobe TN 5085. /.fixcurrenthalftonescreen % <dict> .fix... <freq> <angle> <proc> @@ -164,17 +170,17 @@ end } bind def /currentscreen % - currentscreen 60 0 <dict> { .currenthalftone - { { .fixcurrenthalftonescreen } % halftone + { { //.fixcurrenthalftonescreen exec }% halftone { } % screen { 12 3 roll 9 { pop } repeat % colorscreen - dup type /dicttype eq { .fixcurrenthalftonescreen } if + dup type /dicttype eq { //.fixcurrenthalftonescreen exec } if } } exch get exec } odef /currentcolorscreen % - currentcolorscreen (60 0 <dict>)*4 { .currenthalftone - { { .fixcurrenthalftonescreen 3 copy 6 copy } % halftone + { { //.fixcurrenthalftonescreen exec 3 copy 6 copy } % halftone { % screen % The procedure might not be readable.... dup rcheck { dup length array copy cvx } if @@ -184,12 +190,13 @@ end } exch get exec } odef +currentdict /.fixcurrenthalftonescreen undef % ------ User objects ------ % /.UserObjects { .userdict /UserObjects -} odef +} bind executeonly odef % In order to get proper error recovery behavior, we need to be careful % not to pop any operands from the stack until we're done. % The code below faithfully duplicates the apparent array-growing @@ -213,21 +220,22 @@ end .UserObjects 3 .argindex 1 add 10 .max .localvmarray put } ifelse .UserObjects get 2 .argindex 2 index put pop pop -} odef +} bind odef /execuserobject { % <index> execuserobject - dup type /integertype ne { % Adobe validates the argument before accessing UserObjects - CET 31-03 /execuserobject .systemvar /typecheck signalerror } if .UserObjects get 1 .argindex get exch pop exec -} odef +} bind odef /undefineuserobject { % <index> undefineuserobject - dup type /integertype ne { % Adobe validates the argument before accessing UserObjects - CET 31-11 /undefineuserobject .systemvar /typecheck signalerror } if .UserObjects get 1 .argindex //null put pop -} odef +} bind odef +currentdict /.UserObjects undef % ------ Cache control ------ % diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_dscp.ps b/Master/tlpkg/tlgs/Resource/Init/gs_dscp.ps index d1a668b9d8a..dad0ec30e2f 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_dscp.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_dscp.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 diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_epsf.ps b/Master/tlpkg/tlgs/Resource/Init/gs_epsf.ps index 2d0f6774716..b337f42856f 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_epsf.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_epsf.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 @@ -44,7 +44,7 @@ } { cleartomark //false } ifelse -} bind def +} bind executeonly odef % Crop the page to the BoundingBox /EPSBoundingBoxCrop { % llx lly urx ury -- @@ -54,7 +54,7 @@ exch 3 index sub exch 2 index sub % stack: llx lly urx-llx ury-lly << /PageSize [ 5 -2 roll ] >> setpagedevice neg exch neg exch translate -} bind def +} bind executeonly odef % Rescale, translate and rotate to fit the BoundingBox on the page /EPSBoundingBoxFitPage { % llx lly urx ury -- @@ -69,9 +69,18 @@ 6 index 10 index sub 6 index 10 index sub gt % bbox page-clipbox page-is-landscape bbox-is-landscape xor }{ - false + //false }ifelse - 9 1 roll % compute need-rotate. + dup 10 1 roll % need-rotate compute need-rotate. + + % if we are rotating the contents, we need to also rotate the + % bounding box of the content! + { + 8 -4 roll + exch 4 -2 roll exch 4 2 roll + 8 4 roll + } if + % stack: rotate-needed bbox page-clipbox % calculate scale to fit smaller of width or height exch 4 -1 roll sub 3 1 roll exch sub @@ -84,8 +93,8 @@ % translate to EPS -llx,-lly exch neg exch neg translate % Finally perform the rotate if needed. - { clippath pathbbox pop 0 exch translate 90 rotate pop pop } if -} bind def + { clippath pathbbox pop 0 translate 90 rotate pop pop } if +} bind executeonly odef /EPSBoundingBoxProcess { % (llx lly urx ury) state -- //systemdict /EPSBoundingBoxState get 1 index lt { @@ -121,7 +130,8 @@ } { pop pop } ifelse -} bind def +} bind executeonly odef + /ProcessEPSComment { % file comment -- file comment /EPSBoundingBoxState .systemvar 3 lt { @@ -184,19 +194,20 @@ } ifelse } ifelse } if -} bind def +} bind executeonly def % Install EPS handler for DSC comments, which we do later /EPSBoundingBoxInit { systemdict /NOEPS known not { % Merge ProcessEPSComment with existing handler - /ProcessEPSComment load /exec load + //ProcessEPSComment /exec load currentuserparams /ProcessDSCComment get dup //null eq {pop {pop pop}} if /exec load 4 array astore cvx readonly << /ProcessDSCComment 3 -1 roll >> setuserparams } if -} bind def +} bind executeonly odef + /.runNoEPS /run load def @@ -206,13 +217,13 @@ /runEPS_op_count count 2 sub def /runEPS_page_count currentpagedevice /PageCount get def 0 EPSBoundingBoxSetState - .runNoEPS + //.runNoEPS currentpagedevice /PageCount get runEPS_page_count sub 0 eq { /showpage load exec } if count runEPS_op_count sub {pop} repeat countdictstack runEPS_dict_count sub {end} repeat runEPS_save restore -} bind def +} bind executeonly odef /run { % file OR string -- dup type /filetype ne { (r) file } if @@ -223,29 +234,29 @@ pop pop pop EPSDEBUG {(runEPS: Found EPS\n) print flush} if systemdict /NOEPS known { - cvx .runNoEPS + cvx //.runNoEPS } { cvx .runEPS } ifelse } { EPSDEBUG {(runEPS: Normal DSC\n) print flush} if pop - cvx .runNoEPS + cvx //.runNoEPS } ifelse } { EPSDEBUG {(runEPS: Short DSC\n) print flush} if pop - cvx .runNoEPS + cvx //.runNoEPS } ifelse } { EPSDEBUG {(runEPS: Not DSC\n) print flush} if - cvx .runNoEPS + cvx //.runNoEPS } ifelse } { EPSDEBUG {(runEPS: Short non-DSC\n) print flush} if pop - cvx .runNoEPS + cvx //.runNoEPS } ifelse } bind odef @@ -278,7 +289,7 @@ % Now interpret the PostScript. exch () /SubFileDecode filter cvx run } - { .runnoepsf + { //.runnoepsf } ifelse } odef @@ -289,3 +300,17 @@ userdict begin { (%stdin) run } execute0 } bind def end + +% undefine things defined in this file and not referenced elsewhere +[ + /.runNoEPS + /.runnoepsf + /.runEPS + /EPSBoundingBoxSetState + /EPSBoundingBoxCrop + /EPSBoundingBoxFitPage + /EPSBoundingBoxParse + /EPSBoundingBoxProcess + /ProcessEPSComment +] +{currentdict exch .forceundef} forall diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_fapi.ps b/Master/tlpkg/tlgs/Resource/Init/gs_fapi.ps index ac3c27d299b..53b744604fa 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_fapi.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_fapi.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 diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_fntem.ps b/Master/tlpkg/tlgs/Resource/Init/gs_fntem.ps index c1f7651f18c..196c8641418 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_fntem.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_fntem.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 @@ -401,12 +401,12 @@ currentdict end def .forceput % FontInfo can be read-only. pop % bool <font> exit - } if + } executeonly if dup /FontInfo get % bool <font> <FI> /GlyphNames2Unicode /Unicode /Decoding findresource .forceput % FontInfo can be read-only. exit - } loop + } executeonly loop exch setglobal } .bind executeonly odef % must be bound and hidden for .forceput diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_fonts.ps b/Master/tlpkg/tlgs/Resource/Init/gs_fonts.ps index 803faca4918..c47f6e57767 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_fonts.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_fonts.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 @@ -24,11 +24,18 @@ % consistent with the one specified here. /defaultfontmap (Fontmap) def +% we have to set .languagelevel to 2 so the parser will accept the names +% '<<' and '>>', then we use a local definition here. +.languagelevel 2 .setlanguagelevel /defaultfontmap_content 50 dict -1 dict begin +4 dict begin +(<<) cvn /mark load def +(>>) cvn /.dicttomark load def /; { 2 index 3 1 roll .growput } bind def %% Replace 0 (Fontmap) end def +.setlanguagelevel + % ------ End of editable parameters ------ % @@ -45,7 +52,7 @@ end def % Define a reliable way of accessing FontDirectory in systemdict. /.FontDirectory { /FontDirectory .systemvar -} .bind odef +} .bind executeonly odef % Define a temporary string for local use, since using =string % interferes with some PostScript programs. @@ -88,6 +95,18 @@ userdict /.nativeFontmap .FontDirectory maxlength dict put {.readFontmap} 0 get 1 .quit } if % stack: dict file fontname filename|aliasname + dup type /nametype eq + { + dup (<<) cvn eq + { + pop mark + { + counttomark 2 add index token not {//false exit} if + dup (>>) cvn eq {pop //true exit} if + } loop + { .dicttomark }{cleartomark} ifelse + } if + } if 1 index type /stringtype eq 1 index type /nametype eq and 1 index xcheck and 1 index /run eq 2 index /.runlibfile eq or and { @@ -100,7 +119,7 @@ userdict /.nativeFontmap .FontDirectory maxlength dict put { 2 index token not { (Fontmap entry for ) print 1 index =only ( ends prematurely! Giving up.) = flush - {.loadFontmap} 0 get 1 .quit + {//.loadFontmap exec} 0 get 1 .quit } if dup /; eq { pop 3 index 3 1 roll .growput exit } if pop @@ -172,7 +191,7 @@ userdict /.nativeFontmap .FontDirectory maxlength dict put % <file> <key> .findfontvalue false % Closes the file in either case. exch dup read { - 2 copy unread 16#80 eq { + 2 copy .unread 16#80 eq { dup (xxxxxx) readstring pop pop % skip .PFB header } if { % Stack: key file @@ -191,7 +210,7 @@ userdict /.nativeFontmap .FontDirectory maxlength dict put % Stack: key file false dup { 4 } { 3 } ifelse -2 roll closefile pop } { closefile pop //false } ifelse -} bind def +} bind executeonly def /.findfontname { /FontName .findfontvalue } bind def @@ -202,6 +221,14 @@ NOFONTPATH { /FONTPATH () def } if { pop } { /FONTPATH (GS_FONTPATH) getenv not { () } if def } ifelse + +% The following are dummy definitions that, if we have a FONTPATH, will +% be replaced in the following section. +% They are here so immediately evaulation will work, and allow them to +% undefined at the bottom of the file. +/.scanfontbegin{} bind def +/.scanfontdir {} bind def + FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if /FONTPATH [ FONTPATH .pathlist ] def @@ -242,12 +269,12 @@ FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if /.scanfontbegin { % Construct the table of all file names already in Fontmap. currentglobal //true setglobal - .scanfontdict dup maxlength Fontmap length 2 add .max .setmaxlength + //.scanfontdict dup maxlength Fontmap length 2 add .max .setmaxlength Fontmap { exch pop { dup type /stringtype eq - { .splitfilename pop .fonttempstring copy .lowerstring cvn - .scanfontdict exch //true put + { //.splitfilename exec pop //.fonttempstring copy //.lowerstring exec cvn + //.scanfontdict exch //true put } { pop } @@ -280,9 +307,9 @@ FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if /txt //true .dicttomark def /.scan1fontstring 8192 string def -% %%BeginFont: is not per Adobe documentation, but a few fonts have it. +% BeginFont: is not per Adobe documentation, but a few fonts have it. /.scanfontheaders [(%!PS-Adobe*) (%!FontType*) (%%BeginFont:*)] def -0 .scanfontheaders { length .max } forall 6 add % extra for PFB header +0 //.scanfontheaders { length .max } forall 6 add % extra for PFB header /.scan1fontfirst exch string def /.scanfontdir % <dirname> .scanfontdir - { currentglobal exch //true setglobal @@ -291,16 +318,16 @@ FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if 0 0 0 4 -1 roll % found scanned files { % stack: <fontcount> <scancount> <filecount> <filename> exch 1 add exch % increment filecount - dup .splitfilename .fonttempstring copy .lowerstring + dup //.splitfilename exec //.fonttempstring copy //.lowerstring exec % stack: <fontcount> <scancount> <filecount+1> <filename> % <BASE> <ext> - .scanfontskip exch known exch .scanfontdict exch known or + //.scanfontskip exch known exch //.scanfontdict exch known or { pop % stack: <fontcount> <scancount> <filecount+1> } { 3 -1 roll 1 add 3 1 roll % stack: <fontcount> <scancount+1> <filecount+1> <filename> - dup (r) { file } .internalstopped + dup (r) { file } //.internalstopped exec { pop pop //null () % stack: <fontcount> <scancount+1> <filecount+1> <filename> % null () @@ -309,7 +336,7 @@ FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if % On some platforms, the file operator will open directories, % but an error will occur if we try to read from one. % Handle this possibility here. - dup .scan1fontfirst { readstring } .internalstopped + dup //.scan1fontfirst { readstring } //.internalstopped exec { pop pop () } { pop } ifelse @@ -322,20 +349,22 @@ FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if { dup length 6 sub 6 exch getinterval } if % Check for font file headers. - //false .scanfontheaders + //false //.scanfontheaders { 2 index exch .stringmatch or } forall exch pop { % stack: <fontcount> <scancount+1> <filecount+1> <filename> % <file> - dup 0 setfileposition .findfontname + dup 0 setfileposition //.findfontname exec { dup .nativeFontmap exch known { pop pop } - { exch copystring exch + { exch + dup length string copy % copy string + exch DEBUG { ( ) print dup =only flush } if - 1 index .definenativefontmap - .splitfilename pop //true .scanfontdict 3 1 roll .growput + 1 index //.definenativefontmap exec + //.splitfilename exec pop //true //.scanfontdict 3 1 roll .growput % Increment fontcount. 3 -1 roll 1 add 3 1 roll } @@ -352,7 +381,7 @@ FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if } ifelse } - .scan1fontstring filenameforall + //.scan1fontstring filenameforall QUIET { pop pop pop } { ( ) print =only ( files, ) print =only ( scanned, ) print @@ -361,7 +390,7 @@ FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if ifelse pop setglobal - } bind def + } bind executeonly def %END FONTPATH @@ -374,7 +403,7 @@ FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if /.setnativefontmapbuilt { % set whether we've been run dup type /booleantype eq { systemdict exch /.nativefontmapbuilt exch .forceput - } + } executeonly {pop} ifelse } .bind executeonly odef @@ -395,14 +424,14 @@ systemdict /NONATIVEFONTMAP known .setnativefontmapbuilt { % stack: [ (name) (path) ] % verify the font name ourselves - dup 1 get (r) { file } .internalstopped + dup 1 get (r) { file } //.internalstopped exec { % skip the entry if we can't open the returned path pop pop pop }{ % we could open the font file mark 2 1 roll - {.findfontname} .internalstopped + {//.findfontname exec} //.internalstopped exec { cleartomark pop @@ -413,16 +442,15 @@ systemdict /NONATIVEFONTMAP known .setnativefontmapbuilt % DEBUG { ( found ) print dup print (\n) print flush } if % add entry to the fontmap 1 index exch 0 exch dup type /nametype ne {cvn} if put - aload pop .definenativefontmap + aload pop //.definenativefontmap exec } ifelse } ifelse } forall } if % record that we've been run - //true .setnativefontmapbuilt + //true //.setnativefontmapbuilt } ifelse -} bind def -currentdict /.setnativefontmapbuilt .forceundef +} bind executeonly odef % Create the dictionary that registers the .buildfont procedure % (called by definefont) for each FontType. @@ -443,8 +471,8 @@ buildfontdict 3 /.buildfont3 cvx put % added entry, making sure there is at least one slot left for FID. dup maxlength 1 index length sub 2 lt { dup dup wcheck - { .growdict } - { .growdictlength dict .copydict } + { //.growdict exec} + { //.growdictlength exec dict .copydict } ifelse } { dup wcheck not { dup maxlength dict .copydict } if @@ -455,7 +483,7 @@ buildfontdict 3 /.buildfont3 cvx put { % Check for disabled platform fonts. NOPLATFONTS { % Make sure we leave room for FID. - .growfontdict dup /ExactSize 0 put + //.growfontdict exec dup /ExactSize 0 put } { % Hack: if the Encoding looks like it might be the % Symbol or Dingbats encoding, load those now (for the @@ -502,7 +530,7 @@ buildfontdict 3 /.buildfont3 cvx put } if readonly % stack: name fontdict } stopped { $error /command get /invalidfont signalerror } if -} bind def +} bind executeonly odef /definefont { dup rcheck not { /definefont cvx /invalidaccess signalerror @@ -512,21 +540,22 @@ buildfontdict 3 /.buildfont3 cvx put % the font in LocalFontDirectory. .currentglobal { //systemdict /LocalFontDirectory .knownget - { 2 index 2 index { .growput } systemdict /superexec known {//superexec}{1183615869 internaldict /superexec get exec} ifelse } % readonly + { 2 index 2 index .forceput } % readonly if } if - dup .FontDirectory 4 -2 roll { .growput } systemdict /superexec known {//superexec}{1183615869 internaldict /superexec get exec} ifelse % readonly + dup //.FontDirectory 4 -2 roll .forceput % readonly % If the font originated as a resource, register it. currentfile .currentresourcefile eq { dup .registerfont } if readonly - } odef + } .bind executeonly odef % Define a procedure for defining aliased fonts. % We use this only for explicitly aliased fonts, not substituted fonts: % we think this matches the observed behavior of Adobe interpreters. /.aliasfont % <name> <font> .aliasfont <newFont> - { .currentglobal 3 1 roll dup .gcheck .setglobal + { + currentglobal 3 1 roll dup gcheck setglobal % <bool> <name> <font> dup length 2 add dict % <bool> <name> <font> <dict> dup 3 -1 roll % <bool> <name> <dict> <dict> <font> @@ -541,7 +570,7 @@ buildfontdict 3 /.buildfont3 cvx put % whose FontName is a local non-string, if someone passed a % garbage value to findfont. In this case, just don't % call definefont at all. - 2 index dup type /stringtype eq exch .gcheck or 1 index .gcheck not or + 2 index dup type /stringtype eq exch gcheck or 1 index gcheck not or { pop % <bool> <name> <dict> 1 index dup type /stringtype eq { cvn } if % <bool> <name> <dict> <name1> @@ -566,11 +595,12 @@ buildfontdict 3 /.buildfont3 cvx put % Don't bind in definefont, since Level 2 redefines it. /definefont .systemvar exec } - { /findfont cvx {.completefont} .errorexec pop exch pop + { + /findfont cvx {.completefont} //.errorexec exec pop exch pop } ifelse - exch .setglobal - } odef % so findfont will bind it + exch setglobal + } bind executeonly odef % so findfont will bind it % Define .loadfontfile for loading a font. If we recognize Type 1 and/or % TrueType fonts, gs_type1.ps and/or gs_ttf.ps will redefine this. @@ -669,10 +699,19 @@ buildfontdict 3 /.buildfont3 cvx put [(Cn) 4] [(Cond) 4] [(Narrow) 4] [(Pkg) 4] [(Compr) 4] [(Serif) 8] [(Sans) -8] ] readonly def + +/.fontnamestring { % <fontname> .fontnamestring <string|name> + dup type dup /nametype eq { + pop .namestring + } { + /stringtype ne { pop () } if + } ifelse +} bind def + /.fontnameproperties { % <int> <string|name> .fontnameproperties % <int'> - .fontnamestring - .substituteproperties { + //.fontnamestring exec + //.substituteproperties { 2 copy 0 get search { pop pop pop dup length 1 sub 1 exch getinterval 3 -1 roll exch { dup 0 ge { or } { neg not and } ifelse @@ -710,13 +749,7 @@ buildfontdict 3 /.buildfont3 cvx put % <other> .nametostring <other> dup type /nametype eq { .namestring } if } bind def -/.fontnamestring { % <fontname> .fontnamestring <string|name> - dup type dup /nametype eq { - pop .namestring - } { - /stringtype ne { pop () } if - } ifelse -} bind def + /.substitutefontname { % <fontname> <properties> .substitutefontname % <altname|null> % Look for properties and/or a face name in the font name. @@ -724,7 +757,7 @@ buildfontdict 3 /.buildfont3 cvx put % base font; otherwise, use the default font. % Note that the "substituted" font name may be the same as % the requested one; the caller must check this. - exch .fontnamestring { + exch //.fontnamestring exec { defaultfontname /Helvetica-Oblique /Helvetica-Bold /Helvetica-BoldOblique /Helvetica-Narrow /Helvetica-Narrow-Oblique /Helvetica-Narrow-Bold /Helvetica-Narrow-BoldOblique @@ -734,28 +767,28 @@ buildfontdict 3 /.buildfont3 cvx put } 3 1 roll % Stack: facelist properties fontname % Look for a face name. - .substitutefaces { + //.substitutefaces { 2 copy 0 get search { pop pop pop % Stack: facelist properties fontname [(pattern) family properties] dup 2 get 4 -1 roll or 3 1 roll - 1 get .substitutefamilies exch get + 1 get //.substitutefamilies exch get 4 -1 roll pop 3 1 roll } { pop pop } ifelse } forall pop 1 index length mod get exec -} bind def +} bind executeonly odef /.substitutefont { % <fontname> .substitutefont <altname> - dup 0 exch .fontnameproperties .substitutefontname + dup 0 exch //.fontnameproperties exec .substitutefontname % Only accept fonts known in the Fontmap. Fontmap 1 index known not { .nativeFontmap 1 index known not {pop defaultfontname } if } if -} bind def +} bind executeonly odef % If requested, make (and recognize) fake entries in FontDirectory for fonts % present in Fontmap but not actually loaded. Thanks to Ray Johnston for @@ -814,7 +847,7 @@ FAKEFONTS not { (%END FAKEFONTS) .skipeof } if counttomark 1 sub { .aliasfont } repeat end % <fontname> mark <font> exch pop exch pop -} odef +} bind odef /findfont { .findfont } bind def @@ -860,7 +893,7 @@ FAKEFONTS not { (%END FAKEFONTS) .skipeof } if } { dup .substitutefont 2 copy eq { pop defaultfontname } if - .checkalias + //.checkalias exec QUIET not { SHORTERRORS { (%%[) print 1 index =only @@ -872,7 +905,7 @@ FAKEFONTS not { (%END FAKEFONTS) .skipeof } if } if } ifelse /Font findresource -} bind def +} bind executeonly def % Default font substitution does {pop /Courier} om many implementations. % GS post-process font substitution in .stdsubstfont and uses {} for @@ -886,8 +919,8 @@ $error /SubstituteFont { } put //null 0 1 FONTPATH length 1 sub { FONTPATH 1 index get //null ne { exch pop exit } if pop } for dup //null ne { - dup 0 eq { .scanfontbegin } if - FONTPATH 1 index get .scanfontdir + dup 0 eq { //.scanfontbegin exec} if + FONTPATH 1 index get //.scanfontdir exec FONTPATH exch //null put //true } { pop //false @@ -897,11 +930,10 @@ $error /SubstituteFont { } put % scanning of FONTPATH. /.dofindfont { % mark <fontname> .dofindfont % mark <alias> ... <font> .tryfindfont not { - % We didn't find the font. If we haven't scanned % all the directories in FONTPATH, scan the next one % now and look for the font again. - .scannextfontdir { + //.scannextfontdir exec { % Start over with an empty alias list. counttomark 1 sub { pop } repeat % mark <fontname> .dofindfont @@ -927,6 +959,7 @@ $error /SubstituteFont { } put } if % Substitute for the font. Don't alias. % Same stack as at the beginning of .dofindfont. + $error /SubstituteFont get exec % % igorm: I guess the surrounding code assumes that .stdsubstfont @@ -935,104 +968,24 @@ $error /SubstituteFont { } put % used in .dofindfont and through .stdsubstfont % just to represent a simple iteration, % which accumulates the aliases after the mark. - .stdsubstfont + //.stdsubstfont exec } ifelse } ifelse } if -} bind def -% Try to find a font using only the present contents of Fontmap. -/.tryfindfont { % <fontname> .tryfindfont <font> true - % <fontname> .tryfindfont false - .FontDirectory 1 index .fontknownget - { % Already loaded - exch pop //true - } - { - dup Fontmap exch .knownget - { //true //true } - { % Unknown font name. Look for a file with the - % same name as the requested font. - dup .tryloadfont - { exch pop //true //false } - { - % if we can't load by name check the native font map - dup .nativeFontmap exch .knownget - { //true //true } - { //false //false } ifelse - } ifelse - } ifelse - - { % Try each element of the Fontmap in turn. - pop - //false exch % (in case we exhaust the list) - % Stack: fontname false fontmaplist - { exch pop - dup type /nametype eq - { % Font alias - .checkalias .tryfindfont exit - } - { dup dup type dup /arraytype eq exch /packedarraytype eq or exch xcheck and - { % Font with a procedural definition - exec % The procedure will load the font. - % Check to make sure this really happened. - .FontDirectory 1 index .knownget - { exch pop //true exit } - if - } - { % Font file name - //true .loadfontloop { //true exit } if - } - ifelse - } - ifelse //false - } - forall - % Stack: font true -or- fontname false - { //true - } - { % None of the Fontmap entries worked. - % Try loading a file with the same name - % as the requested font. - .tryloadfont - } - ifelse - } - if - } - ifelse - } bind def +} bind executeonly def % any user of .putgstringcopy must use bind and executeonly /.putgstringcopy % <dict> <name> <string> .putgstringcopy - { 2 index gcheck currentglobal 2 copy eq { pop pop .forceput - } { + } executeonly { 5 1 roll setglobal dup length string copy .forceput setglobal - } ifelse + } executeonly ifelse } .bind executeonly odef % must be bound and hidden for .forceput -% Attempt to load a font from a file. -/.tryloadfont { % <fontname> .tryloadfont <font> true - % <fontname> .tryloadfont false - dup .nametostring - % Hack: check for the presence of the resource machinery. - /.genericrfn where { - pop - pop dup .fonttempstring /FontResourceDir getsystemparam .genericrfn - {//false .loadfontloop} .internalstopped {//false} if { - //true - } { - dup .nametostring - {//true .loadfontloop} .internalstopped {//false} if - } ifelse - } { - {//true .loadfontloop} .internalstopped {//false} if - } ifelse -} bind def - /.loadfontloop { % <fontname> <filename> <libflag> .loadfontloop % <font> true % -or- @@ -1081,11 +1034,11 @@ $error /SubstituteFont { } put % because it's different depending on language level. .currentglobal exch /.setglobal .systemvar exec % Remove the fake definition, if any. - .FontDirectory 3 index .forceundef % readonly - 1 index (r) file .loadfont .FontDirectory exch + //.FontDirectory 3 index .forceundef % readonly + 1 index (r) file .loadfont //.FontDirectory exch /.setglobal .systemvar exec - } - { .loadfont .FontDirectory + } executeonly + { .loadfont //.FontDirectory } ifelse % Stack: fontname fontfilename fontdirectory @@ -1102,25 +1055,25 @@ $error /SubstituteFont { } put } if % Check to make sure the font was actually loaded. - dup 3 index .fontknownget - { dup /PathLoad 4 index .putgstringcopy + dup 3 index //.fontknownget exec + { dup /PathLoad 4 index //.putgstringcopy 4 1 roll pop pop pop //true exit - } if + } executeonly if % Maybe the file had a different FontName. % See if we can get a FontName from the file, and if so, % whether a font by that name exists now. exch dup % Stack: origfontname fontdirectory path path - (r) file .findfontname + (r) file //.findfontname exec { % Stack: origfontname fontdirectory path filefontname - 2 index 1 index .fontknownget + 2 index 1 index //.fontknownget exec { % Yes. Stack: origfontname fontdirectory path filefontname fontdict - dup 4 -1 roll /PathLoad exch .putgstringcopy + dup 4 -1 roll /PathLoad exch //.putgstringcopy % Stack: origfontname fontdirectory filefontname fontdict 3 -1 roll pop % Stack: origfontname filefontname fontdict - dup /FontName get dup FontDirectory exch .forceundef - GlobalFontDirectory exch .forceundef + dup /FontName get dup //.FontDirectory exch .forceundef + /GlobalFontDirectory .systemvar exch .forceundef dup length dict .copydict dup 3 index /FontName exch put 2 index exch definefont exch @@ -1134,9 +1087,9 @@ $error /SubstituteFont { } put ifelse % Stack: origfontname fontdict exch pop //true exit % Stack: fontdict - } + } executeonly if pop % Stack: origfontname fontdirectory path - } + } executeonly if pop pop % Stack: origfontname % The font definitely did not load correctly. @@ -1150,7 +1103,111 @@ $error /SubstituteFont { } put } bind executeonly odef % must be bound and hidden for .putgstringcopy -currentdict /.putgstringcopy .undef +% Attempt to load a font from a file. +/.tryloadfont { % <fontname> .tryloadfont <font> true + % <fontname> .tryloadfont false + dup //.nametostring exec + % Hack: check for the presence of the resource machinery. + /.genericrfn where { + pop + pop dup //.fonttempstring /FontResourceDir getsystemparam .genericrfn + {//false .loadfontloop} //.internalstopped exec {//false} if { + //true + } { + dup //.nametostring exec + {//true .loadfontloop} //.internalstopped exec {//false} if + } ifelse + } { + {//true .loadfontloop} //.internalstopped exec {//false} if + } ifelse +} bind def + +% Try to find a font using only the present contents of Fontmap. +/.tryfindfont { % <fontname> .tryfindfont <font> true + % <fontname> .tryfindfont false + //.FontDirectory 1 index //.fontknownget exec + { % Already loaded + exch pop //true + } + { + dup Fontmap exch .knownget + { //true //true } + { % Unknown font name. Look for a file with the + % same name as the requested font. + dup //.tryloadfont exec + { exch pop //true //false } + { + % if we can't load by name check the native font map + dup .nativeFontmap exch .knownget + { //true //true } + { //false //false } ifelse + } ifelse + } ifelse + + { % Try each element of the Fontmap in turn. + pop + //false exch % (in case we exhaust the list) + % Stack: fontname false fontmaplist + { exch pop + dup type /nametype eq + { % Font alias + //.checkalias exec + dup .tryfindfont + { + % We don't want to reuse an embedded font as a substitute + % so make sure the font came from disk before using it. + dup /Path known + 1 index /PathLoad known or + { exch pop //true exit } + { + % if the candidate didn't come from disk, remove it from + % FontDirectory and try again. + pop dup undefinefont + .tryfindfont exit + } + ifelse + } if + } + { dup dup type dup /arraytype eq exch /packedarraytype eq or exch xcheck and + { % Font with a procedural definition + exec % The procedure will load the font. + % Check to make sure this really happened. + //.FontDirectory 1 index .knownget + { exch pop //true exit } + if + } + { % Font file name + dup type /dicttype eq + { + begin + Path + } + { + 1 dict begin + } ifelse + //true .loadfontloop + end + { //true exit } if + } + ifelse + } + ifelse //false + } + forall + % Stack: font true -or- fontname false + { //true + } + { % None of the Fontmap entries worked. + % Try loading a file with the same name + % as the requested font. + //.tryloadfont exec + } + ifelse + } + if + } + ifelse + } bind executeonly def % Define a procedure to load all known fonts. % This isn't likely to be very useful. @@ -1176,25 +1233,25 @@ currentdict /.putgstringcopy .undef { { pop dup type /stringtype eq { cvn } if - .FontDirectory 1 index known not { + //.FontDirectory 1 index known not { 2 dict dup /FontName 3 index put dup /FontType 1 put - .FontDirectory 3 1 roll { put } systemdict /superexec known {//superexec}{1183615869 internaldict /superexec get exec} ifelse % readonly + //.FontDirectory 3 1 roll //.forceput exec % readonly } { pop } ifelse } forall } forall - } + } executeonly % hide .forceput FAKEFONTS { exch } if pop def % don't bind, .current/setglobal get redefined % Install initial fonts from Fontmap. /.loadinitialfonts { NOFONTMAP not { /FONTMAP where - { pop [ FONTMAP .pathlist ] + { pop [ FONTMAP //.pathlist exec] { dup VMDEBUG findlibfile - { exch pop .loadFontmap } + { exch pop //.loadFontmap exec } { /undefinedfilename signalerror } ifelse } @@ -1204,11 +1261,11 @@ FAKEFONTS { exch } if pop def % don't bind, .current/setglobal get redefined //false .file_name_combine { dup VMDEBUG - (r) { file } .internalstopped { + (r) { file } //.internalstopped exec { pop pop defaultfontmap_content { .definefontmap } forall } { - .loadFontmap + //.loadFontmap exec } ifelse } { pop pop @@ -1219,56 +1276,21 @@ FAKEFONTS { exch } if pop def % don't bind, .current/setglobal get redefined } if userdict /defaultfontmap_content .undef - .definefakefonts % current VM is global + //.definefakefonts exec % current VM is global } def % don't bind, .current/setglobal get redefined -% ---------------- Synthetic font support ---------------- % - -% Create a new font by modifying an existing one. paramdict contains -% entries with the same keys as the ones found in a Type 1 font; -% it should also contain enough empty entries to allow adding the -% corresponding non-overridden entries from the original font dictionary, -% including FID. If paramdict includes a FontInfo entry, this will -% also override the original font's FontInfo, entry by entry; -% again, it must contain enough empty entries. - -% Note that this procedure does not perform a definefont. - -/.makemodifiedfont % <fontdict> <paramdict> .makemodifiedfont <fontdict'> - { exch - { % Stack: destdict key value - 1 index /FID ne - { 2 index 2 index known - { % Skip fontdict entry supplied in paramdict, but - % handle FontInfo specially. - 1 index /FontInfo eq - { 2 index 2 index get % new FontInfo - 1 index % old FontInfo - { % Stack: destdict key value destinfo key value - 2 index 2 index known - { pop pop } - { 2 index 3 1 roll put } - ifelse - } - forall pop - } - if - } - { % No override, copy the fontdict entry. - 2 index 3 1 roll put - dup dup % to match pop pop below - } - ifelse - } - if - pop pop - } forall - } bind def - -% Make a modified font and define it. Note that unlike definefont, -% this does not leave the font on the operand stack. - -/.definemodifiedfont % <fontdict> <paramdict> .definemodifiedfont - - { .makemodifiedfont - dup /FontName get exch definefont pop - } bind def +% Undef these, not needed outside this file +[ + % /.fonttempstring /.scannextfontdir - are also used in gs_res.ps, so are undefined there + % /.scanfontheaders - used in gs_cff.ps, gs_ttf.ps + /.loadfontloop /.tryloadfont /.findfont /.pathlist /.loadFontmap /.lowerstring + /.splitfilename /.scanfontdict /.scanfontbegin + /.scanfontskip /.scan1fontstring + /.scan1fontfirst /.scanfontdir + /.setnativefontmapbuilt /.aliasfont + /.setloadingfont /.substitutefaces /.substituteproperties /.substitutefamilies + /.nametostring /.fontnamestring /.checkalias /.fontknownget /.stdsubstfont + /.putgstringcopy + /.definenativefontmap + /.findfontname +] {systemdict exch .forceundef} forall diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_frsd.ps b/Master/tlpkg/tlgs/Resource/Init/gs_frsd.ps index 49ea61062b1..c4ed1cb0b5e 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_frsd.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_frsd.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 @@ -46,7 +46,7 @@ level2dict begin % If AsyncRead is true, try to create the filter directly. % Stack: dict filters parms CloseSource source 4 index /AsyncRead .knownget not { //false } if { - 1 index { .reusablestream } .internalstopped + 1 index { .reusablestream } //.internalstopped exec } { //null //true } ifelse { diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_icc.ps b/Master/tlpkg/tlgs/Resource/Init/gs_icc.ps index 4ff59c6ef7d..6a4e88a0f73 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_icc.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_icc.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 @@ -103,6 +103,8 @@ dup //null eq {pop {pop pop}} if /exec load 4 array astore cvx readonly << /ProcessDSCComment 3 -1 roll >> setuserparams +currentdict /.ProcessICCcomment .undef + end % systemdict %END PSICC .setglobal diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_il1_e.ps b/Master/tlpkg/tlgs/Resource/Init/gs_il1_e.ps index 99933c8a1e1..3de6ab5c950 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_il1_e.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_il1_e.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 diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_img.ps b/Master/tlpkg/tlgs/Resource/Init/gs_img.ps index 273c18b10dd..be1dc8fd298 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_img.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_img.ps @@ -46,7 +46,7 @@ % implemented in this file as well. % % In this implementation, all sampled objects are passed through one of -% the internal operators .image1, .imagemask1, .image1alpha, .image2, +% the internal operators .image1, .imagemask1, .image2, % .image3, or .image4, each of which handles a specific ImageType value. % % The procedures in this file are responsible for constructing @@ -115,22 +115,6 @@ def 5 dict dup 1 /.imagemask1 load put def -end -.setglobal - -% -% Build a dictionary of utility procedures and constants for use in -% impelementing the image operators. This dictionary is in global VM but -% is maintained (during initialization) in userdict. It should be pushed -% onto the dictionary stack when constructing image-related procedures -% and pseudo-operators. -% -% This dictionary is removed from userdict when initialization is -% completed. -% -.currentglobal //true .setglobal -userdict /img_utils_dict 30 dict put -img_utils_dict begin % % Some useful local data structures: @@ -318,56 +302,49 @@ def % % <width> <height> <bits/component> <matrix> <dsrc0> ... -% <multi> <ncomp> <has_alpha> +% <multi> <ncomp> % img_build_image_dict -% <dict> <has_alpha> +% <dict> % % Build the dictionary corresponding to a colorimage operand stack. This % routine will check just enough of the stack to verify that the % dictionary can be built, and will generate the appropriate error if this % is not the case. % -% The <has_alpha> boolean is used to support the Next alphaimage extension. -% % At the first level, errors in this procedure are reported as colorimage % errors. The error actually reported will usually be determined by the % pseudo-operator which invokes this routine. % /img_build_image_dict { - % Veify that at least 8 operands are available, and that the top three + % Verify that at least 7 operands are available, and that the top two % operands have the expected types - count 8 lt + count 7 lt { /.colorimage cvx /stackunderflow signalerror } if - 3 copy - type /booleantype ne exch - type /integertype ne or exch + 2 copy + type /integertype ne exch type /booleantype ne or { /.colorimage cvx /typecheck signalerror } if % verify that the number of components is 1, 3, or 4 - 1 index 1 lt 2 index 2 eq or 2 index 4 gt or + dup 1 lt 1 index 2 eq or 1 index 4 gt or { /.colorimage cvx /rangecheck signalerror } if % Verify that the required number of operands are present if multiple % data sources are being used. If this test is successful, convert % the data sources to an array (in local VM). - 2 index + 1 index { - % if an alpha component is present, this adds one more component - 2 copy - { 1 add } - if - dup count 9 sub gt - { + dup dup count 8 sub gt + { % Adobe interpreters appear to test the arguments sequentially % starting from the top of the stack and report the 1st error found. % To satisfy CET test 12-02.PS we emulate this logic. //true exch -1 1 - { 3 add index + { 2 add index //good_image_types 1 index type .knownget { exec and } @@ -388,14 +365,14 @@ def % build the DataSource array in local VM dup .currentglobal //false .setglobal exch array exch .setglobal - % stack: <w> <h> <bps> <mtx> <d0> ... <multi> <n> <alpha> <n'> <array> - 5 1 roll 4 add 3 roll astore 4 1 roll + % stack: <w> <h> <bps> <mtx> <d0> ... <multi> <n> <n'> <array> + 4 1 roll 3 add 2 roll astore 3 1 roll } if % the image dictionary can be built; do so - % stack: <w> <h> <bps> <mtx> <dsrc|dsrc_array> <multi> <n> <alpha> - 8 1 roll //img_params_ary //img_build_dict exec exch + % stack: <w> <h> <bps> <mtx> <dsrc|dsrc_array> <multi> <n> + //img_params_ary //img_build_dict exec } .bind def currentdict /good_image_types .undef @@ -408,8 +385,7 @@ currentdict /good_image_types .undef % % If the top entry of the stack is a dictionary that has the keys required % by a colorimage dictionary, unpack that dictionary onto the stack. -% Otherwise just leave things as they are. Note that the <has_alpha> -% parameter is not pushd onto the stack. +% Otherwise just leave things as they are. % /img_unbuild_image_dict { @@ -482,29 +458,26 @@ currentdict /good_image_types .undef % % <width> <height> <bits/component> <matrix> <dsrc_0> ... -% <multi> <ncomp> <has_alpha> +% <multi> <ncomp> % .colorimage % - % % Convert the image/colorimage operator from their traditional form to -% the dictionary form. The <has_alpha> operand is used ot support the -% Next alphaimage extension. +% the dictionary form. % % Error handling for these operators is a bit complex, due to the stack % handling required of operators that potentially invoke procedures. % This problem is discussed in the comment above. The facts relevant to % this particular implementation are: % -% 1. The .image1 (or .alphaimage) operator is executed in a stopped +% 1. The .image1 operator is executed in a stopped % context, so that we can undo the gsave context in the event of % an error. % % 2. In the event of an error, the stack is examined to see if the -% dictionary passed to .image1 (.alphaimage) is still present. +% dictionary passed to .image1 is still present. % If so, this dictionary is "unpacked" onto the stack to re- -% create the original stack. The <has_alpha> parameter is not -% pushed onto the stack, as it is not required for any of the -% pseudo-operators than invoke this procedure. +% create the original stack. % % 3. The use of pseudo-operators in this case may yield incorrect % results for late-detected errors, as the stack depth will be @@ -522,14 +495,12 @@ currentdict /good_image_types .undef gsave % The CET test file 12-02.ps creates colorimages with a width and % height of 0. Ignore these since that is what the CET expects. - 1 index dup /Height get 0 eq exch /Width get 0 eq or - { pop pop } % Ignore colorimage. Pop bool and dict + dup dup /Height get 0 eq exch /Width get 0 eq or + { pop } % Ignore colorimage. Pop dict { 0 .setoverprintmode % disable overprint mode for images - //img_csary 2 index /IMG_NComps get get setcolorspace - { .alphaimage } - { .image1 } - ifelse + //img_csary 1 index /IMG_NComps get get setcolorspace + .image1 } ifelse } @@ -558,7 +529,6 @@ systemdict /setcolorscreen .knownget { /colorimage { - //false //.colorimage stopped { /colorimage .systemvar $error /errorname get signalerror } @@ -656,7 +626,7 @@ if ifelse } { - //false 1 //false + //false 1 //.colorimage stopped { /image .systemvar $error /errorname get signalerror } @@ -664,7 +634,7 @@ if } ifelse } -.bind systemdict begin odef end +.bind odef % An auxiliary function for checking whether an imagemask to be interpolated. /.is_low_resolution % <image dict> .is_low_resolution <bool> @@ -677,7 +647,7 @@ if 4 1 roll idtransform dtransform dup mul exch dup mul add sqrt } repeat - max + .max 2 gt % arbitrary } .bind def @@ -742,8 +712,31 @@ if } ifelse } -.bind systemdict begin odef end - -end % img_utils_dict +.bind odef + +% undefine a bunch of local definitions +[ + /.colorimage + /img_params_dict + /img_unbuild_dict + /img_unbuild_image_dict + /img_unbuild_imagemask_dict + /img_build_dict + /img_build_image_dict + /img_build_imagemask_dict + /img_check_keys + /img_mask_check_ary + /img_params_ary + /img_mask_unbuild_ary + /img_mask_params_ary + /img_csary + /img_decary + /img_check_ary + /img_unbuild_ary + /.is_low_resolution +] +{currentdict exch .undef} forall + +end % systemdict .setglobal % restore VM mode diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_init.ps b/Master/tlpkg/tlgs/Resource/Init/gs_init.ps index d733124b96d..55a785eceed 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_init.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_init.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 @@ -34,7 +34,7 @@ % Interpreter library version number % NOTE: the interpreter code requires that the first non-comment token % in this file be an integer, and that it match the compiled-in version! -926 +927 % Check the interpreter revision. dup revision ne @@ -54,18 +54,11 @@ systemdict exch dup /userdict currentdict dup 200 .setmaxlength % userdict .forceput % userdict is local, systemdict is global - } + } executeonly if begin -% Define dummy local/global operators if needed. -systemdict /.setglobal known - { //true .setglobal - } - { /.setglobal { pop } bind def - /.currentglobal { //false } bind def - /.gcheck { pop //false } bind def - } -ifelse +% Init to global memory (possibly not needed, but left in for legacy purposes) +//true .setglobal % Define .languagelevel if needed. systemdict /.languagelevel known not { /.languagelevel 1 def } if @@ -116,7 +109,7 @@ currentdict /PDFSTEP known /PDFSTEP exch def PDFSTEP { /PDFDEBUG //true def } if currentdict /PDFSTOPONERROR known /PDFSTOPONERROR exch def -currentdict /PDFSTOPONWARNING known {/PDFSTOPONWARNING true def /PDFSTOPONERROR true def}{/PDFSTOPONWARNING false def} ifelse +currentdict /PDFSTOPONWARNING known {/PDFSTOPONWARNING //true def /PDFSTOPONERROR //true def}{/PDFSTOPONWARNING //false def} ifelse currentdict /PDFNOCIDFALLBACK known /PDFNOCIDFALLBACK exch def /.bind /bind load def @@ -147,7 +140,7 @@ currentdict /PDFNOCIDFALLBACK known /PDFNOCIDFALLBACK exch def % ancient and no longer maintained piece of softare, did check % its value unconditionally. So we retain this key in the dictionary % purely for backward compatibility. -/NOBIND false def +/NOBIND //false def currentdict /BATCH known /BATCH exch def currentdict /DELAYBIND known /DELAYBIND exch def @@ -212,12 +205,9 @@ currentdict /SCANCONVERTERTYPE known currentdict /SCANCONVERTERTYPE get .setscanconverter } if -% We rely on PSFitPage to actually implement EPSFitPage -% But we need EPSCrop to be true, to actually issue a PageSize request, so set it here -% in case the user forgets. -currentdict /EPSFitPage known { /PSFitPage //true def /EPSCrop //true def} if +currentdict /EPSFitPage known { /PSFitPage //true def } if % This is a "convenience" option that sets a combination of EPSFitPage, PDFFitPage and PSFitPage -currentdict /FitPage known { /EPSFitPage //true def /EPSCrop //true def /PDFFitPage //true def /PSFitPage //true def } if +currentdict /FitPage known { /EPSFitPage //true def /PDFFitPage //true def /PSFitPage //true def } if % Acquire environment variables. currentdict /DEVICE known not @@ -271,7 +261,7 @@ userdict /=string 256 string put { mark product (GPL Ghostscript) search { pop pop pop - (This software comes with NO WARRANTY: see the file PUBLIC for details.\n) + (This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:\nsee the file COPYING for details.\n) } { pop } @@ -289,7 +279,8 @@ userdict /=string 256 string put } repeat pop } .bind def -QUIET not { printgreeting flush } if +QUIET not { //printgreeting exec flush } if +currentdict /printgreeting .undef % Define a special version of def for making operator procedures. /obind { % <name> <proc> obind <name> <oper> @@ -299,27 +290,20 @@ QUIET not { printgreeting flush } if 1 index exch .makeoperator def } .bind def -% Define a special version of def for storing local objects into global -% dictionaries. Like .forceput, this exists only during initialization. -/.forcedef { % <key> <value> .forcedef - - 1 .argindex pop % check # of args - currentdict 3 1 roll .forceput -} .bind odef - % Define procedures for accessing variables in systemdict and userdict % regardless of the contents of the dictionary stack. /.systemvar { % <name> .systemvar <value> //systemdict exch get -} .bind odef +} .bind executeonly odef /.systemexec { .systemvar exec -} .bind odef +} .bind executeonly odef /.userdict { % - .userdict <dict> /userdict .systemvar -} .bind odef +} .bind executeonly odef /.uservar { % <name> .uservar <value> .userdict exch get -} .bind odef +} .bind executeonly odef % If we're delaying binding, remember everything that needs to be bound later. DELAYBIND @@ -347,7 +331,7 @@ DELAYBIND } ifelse } .bind def -} if +} executeonly if %**************** BACKWARD COMPATIBILITY **************** /hwsizedict mark /HWSize //null .dicttomark readonly def @@ -360,6 +344,9 @@ currentdict /hwsizedict .undef /getdeviceprops { //null .getdeviceparams } bind odef + +% NOTE: Note sure why/if this needs to be a separate operator. Consider rolling this +% implementation into /putdeviceprops ? /.putdeviceprops { //null //true counttomark 1 add 3 roll .putdeviceparams dup type /booleantype ne @@ -368,15 +355,14 @@ currentdict /hwsizedict .undef /.putdeviceprops .systemvar exch signalerror } if - } bind odef -/.currentfilladjust { .currentfilladjust2 pop } bind odef -/.setfilladjust { dup .setfilladjust2 } bind odef + } bind executeonly odef /.writecvs { 0 .writecvp } bind odef + %**************** DEPRECATED PROCEDURES **************** %**************** DO NOT USE THESE IN NEW CODE **************** +% Keeping these because they have been around a long time and we don't want to break old code that's out in the wild /max { .max } bind def % use .max instead /min { .min } bind def % use .min instead -/unread /.unread load def % use .peekstring instead %**************** END OF BACKWARD COMPATIBILITY SECTION **************** % Utility for removing all entries from a dictionary @@ -400,19 +386,19 @@ userdict /#copies 1 put /mark load def (]) cvn {counttomark array astore exch pop} odef -% .beginpage is redefined if setpagedevice is present. -/.beginpage { } odef -% In LanguageLevel 3, copypage erases the page. -/copypage { - .languagelevel 3 ge - dup { 0 } { 1 } ifelse .endpage .doneshowpage { - .currentnumcopies 1 index .outputpage - (>>copypage, press <return> to continue<<\n) .confirm - dup { erasepage } if - } if pop - systemdict /..page_default_spaces .knownget { //.PurgeDict exec } if - .beginpage -} odef +% +% - initgraphics - +% +% Although the internal routine gs_initgraphics resets the color space, +% it does not reset the color space we store in the 'interpreter' +% graphics state (so that we can hand it back in currentcolorspace). +% So we need to do that in the PostScript world. +% +% +/initgraphics + { initgraphics systemdict /DeviceGray_array get setcolorspace } +.bind executeonly odef + /currentmatrix { dup type /arraytype ne { /currentmatrix load /typecheck signalerror } if @@ -420,8 +406,52 @@ userdict /#copies 1 put { /currentmatrix load /rangecheck signalerror } if .currentmatrix 6 .argindex astore pop } odef -% .currentnumcopies is redefined in Level 2. -/.currentnumcopies { #copies } odef + +% 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 executeonly 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 executeonly odef + +% Define .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 executeonly odef + /setcolorscreen where { pop % not in all Level 1 configurations /currentcolorscreen { .currenthalftone @@ -456,8 +486,6 @@ userdict /.echo.mode //true put % because this is apparently what Adobe interpreters do. currentdict //systemdict eq { end } if } odef -% .endpage is redefined if setpagedevice is present. -/.endpage { 2 ne } odef % erasepage mustn't use gsave/grestore, because we call it before % the graphics state stack has been fully initialized. /erasepage @@ -472,24 +500,48 @@ userdict /.echo.mode //true put currentoverprint //false setoverprint 1 setgray .fillpage setoverprint exec } odef +% Define a procedure for clearing the error indication. +/.clearerror + { $error /newerror //false put + $error /errorname //null put + $error /errorinfo //null put + 0 .setoserrno + } bind executeonly def + % To satisfy the Genoa FTS, executive must be a procedure, not an operator. +% Define the procedure used by .runfile, .runstdin and .runstring +% for executing user input. +% This is called with a procedure or executable file on the operand stack. +/.execute { % <obj> .execute <stopped> + stopped $error /newerror get and + { /handleerror .systemvar exec flush //true } { //false } ifelse +} bind def +% Define an execute analogue of runlibfile0. +/execute0 { % <obj> execute0 - + //.execute exec { /execute0 cvx 1 .quit } if +} bind def /executive { { prompt { (%statementedit) (r) .systemvmfile } stopped { pop pop $error /errorname get /undefinedfilename eq - { .clearerror exit } if % EOF + { //.clearerror exec exit } if % EOF /handleerror .systemvar exec //null % ioerror?? } if - cvx { .runexec } .execute pop + cvx { .runexec } //.execute exec pop } loop } bind def +currentdict /.execute .undef + /filter { //filterdict 1 .argindex .knownget { exch pop exec } { /filter .systemvar /undefined signalerror } ifelse } odef +% Internal uses of stopped that aren't going to do a stop if an error occurs +% should use .internalstopped to avoid setting newerror et al. +/.internalstopped { //null 1 .stopped //null ne } bind executeonly def % handleerror procedure as mentioned in the "Operators" section of the PLRM Section 8.2 % This invokes the handleerror procedure from errordict (unless we are running under a % JOBSERVER where we want to always use a defined error handler (many error handlers in @@ -499,9 +551,9 @@ userdict /.echo.mode //true put % won't cause nested errors (Unexpected Error conditions). /handleerror JOBSERVER { - { /.GShandleerror .systemvar .internalstopped pop } bind % always use .GShandleerror. + { /.GShandleerror .systemvar //.internalstopped exec pop } bind % always use .GShandleerror. } { - { /errordict .systemvar /handleerror get .internalstopped pop } bind % PLRM standard errorhandling + { /errordict .systemvar /handleerror get //.internalstopped exec pop } bind % PLRM standard errorhandling } ifelse def /identmatrix [1.0 0.0 0.0 1.0 0.0 0.0] readonly def /identmatrix { @@ -512,16 +564,18 @@ userdict /.echo.mode //true put /languagelevel 1 def % gs_lev2.ps may change this /makeimagedevice { //false makewordimagedevice } odef /matrix { 6 array identmatrix } odef -% .promptmsg is redefined if the interpreter includes readline support. + /.promptmsg { (GS) print count 0 ne { (<) print count =only } if (>) print flush } bind def -/prompt { flush flushpage NOPROMPT not { .promptmsg } if } bind def +/prompt { flush flushpage NOPROMPT not { //.promptmsg exec} if } bind def +currentdict /.promptmsg .undef + /pstack { 0 1 count 3 sub { index == } for } bind def /putdeviceprops - { .putdeviceprops { erasepage } if } odef + { .putdeviceprops { erasepage } if } bind executeonly odef /quit { /quit load 0 .quit } odef /run { dup type /filetype ne { (r) .systemvmfile } if % We must close the file when execution terminates, @@ -543,7 +597,7 @@ userdict /.echo.mode //true put % startjob replaces the null on the o-stack with a procedure % to be executed when we get back here. dup //null ne { exec //true } { pop //false } ifelse -} bind def +} bind executeonly def /.runexec2 { % <continue> <file|fileproc> .runexec2 - exch { .runexec @@ -598,10 +652,48 @@ odef dup length 6 ne { /setmatrix load /rangecheck signalerror } if dup aload pop .setmatrix pop } odef + +/.confirmread { + TTYPAUSE { + (/dev/tty) (r) file dup read pop pop closefile + } { + .echo.mode //false echo + (%stdin) (r) file dup read { + dup (\n) 0 get eq { pop pop } { .unread } ifelse + } { + pop + } ifelse echo + } ifelse +} bind executeonly def + +/.confirm { + DISPLAYING NOPAUSE not TTYPAUSE or and { + % Print a message (unless NOPAGEPROMPT or NOPROMPT is true) + % and wait for the user to type something. + % If the user just types a newline, flush it. + NOPAGEPROMPT NOPROMPT or { pop } { print flush } ifelse + //.confirmread exec + } { + pop + } ifelse +} bind executeonly def + +% In LanguageLevel 3, copypage erases the page. +/copypage { + .languagelevel 3 ge + dup { 0 } { 1 } ifelse .endpage .doneshowpage { + .currentnumcopies 1 index .outputpage + (>>copypage, press <return> to continue<<\n) //.confirm exec + dup { erasepage } if + } if pop + systemdict /..page_default_spaces .knownget { //.PurgeDict exec } if + .beginpage +} .bind executeonly odef + /showpage { 0 .endpage .doneshowpage { .currentnumcopies //true .outputpage - (>>showpage, press <return> to continue<<\n) .confirm + (>>showpage, press <return> to continue<<\n) //.confirm exec % Uncomment the following line, and use a Memento build to track % blocks that are created and not destroyed between each successive % page. @@ -614,14 +706,12 @@ odef { initgraphics } ifelse systemdict /..page_default_spaces .knownget { //.PurgeDict exec } if .beginpage -} odef +} .bind executeonly odef + % Code output by Adobe Illustrator relies on the fact that % `stack' is a procedure, not an operator!!! /stack { 0 1 count 3 sub { index = } for } bind def /start { BATCH { //null 0 .quit } { executive } ifelse } def -% Internal uses of stopped that aren't going to do a stop if an error occurs -% should use .internalstopped to avoid setting newerror et al. -/.internalstopped { //null 1 .stopped //null ne } bind def /store { % Don't alter operands before completing. 1 .argindex where { 2 index 2 index put pop pop } { def } ifelse } odef @@ -642,8 +732,6 @@ currentdict /.typenames .undef % internaldict is defined in systemdict, but the dictionary is allocated % in local VM. However, the procedure must be global, since it is an % "operator" and must be bind-able into global procedures. -% We make a procedure for creating it, since we must create a new one -% for each context with private local VM. /.makeinternaldict { .currentglobal //true .setglobal [ /dup .systemvar 1183615869 /eq .systemvar @@ -655,9 +743,10 @@ currentdict /.typenames .undef /ifelse .systemvar ] cvx executeonly exch .setglobal -} odef +} executeonly def systemdict /internaldict dup .makeinternaldict .makeoperator .forceput % proc is local, systemdict is global +currentdict /.makeinternaldict .undef % Define some additional built-in procedures (beyond the ones defined by % the PostScript Language Reference Manual). @@ -673,8 +762,6 @@ systemdict /internaldict dup .makeinternaldict .makeoperator % Copy a dictionary per the Level 2 spec even in Level 1. /.copydict % <fromdict> <todict> .copydict <todict> { dup 3 -1 roll { put dup } forall pop } bind def -/copystring - { dup length string copy } bind def /findlibfile { .systemvmlibfile { dup .filename pop exch //true } { //false } ifelse } odef @@ -682,11 +769,11 @@ systemdict /internaldict dup .makeinternaldict .makeoperator { length 3 mul 2 idiv 1 add } bind def /.growdict % grow a dictionary - { dup .growdictlength .setmaxlength + { dup //.growdictlength exec .setmaxlength } bind def /.growput % put, grow the dictionary if needed { 2 index length 3 index maxlength eq - { 3 copy pop known not { 2 index .growdict } if + { 3 copy pop known not { 2 index //.growdict exec} if } if put } bind def @@ -709,8 +796,6 @@ systemdict /internaldict dup .makeinternaldict .makeoperator } ifelse /.packtomark { counttomark packedarray exch pop } bind def -/ppstack - { 0 1 count 3 sub { index === } for } bind def /runlibfile { % We don't want to bind 'run' into this procedure, % since run may get redefined. @@ -777,13 +862,13 @@ userdict /.currentresourcefile //null put 2 .execn % stopped <file> .userdict /.currentresourcefile 3 -1 roll put { stop } if -} bind def +} bind executeonly def /.runresource { % <file> .runresource - { /run .systemvar exec } .execasresource } bind def -% Define auxiliary procedures needed for the above. -/shellarguments % -> shell_arguments true (or) false +% Convenience function (documented extension) +/.shellarguments % -> shell_arguments true (or) false { /ARGUMENTS where { /ARGUMENTS get dup type /arraytype eq { aload pop /ARGUMENTS //null store //true } @@ -791,44 +876,7 @@ userdict /.currentresourcefile //null put ifelse } { //false } ifelse } bind def -/.confirm { - DISPLAYING NOPAUSE not TTYPAUSE or and { - % Print a message (unless NOPAGEPROMPT or NOPROMPT is true) - % and wait for the user to type something. - % If the user just types a newline, flush it. - NOPAGEPROMPT NOPROMPT or { pop } { print flush } ifelse - .confirmread - } { - pop - } ifelse -} bind def -/.confirmread { - TTYPAUSE { - (/dev/tty) (r) file dup read pop pop closefile - } { - .echo.mode //false echo - (%stdin) (r) file dup read { - dup (\n) 0 get eq { pop pop } { unread } ifelse - } { - pop - } ifelse echo - } ifelse -} bind def -% Define the procedure used by .runfile, .runstdin and .runstring -% for executing user input. -% This is called with a procedure or executable file on the operand stack. -/.execute { % <obj> .execute <stopped> - stopped $error /newerror get and - { /handleerror .systemvar exec flush //true } { //false } ifelse -} bind def -/execute { % <obj> execute - - .execute pop -} odef -% Define an execute analogue of runlibfile0. -/execute0 { % <obj> execute0 - - .execute { /execute0 cvx 1 .quit } if -} bind def % Define the procedure that the C code uses for running files % named on the command line. /.runfile { @@ -884,7 +932,8 @@ def } bind def % Temporarily substitute it for the real runlibfile. /.runlibfile /runlibfile load def -/runlibfile /runlibfile0 load def +/runlibfile //runlibfile0 def +currentdict /runlibfile0 .undef % Create the error handling machinery. % Define the standard error handlers. @@ -916,7 +965,7 @@ def 1 .instopped { //null eq { pop pop stop } if } if (I) //false .setdebug $error /.inerror get 1 .instopped { pop } { pop //true } ifelse - { .unstoppederrorhandler + { //.unstoppederrorhandler exec } if % detect error recursion $error /globalmode .currentglobal //false .setglobal put $error /.inerror //true put @@ -940,12 +989,12 @@ def } ifelse $error /position currentfile status - { currentfile { fileposition } .internalstopped { pop //null } if + { currentfile { fileposition } //.internalstopped exec { pop //null } if } { % If this was a scanner error, the file is no longer current, % but the command holds the file, which may still be open. $error /command get dup type /filetype eq - { { fileposition } .internalstopped { pop //null } if } + { { fileposition } //.internalstopped exec { pop //null } if } { pop //null } ifelse } @@ -956,59 +1005,14 @@ def $error /.inerror //false put stop } bind executeonly def +currentdict /.unstoppederrorhandler .undef + % Define the standard handleerror. We break out the printing procedure % (.printerror) so that it can be extended for binary output % if the Level 2 facilities are present. - /.printerror - { $error begin newerror - { - /command load errorname SHORTERRORS - { (%%[ Error: ) print =only flush - (; OffendingCommand: ) print =only - errorinfo dup //null eq { - pop - } { - (;\nErrorInfo:) print - dup type /arraytype eq - { { ( ) print =only } forall } - { ( ) print =only } - ifelse - } ifelse - ( ]%%) = flush - } - { (Error: ) print ==only flush - ( in ) print ==only flush - errorinfo dup //null eq { - pop - } { - (\nAdditional information: ) print ==only flush - } ifelse - .printerror_long - } - ifelse - .clearerror flush - } - { % newerror is //false, test to see if user has set handleerror to a different - % routine, if so execute it, otherwise, just return. This code deals with the - % Genoa issue of setting /handleerror, and then calling it, without an error - % being set. We were erroring in this case, due to /command load failing. - - //JOBSERVER { - /errordict .systemvar /handleerror get /.GShandleerror .systemvar ne - } { - //false - } ifelse - { /errordict .systemvar begin /handleerror load .internalstopped pop end - } - if - } - ifelse % newerror - end - flush - } bind executeonly def - /.printerror_long % long error printout, +/.printerror_long % long error printout, % $error is on the dict stack - { % Push the (anonymous) stack printing procedure. +{ % Push the (anonymous) stack printing procedure. % <heading> <==flag> <override-name> <stackname> proc { currentdict exch .knownget % stackname defined in $error? @@ -1082,18 +1086,59 @@ def { (Current file position is ) print position = } if - } bind executeonly def -% Define a procedure for clearing the error indication. -/.clearerror - { $error /newerror //false put - $error /errorname //null put - $error /errorinfo //null put - 0 .setoserrno - } bind executeonly def +} bind executeonly def +/.printerror +{ $error begin newerror + { + /command load errorname SHORTERRORS + { (%%[ Error: ) print =only flush + (; OffendingCommand: ) print =only + errorinfo dup //null eq { + pop + } { + (;\nErrorInfo:) print + dup type /arraytype eq + { { ( ) print =only } forall } + { ( ) print =only } + ifelse + } ifelse + ( ]%%) = flush + } + { (Error: ) print ==only flush + ( in ) print ==only flush + errorinfo dup //null eq { + pop + } { + (\nAdditional information: ) print ==only flush + } ifelse + //.printerror_long exec + } + ifelse + //.clearerror exec flush + } + { % newerror is //false, test to see if user has set handleerror to a different + % routine, if so execute it, otherwise, just return. This code deals with the + % Genoa issue of setting /handleerror, and then calling it, without an error + % being set. We were erroring in this case, due to /command load failing. + + //JOBSERVER { + /errordict .systemvar /handleerror get /.GShandleerror .systemvar ne + } { + //false + } ifelse + { /errordict .systemvar begin /handleerror load //.internalstopped exec pop end + } + if + } + ifelse % newerror + end + flush +} bind executeonly def +currentdict /.printerror_long .undef % Define $error. This must be in local VM. .currentglobal //false .setglobal -/$error 40 dict .forcedef % $error is local, systemdict is global +currentdict /$error 40 dict .forceput % $error is local, systemdict is global % newerror, errorname, command, errorinfo, % ostack, estack, dstack, recordstacks, % binary, globalmode, @@ -1112,8 +1157,8 @@ end % Define errordict similarly. It has one entry per error name, % plus handleerror. However, some astonishingly badly written PostScript % files require it to have at least one empty slot. -/errordict ErrorNames length 3 add dict -.forcedef % errordict is local, systemdict is global +currentdict /errordict ErrorNames length 3 add dict +.forceput % errordict is local, systemdict is global .setglobal % back to global VM % gserrordict contains all the default error handling methods, but unlike % errordict it is noaccess after creation (also it is in global VM). @@ -1129,22 +1174,24 @@ end % files. However, ErrorNames contains all of the error names regardless of % what features are included, so we have to "know" that VMerror is the last % Level 1 error. -/.registererror % <name> .registererror - - { errordict exch .registererror2 - } bind def /.registererror2 % <dict> <name> .registererror - { .currentglobal //true .setglobal % create procs in global VM 3 1 roll - mark 1 index systemdict /.errorhandler get /exec load .packtomark cvx put + mark 1 index systemdict /.errorhandler get /exec load //.packtomark exec cvx put .setglobal } bind def +/.registererror % <name> .registererror - + { errordict exch //.registererror2 exec + } bind def +currentdict /.registererror2 .undef + ErrorNames { .registererror} forall errordict begin % The handlers for interrupt and timeout are special; there is no % 'current object', so they push their own name. { /interrupt /timeout } - { mark 1 index dup systemdict /.errorhandler get /exec load .packtomark cvx def + { mark 1 index dup systemdict /.errorhandler get /exec load //.packtomark exec cvx def } forall /handleerror % this key is 'well known' and some PS may redefine it { /.printerror .systemvar exec @@ -1168,8 +1215,8 @@ errordict /unknownerror .undef }ifelse }forall noaccess pop - systemdict /.setsafeerrors .forceundef - systemdict /.SAFERERRORLIST .forceundef + //systemdict /.setsafeerrors .forceundef + //systemdict /.SAFERERRORLIST .forceundef } bind executeonly odef SAFERERRORS {.setsafererrors} if @@ -1242,39 +1289,53 @@ end /=== { ===only (\n) print } bind def % Create the initialization queue. - -/.delayed_init_queue 10 dict def +1183615869 internaldict dup +/.delayed_init_queue 10 dict put /.schedule_init % <priority> <proc> .schedule_init - { - //.delayed_init_queue 2 index known { + 1183615869 internaldict begin + .delayed_init_queue 2 index known { + end (.delayed_init_queue priority conflict with ) print 1 index = /.schedule_init cvx /configurationerror signalerror } if - //.delayed_init_queue 3 1 roll .growput + .delayed_init_queue 3 1 roll .growput + end } bind def +begin /.execute_scheduled_inits % - .execute_scheduled_inits - { - { 0 //null //.delayed_init_queue { % maxp {} p {} + 2 dict begin + /.newdelayed_init_queue + mark + 1183615869 internaldict /.delayed_init_queue get {} forall + .dicttomark def + { + 0 //null .newdelayed_init_queue { % maxp {} p {} 3 index 2 index lt { 4 2 roll } if pop pop } forall - exch //.delayed_init_queue exch undef + exch .newdelayed_init_queue exch undef dup //null eq { pop exit } if exec } loop + currentdict /.newdelayed_init_queue undef + end } bind def +end (END PROCS) VMDEBUG % Define the font directory. +currentdict /FontDirectory //false .setglobal 100 dict //true .setglobal -.forcedef % FontDirectory is local, systemdict is global +.forceput % FontDirectory is local, systemdict is global % Define the encoding dictionary. /EncodingDirectory 16 dict def % enough for Level 2 + PDF standard encodings @@ -1336,7 +1397,7 @@ currentdict /PDFA known { PDFA type /booleantype eq { /PDFA 1 def } if } if % Loop until the .getdevice gets a rangecheck. errordict /rangecheck 2 copy get errordict /rangecheck { pop stop } put % pop the command - 0 { {dup .getdevice exch 1 add} loop} .internalstopped pop + 0 { {dup .getdevice exch 1 add} loop} //.internalstopped exec pop 1 add dict /devicedict 1 index def begin % 2nd copy of count is on stack { dup .devicename exch @@ -1542,12 +1603,20 @@ setpacking % Increase fill adjustment so that we effectively use Adobe's % any-part-of-pixel rule. - 0.5 .setfilladjust + 0.5 dup .setfilladjust2 } bind def + % Set the default screen and BG/UCR. +% We define the proc here, rather than inline in .setdefaultbgucr +% for the benefit of gs_cet.ps so jobs that do anything that causes +% .setdefaultbgucr to be called will still get the redefined proc +% in gs_cet.ps +(%.defaultbgrucrproc) cvn { pop 0 } def + /.setdefaultbgucr { systemdict /setblackgeneration known { - { pop 0 } dup setblackgeneration setundercolorremoval + (%.defaultbgrucrproc) cvn load dup + setblackgeneration setundercolorremoval } if } bind def /.useloresscreen { % - .useloresscreen <bool> @@ -1571,7 +1640,7 @@ setpacking % false /.getdefaulthalftone { % try the device to see if it has a default halftone - { currentdevice /HalftoneDefault //.gsgetdeviceprop exec } .internalstopped + { currentdevice /HalftoneDefault //.gsgetdeviceprop exec } //.internalstopped exec { pop pop //false } % no device property { dup type /dicttype eq { //true } { pop //false } ifelse } ifelse @@ -1579,7 +1648,7 @@ setpacking % false not found dup not { % device did not provide a default, try Resource - pop { /Default /Halftone /findresource .systemvar exec } .internalstopped + pop { /Default /Halftone /findresource .systemvar exec } //.internalstopped exec { pop pop //false } { //true } ifelse } if @@ -1587,18 +1656,20 @@ setpacking currentdict /.gsgetdeviceprop .forceundef /.setdefaulthalftone { - .getdefaulthalftone + //.getdefaulthalftone exec { sethalftone } { % default not found - .useloresscreen { .setloreshalftone } { .sethireshalftone pop } ifelse + //.useloresscreen exec { .setloreshalftone } { .sethireshalftone pop } ifelse } ifelse } bind def /.setdefaultscreen { - .useloresscreen { .setloresscreen } { .sethiresscreen } ifelse - .setdefaultbgucr + //.useloresscreen exec { .setloresscreen } { .sethiresscreen } ifelse + //.setdefaultbgucr exec } bind def +currentdict /.setdefaultbgucr .undef +currentdict /.useloresscreen .undef % Rendering intent mapping for setcolorrendering1 and PDF interpreter /.renderingintentdict mark @@ -1709,7 +1780,7 @@ currentdict /.gsgetdeviceprop .forceundef dup length 2 index length sub % drop "ffn", remaining "ldffn" = length of the "directory" part exch % {} b [dl] (templ) (ffn) ldffn (dffn) - .makepathtemplate % {} b [dl] (templ) (ffn) ldffn (Dffn) + //.makepathtemplate exec % {} b [dl] (templ) (ffn) ldffn (Dffn) dup % {} b [dl] (templ) (ffn) ldffn (Dffn) (Dffn) 4 index length dup % {} b [dl] (templ) (ffn) ldffn (Dffn) (Dffn) templL templL 2 index length % {} b [dl] (templ) (ffn) ldffn (Dffn) (Dffn) templL templL DffnL @@ -1741,7 +1812,8 @@ currentdict /.gsgetdeviceprop .forceundef } forall } ifelse % (t1) ?l1 (t2) ?l2 ... (tN) ?ln {} b [dl] (templ) (ffn) pop pop pop pop pop % (t1) ?l1 (t2) ?l2 ... (tN) ?ln -} bind def +} .bind executeonly odef +currentdict /.makepathtemplate .undef % <dir_list> <template> .generate_dir_list_templates <t1> ... <tN> % @@ -1749,8 +1821,8 @@ currentdict /.gsgetdeviceprop .forceundef % It's the 'false' case of the function above. % /.generate_dir_list_templates -{ //false 3 1 roll //.generate_dir_list_templates_with_length exec -} bind def +{ //false 3 1 roll //.generate_dir_list_templates_with_length +} .bind executeonly odef % Load the initialization files for optional features. %% Replace 4 INITFILES @@ -1789,6 +1861,7 @@ end % Load initial fonts from FONTPATH directories, Fontmap file, % and/or .getccfont as appropriate. .loadinitialfonts +currentdict /.loadinitialfonts .undef % Remove NullFont from FontDirectory, so it can't be accessed by mistake. /undefinefont where { @@ -1810,12 +1883,16 @@ currentdict /.runlibfile .undef { dup type /operatortype eq { % This might be a real operator, so bind might cause a typecheck - {.bind} .internalstopped pop + {.bind} //.internalstopped exec pop } if pop pop } forall } def -DELAYBIND not { .bindoperators } if +DELAYBIND not { + .bindoperators + %% if not DELAYBIND, undef this now. Otherwise defer to .bindnow + //systemdict /.bindoperators .undef +} if % Establish a default environment. @@ -1938,7 +2015,7 @@ ifelse % If the initial device parameters are invalid, the setdevice may fail. % Trap this and produce a reasonable error message. { setdevice } % does an erasepage -INITDEBUG { exec //false } { .internalstopped } ifelse { +INITDEBUG { exec //false } { //.internalstopped exec } ifelse { (%stderr) (w) file dup (**** Unable to open the initial device, quitting.\n) writestring flushfile @@ -2020,9 +2097,21 @@ gsave } { { } } ifelse def -<1b> cvn { % UEL is <esc>%-12345X and acts the same as ^D - currentfile (%-12345X) .peekstring pop (%-12345X) eq <04> cvn load if -} bind def +<1b> cvn +.actonuel % UEL is <esc>%-12345X and acts the same as ^D +{systemdict (.forceinterp_exit) cvn known {//true} {//false} ifelse} +{//false} ifelse + +{ + { + currentfile (%-12345X) .peekstring pop (%-12345X) eq + { currentfile .forceinterp_exit } if + } +} +{ + {currentfile (%-12345X) .peekstring pop (%-12345X) eq <04> cvn load if} +} ifelse bind def + <1b45> cvn { } def % PJL reset prologue (ESC E) <1b451b> cvn <1b> cvn load def % PJL reset epilogue (ESC E + UEL) (\001M) cvn % TBCP initiator @@ -2048,7 +2137,9 @@ gsave % Install the EPS handler if needed systemdict /EPSBoundingBoxInit known { EPSBoundingBoxInit } if +systemdict /EPSBoundingBoxInit .forceundef +%% ---------------- SAFER stuff BEGIN -------------------%% % If we want a "safer" system, disable some obvious ways to cause havoc. .currentglobal //true .setglobal /SAFETY 2 dict @@ -2108,13 +2199,14 @@ readonly def >> setuserparams } if -} bind def +} .bind executeonly def currentdict /tempfilepaths undef +%% --- These are documented extensions --- /.locksafe { - .locksafe_userparams - systemdict /getenv {pop //false} .forceput + //.locksafe_userparams exec + //systemdict /getenv {pop //false} .forceput % setpagedevice has the side effect of clearing the page, but % we will just document that. Using setpagedevice keeps the device % properties and pagedevice .LockSafetyParams in agreement even @@ -2125,6 +2217,20 @@ currentdict /tempfilepaths undef //SAFETY /safe //true .forceput % overrides readonly } .bind executeonly odef +/.setsafe +{ + SAFETY /safe get not { + << + /PermitFileReading [ ] + /PermitFileWriting [ ] + /PermitFileControl [ ] + >> setuserparams + } + if + .locksafe +} .bind executeonly odef +%% --- End documented extensions --- + % This is only used during startup. Its required so that % we can detect in setpagdevice that we are in fact in startup % and allocate a *global* instead of local VM. We need it to be @@ -2132,7 +2238,7 @@ currentdict /tempfilepaths undef % in gs_setpd.ps) % /.locksafeglobal { - .locksafe_userparams + //.locksafe_userparams exec systemdict /getenv {pop //false} put % setpagedevice has the side effect of clearing the page, but % we will just document that. Using setpagedevice keeps the device @@ -2144,20 +2250,7 @@ currentdict /tempfilepaths undef >> setpagedevice setglobal //SAFETY /safe //true .forceput % overrides readonly -} .bind executeonly odef - -/.setsafe -{ - SAFETY /safe get not { - << - /PermitFileReading [ ] - /PermitFileWriting [ ] - /PermitFileControl [ ] - >> setuserparams - } - if - .locksafe -} .bind executeonly odef +} .bind def % See /.locksafeglobal above. % @@ -2170,12 +2263,16 @@ currentdict /tempfilepaths undef >> setuserparams } if - .locksafeglobal -} bind executeonly odef + //.locksafeglobal exec +} .bind def % If we are running in SAFER mode, lock things down SAFER { .setsafeglobal } if +currentdict /.locksafe_userparams .undef +currentdict /.setsafeglobal .undef +currentdict /.locksafeglobal .undef +SAFER { /SAFERUndefinePostScriptOperators { [ % Used by our own test suite files @@ -2186,30 +2283,17 @@ SAFER { .setsafeglobal } if /.endtransparencygroup % transparency-example.ps /.setdotlength % Bug687720.ps /.sort /.setdebug /.mementolistnewblocks /getenv - - /.makeoperator /.setCPSImode % gs_cet.ps, this won't work on cluster with -dSAFER - /unread ] {systemdict exch .forceundef} forall //systemdict /SAFERUndefinePostScriptOperators .forceundef } .bind executeonly def % must be bound and hidden for .forceundef +} if -/UndefinePostScriptOperators { - - % This list is of Display PostScript operators. We believe that Display PostScript - % was never fully implemented and the only known user, GNUStep, is no longer - % using it. So lets remove it. - [ - /condition /currentcontext /detach /.fork /join /.localfork /lock /monitor /notify - /wait /yield /.currentscreenphase /.setscreenphase /.image2 /eoviewclip /initviewclip - /viewclip /viewclippath /defineusername - % NeXT DPS extensions - /currentalpha /setalpha /.alphaimage /composite /compositerect /dissolve /sizeimagebox /.sizeimageparams - ] - {systemdict exch .forceundef} forall +%% ---------------- SAFER stuff END -------------------%% +/UndefinePostScriptOperators { % This list is of operators which no longer appear to be used, and which we do not believe % to have any real use. For now we will undefine the operstors so they cannot easily be used % but can be easily restored (just delete the name from the list in the array). In future @@ -2244,17 +2328,58 @@ SAFER { .setsafeglobal } if /.file_name_combine /.file_name_is_absolute /.file_name_separator /.file_name_directory_separator /.file_name_current /.filename /.peekstring /.writecvp /.subfiledecode /.setupUnicodeDecoder /.jbig2makeglobalctx /.registerfont /.parsecff /.getshowoperator /.getnativefonts /.beginform /.endform /.get_form_id /.repeatform /.reusablestream /.rsdparams - /.buildfunction /.currentfilladjust2 /.setfilladjust2 /.sethpglpathmode /.currenthpglpathmode + /.buildfunction /.sethpglpathmode /.currenthpglpathmode /.currenthalftone /.sethalftone5 /.image1 /.imagemask1 /.image3 /.image4 /.getiodevice /.getdevparms /.putdevparams /.bbox_transform /.matchmedia /.matchpagesize /.defaultpapersize /.oserrno /.setoserrno /.oserrorstring /.getCPSImode - /.getscanconverter /.setscanconverter /.type1encrypt /.type1decrypt/.languagelevel /.setlanguagelevel /.eqproc /.fillpage /.buildpattern1 /.saslprep - /.buildshading1 /.buildshading2 /.buildshading3 /.buildshading4 /.buildshading5 /.buildshading6 /.buildshading7 /.buildshadingpattern + /.getscanconverter /.setscanconverter /.type1encrypt /.type1decrypt/.languagelevel /.setlanguagelevel /.eqproc /.fillpage + /.saslprep /.shfill /.argindex /.bytestring /.namestring /.stringbreak /.stringmatch /.globalvmarray /.globalvmdict /.globalvmpackedarray /.globalvmstring /.localvmarray /.localvmdict /.localvmpackedarray /.localvmstring /.systemvmarray /.systemvmdict /.systemvmpackedarray /.systemvmstring /.systemvmfile /.systemvmlibfile /.systemvmSFD /.settrapparams /.currentsystemparams /.currentuserparams /.getsystemparam /.getuserparam /.setsystemparams /.setuserparams /.checkpassword /.locale_to_utf8 /.currentglobal /.gcheck /.imagepath /.currentoutputdevice /.type /.writecvs /.setSMask /.currentSMask /.needinput /.countexecstack /.execstack /.applypolicies + /filterdict /.cidfonttypes /.colorrenderingtypes + /.formtypes /.halftonetypes /.imagetypes /.imagemasktypes + /.patterntypes /.shadingtypes /.wheredict /.renderingintentdict + /.currentmatrix /.setmatrix + /.setlinecap /.setlinejoin /.sizeimagebox /.systemvmcheck + /.forceinterp_exit /.actonuel + /.init_otto_font_file + /.composefontdict + /.type1build + /.origdefinefont /.origundefinefont /.origfindfont + /.buildnativefontmap + /.completefont + /.definefakefonts + /.fontnameproperties + /.growfontdict + /.substitutefont /.substitutefontname + /.FontDirectory + /.charkeys + /.makesfnts + /.pickcmap + /.loadttcidfont + /.loadpdfttfont + /obind + /odef + /.packtomark + /.putdeviceprops + /.growdict /.growdictlength + /.userdict /.uservar + /.getdefaulthalftone + /.registererror + /.PurgeDict + /.runresource + /.numicc_components + /.set_outputintent + /.internalstopped + /.generate_dir_list_templates /.generate_dir_list_templates_with_length + /.type11mapcid /.type9mapcid + /.clearerror + /.beginpage /.endpage + /.getpath + /.confirm /.confirmread % Used by a free user in the Library of Congress. Apparently this is used to % draw a partial page, which is then filled in by the results of a barcode @@ -2267,52 +2392,57 @@ SAFER { .setsafeglobal } if % Used by our own test suite files %/.fileposition %image-qa.ps - %/.makeoperator /.setCPSImode % gs_cet.ps % Either our code uses these in ways which mean they can't be undefined, or they are used directly by % test files/utilities, or engineers expressed a desire to keep them visible. % %/currentdevice /.sort /.buildfont0 /.buildfont1 /.buildfont2 /.buildfont3 /.buildfont4 /.buildfont9 /.buildfont10 /.buildfont11 - %/.buildfont32 /.buildfont42 /.type9mapcid /.type11mapcid /.swapcolors + %/.buildfont32 /.buildfont42 /.swapcolors %/currentdevice /.quit /.setuseciecolor /.needinput /.setoverprintmode /.special_op /.dicttomark /.knownget %/.FAPIBuildGlyph /.FAPIBuildChar /.FAPIBuildGlyph9 - %/.tempfile /.numicc_components /.set_outputintent /.max /.min /.vmreclaim /.getpath /.setglobal + %/.tempfile /.max /.min /.setglobal %/.setdebug /.mementolistnewblocks /getenv ] {systemdict exch .forceundef} forall + % level 2 operators, undefine from both systemdict and level2dict + [ + /.execform1 + /.getdevparams + /.setuserparams2 + /.startjob + /.checkFilePermitparams + /.copyparam + /.setdevicecolorrendering1 + /.buildpattern1 + /.findcategory + /.execinstall + /.findfontop + +% Couldn't figure out how to do these yet +% /.checkparamtype +% /.startnewjob + ] + dup {level2dict exch .forceundef} forall + {systemdict exch .forceundef} forall + + % undef stuff from statusdict + [ +% /.setpagesize + ] + {statusdict exch .forceundef} forall + //systemdict /UndefinePostScriptOperators .forceundef } .bind executeonly def % must be bound and hidden for .forceundef +% Undefine operators that are used by PDF internally. +% This list is maintained in pdf_main.ps /UndefinePDFOperators { - % This list of operators are used internally by various parts of the Ghostscript PDF interpreter. - % Since each operator is a potential security vulnerability, and any operator listed here - % is not required once the initislisation is complete and functions are bound, we undefine - % the ones that aren't needed at runtime. - % This function is only called if DELAYBIND is true. It is a copy of the code at the end of pdf_main.ps - % and must be maintained in parallel with it. - [ - /.pdfawidthshow /.pdfwidthshow /.currentblackptcomp /.setblackptcomp - /.setfillcolor /.setfillcolorspace /.setstrokecolor /.setstrokecolorspace /.currentrenderingintent /.setrenderingintent - /.currenttextrenderingmode /.settextspacing /.currenttextspacing /.settextleading /.currenttextleading - /.settextrise /.currenttextrise /.setwordspacing /.currentwordspacing /.settexthscaling /.currenttexthscaling - /.settextlinematrix /.currenttextlinematrix /.currenttextmatrix /.settextmatrix /.currentblendmode - /.currentopacityalpha /.currentshapealpha /.currenttextknockout - /.pushextendedgstate /.popextendedgstate /.begintransparencytextgroup - /.endtransparencytextgroup /.begintransparencymaskgroup /.begintransparencymaskimage /.endtransparencymask /.image3x - /.abortpdf14devicefilter /.pdfinkpath /.pdfFormName /.setstrokeconstantalpha - /.setfillconstantalpha /.setalphaisshape /.currentalphaisshape - /.settextspacing /.currenttextspacing /.settextleading /.currenttextleading /.settextrise /.currenttextrise - /.setwordspacing /.currentwordspacing /.settexthscaling /.currenttexthscaling /.setPDFfontsize /.currentPDFfontsize - /.setdistillerparams - - % undefining these causes errors/incorrect output - %/.settextrenderingmode /.setblendmode /.begintransparencygroup /.settextknockout /check_r6_password /.setstrokeoverprint /.setfilloverprint - %/.currentstrokeoverprint /.currentfilloverprint /.currentfillconstantalpha /.currentstrokeconstantalpha - ] - {systemdict exch .forceundef} forall + .PDF_UNDEF_OPLIST + {//systemdict exch .forceundef} forall + //systemdict /.PDF_UNDEF_OPLIST .forceundef //systemdict /UndefinePDFOperators .forceundef -} .bind executeonly def % must be bound and hidden for .forceundef +} .bind def % If we delayed binding, make it possible to do it later. /.bindnow { @@ -2333,9 +2463,9 @@ SAFER { .setsafeglobal } if //systemdict /UndefinePostScriptOperators get exec //systemdict /UndefinePDFOperators get exec //systemdict /.forcecopynew .forceundef % remove temptation - //systemdict /.forcedef .forceundef % ditto //systemdict /.forceput .forceundef % ditto //systemdict /.undef .forceundef % ditto + //systemdict /.bindoperators .forceundef //systemdict /.forceundef .forceundef % ditto currentuserparams /IdiomRecognition known { 1 dict dup /IdiomRecognition 4 -1 roll put setuserparams @@ -2357,7 +2487,7 @@ SAFER { .setsafeglobal } if % Update the copy of the user parameters. mark .currentuserparams counttomark 2 idiv { userparams 3 1 roll .forceput % userparams is read-only - } repeat pop + } executeonly repeat pop % Turn on idiom recognition, if available. currentuserparams /IdiomRecognition known { /IdiomRecognition //true .definepsuserparam @@ -2368,15 +2498,15 @@ SAFER { .setsafeglobal } if % (and, if implemented, context switching). .currentglobal //false .setglobal mark userparams { } forall .dicttomark readonly - /userparams exch .forcedef % systemdict is read-only + currentdict exch /userparams exch .forceput % systemdict is read-only .setglobal -} if +} executeonly if /.currentsystemparams where { pop % Remove real system params from pssystemparams. mark .currentsystemparams counttomark 2 idiv { pop pssystemparams exch .forceundef - } repeat pop + } executeonly repeat pop } if % Set up AlignToPixels : @@ -2399,47 +2529,19 @@ $error /.nosetlocal //false put (END GLOBAL) VMDEBUG -% .savelocalstate is part of Display PostScript (if included). Part of the function of -% the .savelocalstate routine is to store the 'initial saved gstate' (savedinitialgstate) -% in systemdict. The code in dps1.c, gstate_check_space, disallows writing or creating -% gstates in global VM in certain conditions. If we execute setpagedevice before we -% reach this point, we must ensure that we do so using /..StartupGlobal so that -% the dictionary is defined in global VM, because the gstate contains a pointer to the -% device dictionary, and if that is allocated in local VM we will fail the gstate check. -/.savelocalstate where { - % If we might create new contexts, save away copies of all dictionaries - % referenced from systemdict that are stored in local VM, - % and also save a copy of the initial gstate. - pop .savelocalstate -} { - % If we're *not* running in a multi-context system and FAKEFONTS is - % defined, add the fake fonts to LocalFontDirectory. - .definefakefonts % current VM is local -} ifelse +% Add the fake fonts to LocalFontDirectory. +//.definefakefonts exec % current VM is local % Execute scheduled inits : -//.execute_scheduled_inits exec -currentdict /.execute_scheduled_inits undef -currentdict /.delayed_init_queue undef +1183615869 internaldict /.execute_scheduled_inits get exec +currentdict /.schedule_init undef +%currentdict /.execute_scheduled_inits undef +%currentdict /.delayed_init_queue undef % Make global and local FontDirectory read-only. FontDirectory readonly pop /GlobalFontDirectory where { pop GlobalFontDirectory readonly pop } if -% Remove systemdict entries for things that have been bound in where used -% and that shouldn't be accessible by name, and close up systemdict. -currentdict /filterdict .undef -currentdict /.cidfonttypes .undef -currentdict /.colorrenderingtypes .undef -currentdict /.formtypes .undef -currentdict /.halftonetypes .undef -currentdict /.imagetypes .undef -currentdict /.imagemasktypes .undef -currentdict /.patterntypes .undef -currentdict /.shadingtypes .undef -currentdict /.wheredict .undef -currentdict /.renderingintentdict .undef - % If we are using DELAYBIND we have to defer the undefinition % until .bindnow. DELAYBIND not { @@ -2455,24 +2557,30 @@ end /vmreclaim where { pop NOGC not { 2 .vmreclaim 0 vmreclaim } if } if +systemdict /.vmreclaim .undef +level2dict /.vmreclaim .undef + +% Do this before systemdict is locked (see below for additional CETMODE setup using gs_cet.ps) +systemdict /CETMODE .knownget { + { + (gs_cet.ps) runlibfile + } if +} if +systemdict /.makeoperator .undef % must be after gs_cet.ps +systemdict /.setCPSImode .undef % must be after gs_cet.ps + DELAYBIND not { systemdict /.bindnow .undef % We only need this for DELAYBIND systemdict /.forcecopynew .undef % remove temptation - systemdict /.forcedef .undef % ditto systemdict /.forceput .undef % ditto systemdict /.forceundef .undef % ditto } if -% Move superexec to internaldict if superexec is defined. -systemdict /superexec .knownget { - 1183615869 internaldict /superexec 3 -1 roll put - systemdict /superexec .undef -} if - % Can't remove this one until the last minute :-) DELAYBIND not { systemdict /.undef .undef } if + WRITESYSTEMDICT { SAFER { (\n *** WARNING - you have selected SAFER, indicating you want Ghostscript\n) print diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_l2img.ps b/Master/tlpkg/tlgs/Resource/Init/gs_l2img.ps deleted file mode 100644 index c448fc42378..00000000000 --- a/Master/tlpkg/tlgs/Resource/Init/gs_l2img.ps +++ /dev/null @@ -1,183 +0,0 @@ -% Copyright (C) 2001-2018 Artifex Software, Inc. -% All Rights Reserved. -% -% This software is provided AS-IS with no warranty, either express or -% implied. -% -% This software is distributed under license and may not be copied, -% modified or distributed except as expressly authorized under the terms -% of the license contained in the file LICENSE in this distribution. -% -% Refer to licensing information at http://www.artifex.com or contact -% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato, -% CA 94945, U.S.A., +1(415)492-9861, for further information. -% - -% Emulate the Level 2 dictionary-based image operator in Level 1, -% except for Interpolate (ignored) and MultipleDataSources = true; -% also, we require that the data source be either a procedure of a -% particular form or a stream, not a string or a general procedure. - -% pdf2ps copies the portion of this file from %BEGIN to %END if Level 1 -% compatible output is requested. - -/currentglobal where - { pop currentglobal { setglobal } //true setglobal } - { { } } -ifelse - -/packedarray where - { pop } - { /packedarray { array astore readonly } bind def } -ifelse - -%BEGIN - -11 dict /.csncompdict 1 index def begin - /DeviceGray { 1 /setgray load } bind def - /DeviceRGB { 3 /setrgbcolor load } bind def - /DeviceCMYK { 4 /setcmykcolor load } bind def - /Indexed - { dup 1 index 1 get //.csncompdict exch get exec - % Stack: [/Indexed base hival map] ncomp basesetcolor - 3 -1 roll 3 get mark 3 1 roll - % Stack: ncomp -mark- basesetcolor map - dup type /stringtype eq - { { - - { exch round cvi get 255 div - } - - - { exch round cvi 3 mul 2 copy 2 copy get 255 div - 3 1 roll 1 add get 255 div - 4 2 roll 2 add get 255 div - } - { exch round cvi 4 mul 2 copy 2 copy 2 copy get 255 div - 3 1 roll 1 add get 255 div - 4 2 roll 2 add get 255 div - 5 3 roll 3 add get 255 div - } - } - 4 index get aload pop counttomark -1 roll - } - { /exec load 3 -1 roll - % Stack: -mark- mapproc --exec-- basesetcolor - } - ifelse .packtomark cvx - exch pop 1 exch - } bind def - /Separation - { dup 2 index //.csncompdict exch get exec - % Stack: [/Separation name alt xform] ncomp altsetcolor - 3 -1 roll 3 get /exec load 3 -1 roll 3 array astore readonly cvx - exch pop 1 exch - } bind def - % Substitute device spaces for CIE spaces. - /CIEBasedA /DeviceGray load def - /CIEBasedABC /DeviceRGB load def - /CIEBasedDEF /DeviceRGB load def - /CIEBasedDEFG /DeviceCMYK load def -end - -/.packtomark { counttomark packedarray exch pop } bind def - -/.csinextbits % - .csinextbits <bits> - % Uses b, nnb, i, row, mask, BitsPerComponent; - % sets b, nnb, i. - { /nnb nnb BitsPerComponent add - { dup 0 le { exit } if - /b b 8 bitshift row i get add def - /i i 1 add def 8 sub - } - loop def - b nnb bitshift mask and - } bind def - -% Note that the ColorSpace key must be present in the image dictionary. -/.colorspaceimage % <imagedict> .colorspaceimage - - { save exch - dup length 15 add dict begin { cvlit def } forall - ColorSpace dup dup type /nametype ne { 0 get } if - .csncompdict exch get exec - /setpixelcolor exch def /ncomp exch def pop - /row ncomp BitsPerComponent mul Width mul 7 add 8 idiv string def - /mask 1 BitsPerComponent bitshift 1 sub def - /nextbits BitsPerComponent 8 eq - { { row i get /i i 1 add def } } - { /.csinextbits load } - ifelse def - /nextpixel mark 0 2 ncomp 1 sub 2 mul - { /nextbits cvx exch - Decode exch 2 getinterval - dup aload pop exch sub - dup mask eq { pop } { mask div /mul load 3 -1 roll } ifelse - 0 get dup 0 eq { pop } { /sub load 3 -1 roll } ifelse - } - for - /setpixelcolor load dup type /operatortype ne { /exec load } if - .packtomark cvx def - /readrow - /DataSource load dup type - dup /arraytype eq exch /packedarraytype eq or - { % Must be { <file> <string> ... } - aload length 1 add array /pop load exch astore - dup 1 row put cvx - } - { pop - % Adobe requires readstring to signal an error if given - % an empty string. Work around this nonsense here. - row length 0 eq - { { } } - { { DataSource row readstring pop pop } } - ifelse - } - ifelse def - ImageMatrix matrix invertmatrix concat - /imat matrix def - 0 1 Height 1 sub - { imat 5 3 -1 roll neg put - readrow - /b 0 def /nnb 0 def /i 0 def - 0 1 Width 1 sub - { imat 4 3 -1 roll neg put nextpixel - 1 1 //true imat {<80>} imagemask - } - for - } - for - end restore - } bind def - -%END -exec -currentfile closefile - -% Patch for testing. -/.cincompdict 3 dict begin - 1 { {0 1} {/DeviceGray} } def - 3 { {0 1 0 1 0 1} {/DeviceRGB} } def - 4 { {0 1 0 1 0 1 0 1} {/DeviceCMYK} } def -currentdict end def -/.imagekeys [ - /Decode /DataSource /ImageMatrix /BitsPerComponent /Height /Width -] def -/colorimage % <width> <height> <bits/comp> <matrix> - % <datasrc> false <ncomp> colorimage - - { 1 index { /colorimage .systemvar /rangecheck signalerror } if exch pop - //.cincompdict exch get exec - 7 dict begin /ColorSpace exch cvlit def - .imagekeys { exch cvlit def } forall - currentdict end .colorspaceimage - } bind odef -/image - { dup type /dicttype ne - { 7 dict begin /ColorSpace /DeviceGray def [0 1] - .imagekeys { exch cvlit def } forall - currentdict end - } - { dup length 1 add dict .copydict dup /ColorSpace currentcolorspace put - } - ifelse - .colorspaceimage - } bind odef - -exec diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_lev2.ps b/Master/tlpkg/tlgs/Resource/Init/gs_lev2.ps index 44fe6195665..98d55fe7425 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_lev2.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_lev2.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 @@ -64,7 +64,7 @@ level2dict begin pop } ifelse pop pop } forall pop pop -} .bind def % not odef, shouldn't reset stacks +} .bind def % currentuser/systemparams creates and returns a dictionary in the % current VM. The easiest way to make this work is to copy any composite @@ -101,7 +101,7 @@ level2dict begin 1 index length string exch .setglobal copy exch not { readonly } if } if -} .bind def +} .bind odef % Some user parameters are managed entirely at the PostScript level. % We take care of that here. @@ -117,7 +117,7 @@ counttomark 2 idiv { } repeat pop /.definepsuserparam { % <name> <value> .definepsuserparam - psuserparams 3 copy pop - type cvlit /.checkparamtype cvx 2 packedarray cvx put + type cvlit //.checkparamtype /exec load 3 packedarray cvx put userparams 3 1 roll put } .bind def end @@ -129,7 +129,7 @@ end /.setuserparams2 { % Check that we will be able to set the PostScript-level % user parameters. - /setuserparams /psuserparams .systemvar .checksetparams + /setuserparams /psuserparams .systemvar //.checksetparams exec % Set the C-level user params. If this succeeds, we know that % the password check succeeded. dup .setuserparams @@ -154,7 +154,8 @@ end % protect top level of parameters that we copied dup type dup /arraytype eq exch /stringtype eq or { readonly } if /userparams .systemvar 3 1 roll .forceput % userparams is read-only - } { + } executeonly + { pop pop } ifelse } forall @@ -210,8 +211,8 @@ end } forall } if /setsystemparams //pssystemparams mark exch { - type cvlit /.checkparamtype cvx 2 packedarray cvx - } forall .dicttomark .checksetparams + type cvlit //.checkparamtype /exec load 3 packedarray cvx + } forall .dicttomark //.checksetparams exec % Set the C-level system params. If this succeeds, we know that % the password check succeeded. dup .setsystemparams @@ -224,7 +225,7 @@ end % protect top level parameters that we copied dup type dup /arraytype eq exch /stringtype eq or { readonly } if //pssystemparams 3 1 roll .forceput % pssystemparams is read-only - } + } executeonly { pop pop } ifelse @@ -303,31 +304,30 @@ end psuserparams exch /.checkFilePermitparams load put .setglobal -pssystemparams begin - /CurDisplayList 0 .forcedef - /CurFormCache 0 .forcedef - /CurInputDevice () .forcedef - /CurOutlineCache 0 .forcedef - /CurOutputDevice () .forcedef - /CurPatternCache 0 .forcedef - /CurUPathCache 0 .forcedef - /CurScreenStorage 0 .forcedef - /CurSourceList 0 .forcedef - /DoPrintErrors //false .forcedef - /JobTimeout 0 .forcedef - /LicenseID (LN-001) .forcedef % bogus - /MaxDisplayList 140000 .forcedef - /MaxFormCache 100000 .forcedef - /MaxImageBuffer 524288 .forcedef - /MaxOutlineCache 65000 .forcedef - /MaxPatternCache 100000 .forcedef - /MaxUPathCache 300000 .forcedef - /MaxScreenStorage 84000 .forcedef - /MaxSourceList 25000 .forcedef - /PrinterName product .forcedef - /RamSize 4194304 .forcedef - /WaitTimeout 40 .forcedef -end +pssystemparams +dup /CurDisplayList 0 .forceput +dup /CurFormCache 0 .forceput +dup /CurInputDevice () .forceput +dup /CurOutlineCache 0 .forceput +dup /CurOutputDevice () .forceput +dup /CurPatternCache 0 .forceput +dup /CurUPathCache 0 .forceput +dup /CurScreenStorage 0 .forceput +dup /CurSourceList 0 .forceput +dup /DoPrintErrors //false .forceput +dup /JobTimeout 0 .forceput +dup /LicenseID (LN-001) .forceput % bogus +dup /MaxDisplayList 140000 .forceput +dup /MaxFormCache 100000 .forceput +dup /MaxImageBuffer 524288 .forceput +dup /MaxOutlineCache 65000 .forceput +dup /MaxPatternCache 100000 .forceput +dup /MaxUPathCache 300000 .forceput +dup /MaxScreenStorage 84000 .forceput +dup /MaxSourceList 25000 .forceput +dup /PrinterName product .forceput +dup /RamSize 4194304 .forceput + /WaitTimeout 40 .forceput % Define the procedures for handling comment scanning. The names % %ProcessComment and %ProcessDSCComment are known to the interpreter. @@ -344,13 +344,13 @@ end } ifelse } .bind def /ProcessComment //null .definepsuserparam -psuserparams /ProcessComment {.checkprocesscomment} put +psuserparams /ProcessComment {//.checkprocesscomment exec} put (%ProcessComment) cvn { /ProcessComment getuserparam dup //null eq { pop pop pop } { exec } ifelse } bind def /ProcessDSCComment //null .definepsuserparam -psuserparams /ProcessDSCComment {.checkprocesscomment} put +psuserparams /ProcessDSCComment {//.checkprocesscomment exec} put /.loadingfont //false def (%ProcessDSCComment) cvn { /ProcessDSCComment getuserparam @@ -434,7 +434,7 @@ psuserparams /ProcessDSCComment {.checkprocesscomment} put {pop /vmreclaim load $error /errorname get signalerror} {pop} ifelse } ifelse -} odef +} .bind executeonly odef -1 setvmthreshold % ------ IODevices ------ % @@ -492,7 +492,7 @@ end % serverdict clear cleardictstack initgraphics //false setglobal -} bind def +} bind executeonly def /.startjob { % <exit_bool> <password> <finish_proc> % .startjob <ok_bool> vmstatus pop pop serverdict /.jobsavelevel get eq @@ -515,14 +515,6 @@ end % serverdict { .startnewjob //true } .startjob } odef -% The procedure to undo the job encapsulation -/.endjob { - clear cleardictstack - serverdict /.jobsave get dup //null eq { pop } { restore } ifelse - serverdict /.jobsave //null put - 2 .vmreclaim % recover local and global VM -} odef - systemdict begin /quit { % - quit - //systemdict begin serverdict /.jobsave get //null eq @@ -555,7 +547,8 @@ end % serverdict % Note that statusdict must be allocated in local VM. % We don't bother with many of these yet. -/.dict1 { exch mark 3 1 roll .dicttomark } bind def +% convenience function to make a dictionary from an object and a key +/.pair2dict { exch mark 3 1 roll .dicttomark } bind def currentglobal //false setglobal 25 dict exch setglobal begin currentsystemparams @@ -568,11 +561,11 @@ systemdict /buildtime dup load put /checkpassword { .checkpassword 0 gt } bind def dup /DoStartPage known { /dostartpage { /DoStartPage getsystemparam } bind def - /setdostartpage { /DoStartPage .dict1 setsystemparams } bind def + /setdostartpage { /DoStartPage //.pair2dict exec setsystemparams } bind def } if dup /StartupMode known { /dosysstart { /StartupMode getsystemparam 0 ne } bind def - /setdosysstart { { 1 } { 0 } ifelse /StartupMode .dict1 setsystemparams } bind def + /setdosysstart { { 1 } { 0 } ifelse /StartupMode //.pair2dict exec setsystemparams } bind def } if %****** Setting jobname is supposed to set userparams.JobName, too. /jobname { /JobName getuserparam } bind def @@ -580,7 +573,7 @@ dup /StartupMode known /ramsize { /RamSize getsystemparam } bind def /realformat 1 index /RealFormat get def dup /PrinterName known - { /setprintername { /PrinterName .dict1 setsystemparams } bind def + { /setprintername { /PrinterName //.pair2dict exec setsystemparams } bind def } if /printername { currentsystemparams /PrinterName .knownget not { () } if exch copy @@ -615,19 +608,11 @@ currentuserparams /WaitTimeout known .dicttomark setpagedevice /WaitTimeout exch mark /JobTimeout 5 2 roll .dicttomark setsystemparams } bind def -/.setpagesize - { 2 copy 2 array astore /PageSize .dict1 { setpagedevice } stopped { - pop % the setpagedevice dict - /setpagesize $error /errorname get signalerror - } { - pop pop % success -- pop the arguments - } ifelse - } bind def -/setduplexmode { /Duplex .dict1 setpagedevice } bind def +/setduplexmode { /Duplex //.pair2dict exec setpagedevice } bind def /setmargins - { exch 2 array astore /Margins .dict1 setpagedevice + { exch 2 array astore /Margins //.pair2dict exec setpagedevice } bind def -/setpagemargin { 0 2 array astore /PageOffset .dict1 setpagedevice } bind def +/setpagemargin { 0 2 array astore /PageOffset //.pair2dict exec setpagedevice } bind def /setpageparams { mark /PageSize 6 -2 roll 4 index 1 and ORIENT1 { 1 } { 0 } ifelse ne { exch } if 2 array astore @@ -641,7 +626,7 @@ currentuserparams /WaitTimeout known { /setresolution /typecheck signalerror } if - dup 2 array astore /HWResolution .dict1 { setpagedevice } stopped { + dup 2 array astore /HWResolution //.pair2dict exec { setpagedevice } stopped { pop /setresolution $error /errorname get signalerror } if } bind def @@ -667,7 +652,7 @@ currentuserparams /WaitTimeout known } { % First see if the current value is valid so we don't have to guess mark .currentuserparams .dicttomark /ICCProfilesDir get - (default_gray.icc) concatstrings {status} .internalstopped + (default_gray.icc) concatstrings {status} //.internalstopped exec {pop //false} if { pop pop pop pop % current value was OK. Just clean up stack @@ -709,7 +694,7 @@ pop % currentsystemparams /statusdict currentdict def currentdict end -/statusdict exch .forcedef % statusdict is local, systemdict is global +currentdict exch /statusdict exch .forceput % statusdict is local, systemdict is global % The following compatibility operators are in systemdict. They are % defined here, rather than in gs_init.ps, because they require the @@ -915,34 +900,29 @@ mark .dicttomark ] def -% ------ Painting ------ % - -%% We don't want to do any high level forms stuff if the source -%% is PDF because : -%% 1) Transparent forms are handled separately and we don't want to ge confused -%% 2) PDF forms are too llikely to trip over the limitations in our support -%% 3) Its highly unusual to find a PDF file which uses forms sensibly. -%% -%% So we have a special PDF version of execform which doesn't do high level forms. +% Special type to install +% e-sRGB ICC profile color space +/CIEesRGBICC [ /ICCBased + mark + /N 3 + /DataSource (esrgb) + /Alternate [/DeviceRGB] + /Name (esrgb) + .dicttomark +] def -/.PDFexecform { - % This is a separate operator so that the stacks will be restored - % properly if an error occurs. - dup /Matrix get concat - dup /BBox get aload pop - exch 3 index sub exch 2 index sub rectclip - dup /PaintProc get - 1 index /Implementation known not { - 1 index dup /Implementation //null .forceput readonly pop - } if - exec -}.bind odef +% Special type to install +% rommRGB ICC profile color space +/CIErommRGBICC [ /ICCBased + mark + /N 3 + /DataSource (rommrgb) + /Alternate [/DeviceRGB] + /Name (rommrgb) + .dicttomark +] def -/PDFexecform { - gsave { - .PDFexecform - } stopped grestore {stop} if -} odef +% ------ Painting ------ % % A straightforward definition of execform that doesn't actually % do any caching. @@ -950,7 +930,7 @@ mark % This is a separate operator so that the stacks will be restored % properly if an error occurs. %% High level forms need the CTM before the Form Matrix is applied - /UNROLLFORMS where {/UNROLLFORMS get}{false}ifelse not + /UNROLLFORMS where {/UNROLLFORMS get}{//false}ifelse not {matrix currentmatrix exch} if dup /Matrix get concat dup /BBox get aload pop @@ -958,8 +938,8 @@ mark dup /PaintProc get 1 index /Implementation known not { 1 index dup /Implementation //null .forceput readonly pop - } if - /UNROLLFORMS where {/UNROLLFORMS get}{false}ifelse not + } executeonly if + /UNROLLFORMS where {/UNROLLFORMS get}{//false}ifelse not %% [CTM] <<Form>> PaintProc .beginform - { %% First,, check to see if we have no /Implementation already defined (see above) @@ -1005,7 +985,7 @@ mark %% Form dictioanry using the /Implementation key). 1 dict dup /FormID 4 -1 roll put 1 index exch /Implementation exch .forceput readonly pop - } + } executeonly ifelse } { @@ -1253,3 +1233,13 @@ def %END TN 5044 psuedo-ops end % level2dict + +% undefine things defined in this file and not referenced elsewhere +[ + /.checkprocesscomment + /.pair2dict + /.setcolorrendering1 + /.checkparamtype + /.checksetparams +] +{level2dict exch .forceundef} forall diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_ll3.ps b/Master/tlpkg/tlgs/Resource/Init/gs_ll3.ps index c86721f39fc..359579f3e72 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_ll3.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_ll3.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 @@ -38,7 +38,7 @@ languagelevel dup 2 .max .setlanguagelevel .knownget not { //false } if { //false - /IdiomSet .findcategory .Instances + /IdiomSet //.findcategory exec .Instances { exch pop % pop the IdiomSet identifying key. Stack /proc /false [-dict- status size] 0 get % get resource instance, a dictionary. Stack : /proc false -dict- @@ -100,6 +100,26 @@ DELAYBIND not { } if currentdict /.bind_ undef +/.readbytestring { % <source> <bytestring> .readbytestring + % <bytestring> <filled> + % Note that since bytestrings don't implement getinterval, + % if filled is false, there is no way to tell how much + % was read. + //true exch 0 1 2 index length 1 sub { + % Stack: source true str index + 3 index read not { pop exch not exch exit } if + 3 copy put pop pop + } for 3 -1 roll pop exch +} bind def + +/.bigstring { % <size> .bigstring <string|bytestring> + count 1 lt { /.bigstring /stackunderflow signalerror } if + dup type /integertype ne { + /.bigstring /typecheck signalerror + } if + dup 65400 gt { .bytestring } { string } ifelse +} bind def + % ------ HalftoneTypes 6, 10, 16 and HalftoneMode ------ % % This code depends on an internal HalftoneType 7 with the following keys: @@ -130,9 +150,9 @@ currentdict /.bind_ undef } ifelse 3 1 roll /Height 1 index def /Width 2 index def - mul add BitsPerSample 8 idiv mul .bigstring + mul add BitsPerSample 8 idiv mul //.bigstring exec % Stack: dict dict source str - dup type /stringtype eq { readstring } { .readbytestring } ifelse + dup type /stringtype eq { readstring } { //.readbytestring exec} ifelse not { /sethalftone .systemvar /rangecheck signalerror exit } if readonly /Thresholds exch def /TransferFunction .knownget { /TransferFunction exch def } if @@ -145,32 +165,12 @@ currentdict /.bind_ undef { .sethalftone5 } } bind def -/.bigstring { % <size> .bigstring <string|bytestring> - count 1 lt { /.bigstring /stackunderflow signalerror } if - dup type /integertype ne { - /.bigstring /typecheck signalerror - } if - dup 65400 gt { .bytestring } { string } ifelse -} bind def - -/.readbytestring { % <source> <bytestring> .readbytestring - % <bytestring> <filled> - % Note that since bytestrings don't implement getinterval, - % if filled is false, there is no way to tell how much - % was read. - //true exch 0 1 2 index length 1 sub { - % Stack: source true str index - 3 index read not { pop exch not exch exit } if - 3 copy put pop pop - } for 3 -1 roll pop exch -} bind def - /.sethalftone6 { % <dict> <dict> .sethalftone6 <setdict> <dict5> % { .sethalftone5 } % Keys: Width, Height, Thresholds, T'Function dup /Thresholds get 1 index /Width get 2 index /Height get - //null 8 .makehalftone7 + //null 8 //.makehalftone7 exec } bind def /.sethalftone10 { % <dict> <dict> .sethalftone10 <setdict> <dict5> @@ -180,7 +180,7 @@ currentdict /.bind_ undef % that allows either a file or a string for Thresholds. dup /Thresholds get dup type /stringtype eq { 0 () .subfiledecode } if 1 index /Xsquare get dup 3 index /Ysquare get dup - 8 .makehalftone7 + 8 //.makehalftone7 exec } bind def /.sethalftone16 { % <dict> <dict> .sethalftone16 <setdict> <dict5> @@ -193,13 +193,13 @@ currentdict /.bind_ undef 4 index /Height2 get } { % 1-rectangle case //null - } ifelse 16 .makehalftone7 + } ifelse 16 //.makehalftone7 exec } bind def .halftonetypes begin - 6 /.sethalftone6 load def - 10 /.sethalftone10 load def - 16 /.sethalftone16 load def + 6 //.sethalftone6 def + 10 //.sethalftone10 def + 16 //.sethalftone16 def end % Redefine the halftone-setting operators to honor HalftoneMode. @@ -207,7 +207,7 @@ end /HalftoneMode getuserparam 0 eq { //setcolorscreen } { - 12 { pop } repeat .getdefaulthalftone + 12 { pop } repeat //.getdefaulthalftone exec { //sethalftone } { .setdefaulthalftone } ifelse @@ -217,7 +217,7 @@ end /HalftoneMode getuserparam 0 eq { //setscreen } { - pop pop pop .getdefaulthalftone + pop pop pop //.getdefaulthalftone exec { //sethalftone } { .setdefaulthalftone } ifelse @@ -228,7 +228,7 @@ end //sethalftone } { gsave //sethalftone grestore - .getdefaulthalftone + //.getdefaulthalftone exec { //sethalftone } { .setdefaulthalftone } ifelse @@ -446,7 +446,7 @@ systemdict /.reuseparamdict mark } bind def /.buildshading_and_shfill { - .buildshading .shfill + //.buildshading exec .shfill } bind def systemdict /.reuseparamdict undef @@ -459,7 +459,7 @@ systemdict /.reuseparamdict undef mark currentcolor currentcolorspace counttomark 4 add -3 roll mark 4 1 roll % Stack: -mark- ..color.. cspace -mark- template matrix shadingdict - { .buildshading } stopped { + { //.buildshading exec} stopped { cleartomark setcolorspace setcolor pop stop } if .buildshadingpattern @@ -467,7 +467,7 @@ systemdict /.reuseparamdict undef } bind def .patterntypes - 2 /.buildpattern2 load put + 2 //.buildpattern2 put /shfill { % <shadingdict> shfill - % Currently, .shfill requires that the color space @@ -521,9 +521,8 @@ end % Define additional user and system parameters. /HalftoneMode 0 .definepsuserparam /MaxSuperScreen 1016 .definepsuserparam -pssystemparams begin % read-only, so use .forcedef - /MaxDisplayAndSourceList 160000 .forcedef -end +% read-only, so use .forceput +pssystemparams /MaxDisplayAndSourceList 160000 .forceput % Define the IdiomSet resource category. { /IdiomSet } { @@ -546,4 +545,16 @@ end .setlanguagelevel +% undefine things defined (or used) in this file and not referenced elsewhere +[ + /.buildpattern2 + /.buildshading + /.buildshading1 /.buildshading2 /.buildshading3 /.buildshading4 + /.buildshading5 /.buildshading6 /.buildshading7 /.buildshadingpattern + /.makehalftone7 /.sethalftone6 /.sethalftone10 /.sethalftone16 + /.readbytestring /.bigstring +] +dup {currentdict exch .forceundef} forall +{systemdict exch .forceundef} forall + end % ll3dict diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_mex_e.ps b/Master/tlpkg/tlgs/Resource/Init/gs_mex_e.ps index 2812cb8d4ad..7b28360fb0d 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_mex_e.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_mex_e.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 diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_mgl_e.ps b/Master/tlpkg/tlgs/Resource/Init/gs_mgl_e.ps index 4086fb04904..7c97efb95da 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_mgl_e.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_mgl_e.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 diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_mro_e.ps b/Master/tlpkg/tlgs/Resource/Init/gs_mro_e.ps index 17a194d2e1f..f3f15430be7 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_mro_e.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_mro_e.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 diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_pdf_e.ps b/Master/tlpkg/tlgs/Resource/Init/gs_pdf_e.ps index a285e491a50..382542add99 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_pdf_e.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_pdf_e.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 diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_pdfwr.ps b/Master/tlpkg/tlgs/Resource/Init/gs_pdfwr.ps index 58e75d3a483..00c19faf3c4 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_pdfwr.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_pdfwr.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 @@ -248,7 +248,7 @@ languagelevel 2 .setlanguagelevel /ColorConversionStrategy /LeaveColorUnchanged /ColorImageDownsampleType /Subsample /ColorImageResolution 600 - /DownsampleColorImages false + /DownsampleColorImages //false /CompatibilityLevel 1.2 % Always 1.2 with ps2write. % /CreateJobTicket //true % Not sure /DoThumbnails //false @@ -256,10 +256,10 @@ languagelevel 2 .setlanguagelevel /GrayACSImageDict .prepressACSImageDict /GrayImageDownsampleType /Subsample /GrayImageResolution 600 - /DownsampleGrayImages false + /DownsampleGrayImages //false /MonoImageDownsampleType /Subsample /MonoImageResolution 1200 - /DownsampleMonoImages false + /DownsampleMonoImages //false /NeverEmbed [] /PreserveEPSInfo //true /PreserveOPIComments //true @@ -650,7 +650,7 @@ currentdict /.pdfmarkparams .undef } ifelse } bind .makeoperator .forceput systemdict /.pdf_hooked_DSC_Creator //true .forceput - } if + } executeonly if pop } if } { @@ -928,7 +928,7 @@ currentdict /.pdf_hook_DSC_Creator undef }{ //true }ifelse - { pop false } if + { pop //false } if } { known } ifelse @@ -980,7 +980,7 @@ currentdict /.pdf_hook_DSC_Creator undef }ifelse systemdict /ProvideUnicode .knownget not { //false } if or { - currentglobal true setglobal + currentglobal //true setglobal systemdict /.setupUnicodeDecoder known { /Unicode /Decoding resourcestatus { pop pop diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_res.ps b/Master/tlpkg/tlgs/Resource/Init/gs_res.ps index 8eb8bb0e582..0f8cb8f6cd1 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_res.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_res.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 @@ -41,10 +41,10 @@ level2dict begin % However, Ed Taft of Adobe says their interpreters don't implement this % either, so we aren't going to worry about it for a while. -currentglobal //false setglobal systemdict begin - /localinstancedict 5 dict - .forcedef % localinstancedict is local, systemdict is global -end //true setglobal +currentglobal //false setglobal + systemdict /localinstancedict 5 dict + .forceput % localinstancedict is local, systemdict is global +//true setglobal /.emptydict 0 dict readonly def setglobal @@ -149,10 +149,10 @@ setglobal dup [ exch 0 -1 ] exch .Instances 4 2 roll put % Make the Category dictionary read-only. We will have to - % use .forceput / .forcedef later to replace the dummy, + % use .forceput / .forceput later to replace the dummy, % empty .Instances dictionary with the real one later. readonly - } { + }{ /defineresource cvx /typecheck signaloperror } ifelse } bind executeonly odef @@ -196,8 +196,8 @@ setglobal % can use it without entering another level of pseudo-operator. /.findresource { % <key> <category> findresource <instance> 2 copy dup /Category eq - { pop //Category 0 get begin } { .findcategory } ifelse - /FindResource .resourceexec exch pop exch pop + { pop //Category 0 get begin } { //.findcategory exec } ifelse + /FindResource //.resourceexec exec exch pop exch pop } bind end % .Instances of Category def @@ -216,14 +216,14 @@ def 2 .argindex 2 index 2 index % catch stackunderflow % See above re .errorexec. /defineresource cvx { - .findcategory + //.findcategory exec currentdict /InstanceType known { dup type InstanceType ne { dup type /packedarraytype eq InstanceType /arraytype eq and not { /defineresource cvx /typecheck signaloperror } if } if } if - /DefineResource .resourceexec + /DefineResource //.resourceexec exec 4 1 roll pop pop pop } .errorexec } bind executeonly odef @@ -235,7 +235,7 @@ def % calls, so stack protection doesn't apply to the very last token of an % operator procedure. /resourceforall1 { % <template> <proc> <scratch> <category> resourceforall1 - - dup .findcategory + dup //.findcategory exec /ResourceForAll load % Stack: <template> <proc> <scratch> <category> proc exch pop % pop the category @@ -252,7 +252,7 @@ def % without the check. /resourcestatus cvx /typecheck signalerror } if - 2 copy .findcategory /ResourceStatus .resourceexec + 2 copy //.findcategory exec /ResourceStatus //.resourceexec exec { 4 2 roll pop pop //true } { pop pop //false } ifelse } stopped { % Although resourcestatus is an operator, Adobe uses executable name @@ -266,7 +266,7 @@ def } if 1 .argindex 1 index % catch stackunderflow - { .findcategory /UndefineResource .resourceexec pop pop + { //.findcategory exec /UndefineResource //.resourceexec exec pop pop } stopped { % Although undefineresource is an operator, Adobe uses executable name % here but uses operator for the errors above. CET 23-33 @@ -304,7 +304,8 @@ systemdict begin dup () ne { .file_name_directory_separator concatstrings } if - 2 index exch //false .file_name_combine not { + 2 index exch //false + .file_name_combine not { (Error: .default_resource_dir returned ) print exch print ( that can't combine with ) print = /.default_resource_dir cvx /configurationerror signalerror } if @@ -315,16 +316,16 @@ currentdict /pssystemparams known not { /pssystemparams 10 dict readonly def } if pssystemparams begin - .default_resource_dir - /FontResourceDir (Font) .resource_dir_name - readonly .forcedef % pssys'params is r-o - /GenericResourceDir () .resource_dir_name - readonly .forcedef % pssys'params is r-o + //.default_resource_dir exec + /FontResourceDir (Font) //.resource_dir_name exec + readonly currentdict 3 1 roll .forceput % pssys'params is r-o + /GenericResourceDir () //.resource_dir_name exec + readonly currentdict 3 1 roll .forceput % pssys'params is r-o pop % .default_resource_dir /GenericResourcePathSep - .file_name_separator readonly .forcedef % pssys'params is r-o - (%diskFontResourceDir) cvn (/Resource/Font/) readonly .forcedef % pssys'params is r-o - (%diskGenericResourceDir) cvn (/Resource/) readonly .forcedef % pssys'params is r-o + .file_name_separator readonly currentdict 3 1 roll .forceput % pssys'params is r-o + currentdict (%diskFontResourceDir) cvn (/Resource/Font/) readonly .forceput % pssys'params is r-o + currentdict (%diskGenericResourceDir) cvn (/Resource/) readonly .forceput % pssys'params is r-o end end @@ -387,13 +388,13 @@ status { } bind def /.localresourceforall { % <key> <value> <args> .localr'forall - exch pop - 2 copy 0 get .stringmatch { .enumerateresource } { pop pop } ifelse + 2 copy 0 get .stringmatch { //.enumerateresource exec } { pop pop } ifelse } bind def /.globalresourceforall { % <key> <value> <args> .globalr'forall - exch pop 2 copy 0 get .stringmatch { dup 3 get begin .LocalInstances end 2 index known not { - .enumerateresource + //.enumerateresource exec } { pop pop } ifelse @@ -408,7 +409,7 @@ status { 3 index known { pop pop pop } { - 2 index known { pop pop } { .enumerateresource } ifelse + 2 index known { pop pop } { //.enumerateresource exec } ifelse } ifelse } bind def @@ -422,10 +423,10 @@ status { .Instances dup //.emptydict eq { pop 3 dict % As noted above, Category dictionaries are read-only, - % so we have to use .forcedef here. - /.Instances 1 index .forcedef % Category dict is read-only - } if - } + % so we have to use .forceput here. + currentdict /.Instances 2 index .forceput % Category dict is read-only + } executeonly if + } executeonly { .LocalInstances dup //.emptydict eq { pop 3 dict localinstancedict Category 2 index put } @@ -435,13 +436,13 @@ status { % Stack: key value instance instancedict 3 index 2 index .growput % Now make the resource value read-only. - 0 2 copy get { readonly } .internalstopped pop + 0 2 copy get { readonly } //.internalstopped exec pop dup 4 1 roll put exch pop exch pop - } + } executeonly { /defineresource cvx /typecheck signaloperror } ifelse -} .bind executeonly .makeoperator % executeonly to prevent access to .forcedef +} .bind executeonly .makeoperator % executeonly to prevent access to .forceput /UndefineResource { { dup 2 index .knownget { dup 1 get 1 ge @@ -468,19 +469,19 @@ status { % .knownget doesn't fail on null /findresource cvx /typecheck signaloperror } if - dup .getvminstance { + dup //.getvminstance exec { exch pop 0 get } { dup ResourceStatus { pop 1 gt { - .DoLoadResource .getvminstance not { - /findresource cvx .undefinedresource + .DoLoadResource //.getvminstance exec not { + /findresource cvx //.undefinedresource exec } if 0 get } { .GetInstance pop 0 get } ifelse } { - /findresource cvx .undefinedresource + /findresource cvx //.undefinedresource exec } ifelse } ifelse } bind executeonly @@ -621,20 +622,20 @@ status { .currentglobal not .setglobal vmstatus pop exch pop add } repeat -} bind def +} bind executeonly odef /.DoLoadResource { % .LoadResource may push entries on the operand stack. % It is an undocumented feature of Adobe implementations, % which we must match for the sake of some badly written % font downloading code, that such entries are popped % automatically. - count 1 index cvlit .vmused + count 1 index cvlit //.vmused % Stack: key count litkey memused {.LoadResource} 4 1 roll 4 .execn % Stack: ... count key memused - .vmused exch sub - 1 index .getvminstance not { - pop dup .undefinedresource % didn't load + //.vmused exch sub + 1 index //.getvminstance exec not { + pop dup //.undefinedresource exec % didn't load } if dup 1 1 put 2 3 -1 roll put @@ -644,11 +645,11 @@ status { /.LoadResource { dup .ResourceFile { exch pop currentglobal - { .runresource } - { //true setglobal { .runresource } stopped //false setglobal { stop } if } + { //.runresource exec } + { //true setglobal { //.runresource exec } stopped //false setglobal { stop } if } ifelse } - { dup .undefinedresource + { dup //.undefinedresource exec } ifelse } bind @@ -667,10 +668,10 @@ status { } { pop currentdict /ResourceFileName known { - mark 1 index //.rfnstring { ResourceFileName } .internalstopped { + mark 1 index //.rfnstring { ResourceFileName } //.internalstopped exec { cleartomark //false } { - (r) { file } .internalstopped { + (r) { file } //.internalstopped exec { cleartomark //false } { exch pop exch pop //true @@ -703,7 +704,7 @@ mark /ColorSpaceFamily { } % These must be deferred, because optional features may add some. /Emulator - mark EMULATORS { <00> search { exch pop cvn exch }{ cvn exit } ifelse } .bind loop .packtomark + mark EMULATORS { <00> search { exch pop cvn exch }{ cvn exit } ifelse } .bind loop //.packtomark exec /Filter { } % These must be deferred, because optional features may add some. /IODevice @@ -712,10 +713,10 @@ mark errordict /rangecheck { pop stop } put % pop the command mark 0 { { dup .getiodevice dup //null eq { pop } { exch } ifelse 1 add - } loop} .internalstopped - pop pop pop .packtomark + } loop} //.internalstopped exec + pop pop pop //.packtomark exec 4 1 roll put - .clearerror + //.clearerror exec % Type categories listed in the Red Book. /ColorRenderingType { } % These must be deferred, because optional features may add some. @@ -758,13 +759,13 @@ counttomark 2 idiv /FindResource { .Instances 1 index .knownget { exch pop } - { /findresource cvx .undefinedresource } + { /findresource cvx //.undefinedresource exec } ifelse } bind executeonly /ResourceStatus { .Instances exch known { 0 0 //true } { //false } ifelse } bind executeonly /ResourceForAll - /Generic .findcategory /ResourceForAll load end + /Generic //.findcategory exec /ResourceForAll load end % Additional entries @@ -826,7 +827,7 @@ counttomark 2 idiv 0 { {dup .getdevice .devicename cvn 1 dict dup /PageSize [1 1 14400 14400] put [exch readonly 0 -1] 3 -1 roll 1 add} loop -} .internalstopped pop +} //.internalstopped exec pop %% Remove the count, and the duplicate, from the stack pop pop .dicttomark @@ -862,7 +863,7 @@ userdict /.localcsdefaults //false put 2 copy /Generic /Category findresource /DefineResource get exec exch pop exch //.defaultcsnames exch .knownget { - 1 index .definedefaultcs + 1 index //.definedefaultcs exec currentglobal not { .userdict /.localcsdefaults //true put } if } if } bind executeonly @@ -872,13 +873,13 @@ userdict /.localcsdefaults //false put //.defaultcsnames 1 index .knownget { % Stack: resname index currentglobal { - .undefinedefaultcs pop + //.undefinedefaultcs exec pop } { % We removed the local definition, but there might be a global one. exch .GetInstance { - 0 get .definedefaultcs + 0 get //.definedefaultcs exec } { - .undefinedefaultcs + //.undefinedefaultcs exec } ifelse % Recompute .localcsdefaults by scanning. This is rarely needed. .userdict /.localcsdefaults //false //.defaultcsnames { @@ -945,6 +946,7 @@ userdict /.localcsdefaults //false put dup type /nametype eq { .fontstatus { pop //null exit } if } { + dup type /dicttype eq {/Path .knownget pop} if dup type /stringtype eq { findlibfile { closefile pop //null exit } if pop } { @@ -961,7 +963,7 @@ userdict /.localcsdefaults //false put dup type /nametype eq { .namestring } if dup type /stringtype ne { //false exit } if % Check the resource directory. - dup .fonttempstring /FontResourceDir getsystemparam .genericrfn + dup //.fonttempstring /FontResourceDir getsystemparam .genericrfn status { pop pop pop pop //true exit } if @@ -969,7 +971,7 @@ userdict /.localcsdefaults //false put % as the font. findlibfile { closefile //true exit } if % Scan a FONTPATH directory and try again. - .scannextfontdir not { //false exit } if + //.scannextfontdir exec not { //false exit } if } loop } bind def @@ -981,7 +983,7 @@ userdict /.localcsdefaults //false put { //.fontstatusaux exec } { //false } ifelse } ifelse -} bind def +} bind executeonly def currentdict /.fontstatusaux .undef /Font mark @@ -997,7 +999,7 @@ currentdict /.fontstatusaux .undef /Generic /Category findresource /UndefineResource get exec } bind executeonly /FindResource { - dup .getvminstance { + dup //.getvminstance exec { exch pop 0 get } { dup ResourceStatus { @@ -1008,7 +1010,7 @@ currentdict /.fontstatusaux .undef } ifelse } bind executeonly /ResourceForAll { - { .scannextfontdir not { exit } if } loop + { //.scannextfontdir exec not { exit } if } loop /Generic /Category findresource /ResourceForAll get exec } bind executeonly /.ResourceFileStatus { @@ -1016,15 +1018,15 @@ currentdict /.fontstatusaux .undef } bind executeonly /.loadfontresource { - dup .vmused exch + dup //.vmused exch % Hack: rebind .currentresourcefile so that all calls of % definefont will know these are built-in fonts. currentfile {pop //findfont exec} .execasresource % (findfont is a procedure) - exch .vmused exch sub + exch //.vmused exch sub % stack: name font vmused % findfont has the prerogative of not calling definefont % in certain obscure cases of font substitution. - 2 index .getvminstance { + 2 index //.getvminstance exec { dup 1 1 put 2 3 -1 roll put } { @@ -1054,7 +1056,9 @@ currentdict /.fontstatusaux .undef % Make sure the old definitions are still in systemdict so that % they will get bound properly. -systemdict begin +% NOTE: Mystery code... I can't just delete this, but don't understand why. +% Instead we will undef these three operators in gs_init.ps after all the initialization is done. + systemdict begin /.origdefinefont /definefont load def /.origundefinefont /undefinefont load def /.origfindfont /findfont load def @@ -1120,7 +1124,15 @@ end % level2dict /sGrayICC exch /ColorSpace defineresource pop systemdict /CIEsGRAYICC undef } if - % ColorSpaceFamily resources + systemdict /CIEesRGBICC .knownget { + /esRGBICC exch /ColorSpace defineresource pop + systemdict /CIEesRGBICC undef + } if + systemdict /CIErommRGBICC .knownget { + /rommRGBICC exch /ColorSpace defineresource pop + systemdict /CIErommRGBICC undef + } if + % ColorSpaceFamily resources colorspacedict { pop dup /ColorSpaceFamily defineresource pop } forall % Filter resources filterdict { pop dup /Filter defineresource pop } forall @@ -1159,3 +1171,26 @@ end % level2dict %% Replace 1 (gs_resmp.ps) (gs_resmp.ps) dup runlibfile VMDEBUG + +[ + /.default_resource_dir + /.resource_dir_name + /.fonttempstring /.scannextfontdir % from gs_fonts.ps +] +{systemdict exch .forceundef} forall + +[ + /.definedefaultcs + /.undefinedefaultcs + /.defaultcsnames + /.enumerateresource + /.externalresourceforall + /.getvminstance + /.globalresourceforall + /.localresourceforall + /resourceforall1 + /.resourceexec + /.undefinedresource + /.vmused +] +{level2dict exch .forceundef} forall diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_resmp.ps b/Master/tlpkg/tlgs/Resource/Init/gs_resmp.ps index 9bb42638ad2..c7122e9a26d 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_resmp.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_resmp.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 @@ -230,7 +230,7 @@ currentpacking //false setpacking } { dup dup .map exch .knownget { % /Name /Name <<record>> dup dup /RecordVirtualMethods get /IsActive get exec { - 1 index .getvminstance { % /Name /Name <<record>> holder + 1 index //.getvminstance exec { % /Name /Name <<record>> holder 1 get 1 eq } { //true @@ -242,7 +242,7 @@ currentpacking //false setpacking DefineResource exec % size bStatusIs1 /Name Instance % Make ResourceStatus to return correct values for this instance : % Hack: we replace status values in the instance holder : - exch .getvminstance pop % size bStatusIs1 Instance holder + exch //.getvminstance exec pop % size bStatusIs1 Instance holder dup 5 -1 roll 2 exch put % bStatusIs1 Instance holder 3 2 roll { % Instance holder 1 1 put % Instance 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 diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_statd.ps b/Master/tlpkg/tlgs/Resource/Init/gs_statd.ps index 20d4c96c4f8..3ea50eeead3 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_statd.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_statd.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 @@ -21,15 +21,25 @@ 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 91 dict .forcedef % statusdict is local, sys'dict global + currentdict /statusdict 91 dict .forceput % 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 + currentdict /serverdict 10 dict .forceput % serverdict is local, sys'dict global .setglobal end statusdict begin +/.setpagesize +{ 2 copy 2 array astore /PageSize exch mark 3 1 roll .dicttomark + { setpagedevice } stopped { + pop % the setpagedevice dict + /setpagesize $error /errorname get signalerror + } { + pop pop % success -- pop the arguments + } ifelse +} bind def + % Keep the table of named paper sizes as procedures. Reuse them later % as compatibility operators. /.pagetypeprocs 70 dict begin @@ -39,14 +49,6 @@ statusdict begin % 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 } stopped { - /setpagesize $error /errorname get signalerror - } if - end -} bind def - % 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). @@ -132,7 +134,6 @@ statusdict begin /ANSI_F {2016 2880 //.setpagesize stopped { pop pop /ANSI_F $error /errorname get signalerror } if } bind def %END SIZES currentdict end -dup /.setpagesize .undef userdict begin dup { def } forall end % reuse! readonly def @@ -164,19 +165,19 @@ readonly def % Tray and format selection - /11x17tray {/11x17 .uservar stopped { pop pop /11x17tray $error /errorname get signalerror } if } bind def - /a3tray {/a3 .uservar stopped { pop pop /a3tray $error /errorname get signalerror } if } bind def - /a4tray {/a4 .uservar stopped { pop pop /a4tray $error /errorname get signalerror } if } bind def - /a5tray {/a5 .uservar stopped { pop pop /a5tray $error /errorname get signalerror } if } bind def - /a6tray {/a6 .uservar stopped { pop pop /a6tray $error /errorname get signalerror } if } bind def - /b4tray {/b4 .uservar stopped { pop pop /b4tray $error /errorname get signalerror } if } bind def - /b5tray {/b5 .uservar stopped { pop pop /b5tray $error /errorname get signalerror } if } bind def - /flsatray {/flsa .uservar stopped { pop pop /flsatray $error /errorname get signalerror } if } bind def - /flsetray {/flse .uservar stopped { pop pop /flsetray $error /errorname get signalerror } if } bind def - /halflettertray {/halfletter .uservar stopped { pop pop /halflettertray $error /errorname get signalerror } if } bind def - /ledgertray {/ledger .uservar stopped { pop pop /ledgertray $error /errorname get signalerror } if } bind def - /legaltray {/legal .uservar stopped { pop pop /legaltray $error /errorname get signalerror } if } bind def - /lettertray {/letter .uservar stopped { pop pop /lettertray $error /errorname get signalerror } if } bind def +/11x17tray {/11x17 .uservar stopped { pop pop /11x17tray $error /errorname get signalerror } if } bind executeonly def +/a3tray {/a3 .uservar stopped { pop pop /a3tray $error /errorname get signalerror } if } bind executeonly def +/a4tray {/a4 .uservar stopped { pop pop /a4tray $error /errorname get signalerror } if } bind executeonly def +/a5tray {/a5 .uservar stopped { pop pop /a5tray $error /errorname get signalerror } if } bind executeonly def +/a6tray {/a6 .uservar stopped { pop pop /a6tray $error /errorname get signalerror } if } bind executeonly def +/b4tray {/b4 .uservar stopped { pop pop /b4tray $error /errorname get signalerror } if } bind executeonly def +/b5tray {/b5 .uservar stopped { pop pop /b5tray $error /errorname get signalerror } if } bind executeonly def +/flsatray {/flsa .uservar stopped { pop pop /flsatray $error /errorname get signalerror } if } bind executeonly def +/flsetray {/flse .uservar stopped { pop pop /flsetray $error /errorname get signalerror } if } bind executeonly def +/halflettertray {/halfletter .uservar stopped { pop pop /halflettertray $error /errorname get signalerror } if } bind executeonly def +/ledgertray {/ledger .uservar stopped { pop pop /ledgertray $error /errorname get signalerror } if } bind executeonly def +/legaltray {/legal .uservar stopped { pop pop /legaltray $error /errorname get signalerror } if } bind executeonly def +/lettertray {/letter .uservar stopped { pop pop /lettertray $error /errorname get signalerror } if } bind executeonly def % Per-job parameters @@ -255,12 +256,12 @@ readonly def } bind def /setpage { ORIENT1 { 1 } { 0 } ifelse ne {exch} if - statusdict /.setpagesize get exec + //.setpagesize exec } bind def /setpagemargin {pop} bind def % can't do better without setpagedevice /setpageparams { exch pop ORIENT1 { 1 } { 0 } ifelse ne {exch} if - statusdict /.setpagesize get exec + //.setpagesize exec } bind def /setpagetype { statusdict begin @@ -307,13 +308,6 @@ readonly def %%%%%% End of documented items. -/.setpagesize - { mark /HWSize [ - 4 index 4 index matrix defaultmatrix dtransform - abs ceiling cvi exch abs ceiling cvi exch - ] currentdevice putdeviceprops pop pop pop - initmatrix initclip erasepage - } bind def /.password 0 def /.timeouts [0 60 30] def //true setdostartpage @@ -322,6 +316,7 @@ mark setidlefonts 0 0 setmargins product setprintername +currentdict /.setpagesize .undef end % statusdict %%%%%% The following documented compatibility "operators" are in systemdict, diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_std_e.ps b/Master/tlpkg/tlgs/Resource/Init/gs_std_e.ps index aef9036eaca..f4ea79e310a 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_std_e.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_std_e.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 diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_sym_e.ps b/Master/tlpkg/tlgs/Resource/Init/gs_sym_e.ps index 4c2eb95db6d..b9abc86f7fe 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_sym_e.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_sym_e.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 diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_trap.ps b/Master/tlpkg/tlgs/Resource/Init/gs_trap.ps index 236b85e0083..58c5888a095 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_trap.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_trap.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 @@ -36,7 +36,7 @@ languagelevel dup 2 .max .setlanguagelevel } forall pop dup .settrapparams % Let the operator check parameter validity. .userdict /.trapparams 3 -1 roll put pop -} bind .makeoperator +} bind executeonly .makeoperator /.copyparams { % <obj> .copyparams <obj'> dup type /dicttype eq { @@ -53,7 +53,7 @@ languagelevel dup 2 .max .setlanguagelevel /currenttrapparams dup { % - currenttrapparams <paramdict> /.trapparams .uservar .copyparams -} bind .makeoperator +} bind executeonly .makeoperator /settrapzone dup { % - settrapzone - % ****** DUMMY ****** diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_ttf.ps b/Master/tlpkg/tlgs/Resource/Init/gs_ttf.ps index 05943c5d716..e34967dd78d 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_ttf.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_ttf.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 @@ -36,128 +36,6 @@ ] def } if -% <file> <key> .findfontvalue <value> true -% <file> <key> .findfontvalue false -% Closes the file in either case. -/.findnonttfontvalue /.findfontvalue load def -/.findfontvalue { - 1 index .is_woff { - dup /FontType eq { - pop closefile 42 //true - } { - dup /FontName eq { pop .findwoffname } { pop closefile //false } ifelse - } ifelse - } - { - 1 index .is_ttf_or_otf { - % If this is a font at all, it's a TrueType font. - dup /FontType eq { - pop closefile 42 //true - } { - dup /FontName eq { pop .findttfontname } { pop closefile //false } ifelse - } ifelse - } { - % Not a TrueType font. - .findnonttfontvalue - } ifelse - } ifelse -} bind def - -% <file> .findttfontname <fname> true -% <file> .findttfontname false -% Closes the file in either case. -/.findttfontname { - //true 0 .loadttfonttables - tabdict /name .knownget { - dup 8 getu32 f exch setfileposition - 12 getu32 - dup 65535 gt { pop 65535 } if % protect against extremely large name - string f exch readstring pop - dup - 6 findname not { - 4 findname % Try FullName - } { - exch pop //true - } - ifelse - } { - //false - } ifelse - f closefile end end -} bind def - -/.findwoffname { - //true 0 .loadwofftables - tabdict /name .knownget { - dup /clen exch 8 getu32 def - dup /olen exch 12 getu32 def - 4 getu32 f exch setfileposition - olen dup 65535 gt { pop 65535 } if % protect against extremely large name - /fs - clen olen ne - {f clen () /SubFileDecode filter /FlateDecode filter} - {f clen () /SubFileDecode filter} - ifelse def - string fs exch readstring pop - fs closefile - dup - 6 findname not { - 4 findname % Try FullName - } { - exch pop //true - } - ifelse - } { - //false - } ifelse - f closefile end end -} bind def - - -% Load a font file that might be a TrueType font. - -/tt_tag_dict << <00010000> 0 (true) 0 (typ1) 0 (ttcf) 0 >> readonly def -/ttf_otf_tag_dict << <00010000> 0 (true) 0 (typ1) 0 (ttcf) 0 (OTTO) 0>> readonly def -% The wOFF tag is immediately followed by the sfnt "flavour" so for simplicity -% combine them -/woff_tag_dict << - (wOFF) 0 - <774F464600010000> 0 % (wOFF)<00010000> .concatstrings - (wOFFtrue) 0 - (wOFFtyp1) 0 ->> readonly def - -% <file> .loadfontfile - -/.loadnonttfontfile /.loadfontfile load def -/.loadfontfile { - dup (12345678) .peekstring { //woff_tag_dict exch known } { //false } ifelse - { - .loadwofffont pop - } - { - dup (1234) .peekstring { //tt_tag_dict exch known } { //false } ifelse { - % If this is a font at all, it's a TrueType font. - .loadttfont pop - } { - % Not a TrueType font. - .loadnonttfontfile - } ifelse - } ifelse -} bind def - -% <file> .is_ttf_or_otf <bool> -/.is_ttf_or_otf { - dup 0 setfileposition (1234) .peekstring { //ttf_otf_tag_dict exch known } { //false } ifelse -} bind def - -/.is_woff { - dup 0 setfileposition (1234) .peekstring { //woff_tag_dict exch known } { //false } ifelse -} bind def - -currentdict /tt_tag_dict .undef -currentdict /ttf_otf_tag_dict .undef -currentdict /woff_tag_dict .undef - % ---------------- Automatic Type 42 generation ---------------- % % Load a TrueType font from a file as a Type 42 PostScript font. @@ -342,7 +220,7 @@ currentdict /woff_tag_dict .undef 16#ffffffff 0 gt { % 64-bit sign extension { /gets32 /gets32a} { mark 1 index load aload pop { 16#80000000 xor 16#80000000 sub } aload pop - .packtomark cvx def + //.packtomark exec cvx def } bind forall } if @@ -911,7 +789,7 @@ end readonly def % .loadttfontdict % Defines f, offsets, tables, tabdict, tabs, tthdrlen. % Skips loca and glyf if <bool> is true. /.loadttfonttables { - .loadttfontdict begin + //.loadttfontdict begin 40 dict begin /SubfontID exch def /load_stripped exch def @@ -954,7 +832,7 @@ end readonly def % .loadttfontdict % tabs = tables we want to keep, sorted by file position. /tabs [ 0 16 tables length 1 sub { tables exch 16 getinterval - TTFDEBUG { dup .printtab } if + TTFDEBUG { dup //.printtab exec } if dup 0 4 getinterval readtables_ 1 index known { % put all 0 length tables at 0 to avoid overlap 1 index 12 getu32 0 eq { 1 index 8 0 putu32 } if @@ -978,7 +856,7 @@ end readonly def % .loadttfontdict 2 index 12 3 -1 roll putu32 } if pop pop } for -} bind def +} bind executeonly def @@ -987,7 +865,7 @@ end readonly def % .loadttfontdict % Defines f, offsets, tables, tabdict, tabs, tthdrlen. % Skips loca and glyf if <bool> is true. /.loadwofftables { - .loadttfontdict begin + //.loadttfontdict begin 40 dict begin /SubfontID exch def /load_stripped exch def @@ -1011,7 +889,7 @@ end readonly def % .loadttfontdict /tabs [ 0 20 tables length 1 sub { tables exch 20 getinterval - TTFDEBUG { dup .printtab } if + TTFDEBUG { dup //.printtab exec } if dup 0 4 getinterval readtables_ 1 index known { % put all 0 length tables at 0 to avoid overlap @@ -1107,7 +985,7 @@ mark % Defines checksum, getloca, head, locatable, numloca, post, sfnts, upem % Note that the 'loca' table may be out of order. /.makesfnts { - .readttdata + //.readttdata exec /head tabdict /head get def /post tabdict /post .knownget { dup 0 get /post_first_part exch def @@ -1124,7 +1002,7 @@ mark locatable type /stringtype eq { /.indexloca {} def } { - /.indexloca /.findseg load def + /.indexloca //.findseg def } ifelse head 50 getu16 0 ne { /getloca { @@ -1148,7 +1026,7 @@ mark dup type /stringtype ne { aload pop } if } forall ] def -} bind def +} .bind executeonly odef /first_post_string % - first_post_string <string> { @@ -1209,7 +1087,7 @@ mark counttomark 0 ne { .dicttomark } { pop pop } ifelse /XUID [orgXUID 42 curxuid] TTFDEBUG { - tabs { .printtab } forall + tabs { //.printtab exec } forall [ sfnts { length } forall ] //== exec count ttkeycount sub array astore dup { //== exec } forall aload pop } if @@ -1322,7 +1200,9 @@ mark } { //.pickcmap_with_no_xlatmap exec } ifelse -} bind def +} .bind executeonly odef +currentdict /.pickcmap_with_xlatmap .undef +currentdict /.pickcmap_with_no_xlatmap .undef % <glyph> .nname <_name> /.nname { @@ -1369,7 +1249,7 @@ mark } for % /glyphencoding <newarray> <glyphencoding length> 1 numloca 1 sub { - 1 index exch dup .nname put + 1 index exch dup //.nname exec put } for def } if @@ -1394,7 +1274,7 @@ mark 3 index 1 index known { % The same name maps to more than one glyph. Change the name. % No special treatment for /.notdef glyph. Bug 689408. - pop .nname 3 index 2 index 2 index put + pop //.nname exec 3 index 2 index 2 index put 2 index exch 3 -1 roll put } { 3 index exch 3 -1 roll put % unique name @@ -1421,7 +1301,7 @@ mark TTFDEBUG { (\n1 setting alias: ) print dup ==only ( to be the same as ) print 2 index //== exec } if - 7 index 2 index 3 -1 roll exch //.growput systemdict /superexec known {//superexec}{1183615869 internaldict /superexec get exec} ifelse + 7 index 2 index 3 -1 roll exch .forceput } forall pop pop pop } @@ -1439,7 +1319,7 @@ mark exch pop TTFDEBUG { (\n2 setting alias: ) print 1 index ==only ( to use glyph index: ) print dup //== exec } if - 5 index 3 1 roll //.growput systemdict /superexec known {//superexec}{1183615869 internaldict /superexec get exec} ifelse + 5 index 3 1 roll .forceput //false } { @@ -1456,7 +1336,7 @@ mark { % CharStrings(dict) isunicode(boolean) cmap(dict) RAGL(dict) gname(name) codep(integer) gindex(integer) TTFDEBUG { (\3 nsetting alias: ) print 1 index ==only ( to be index: ) print dup //== exec } if - exch pop 5 index 3 1 roll //.growput systemdict /superexec known {//superexec}{1183615869 internaldict /superexec get exec} ifelse + exch pop 5 index 3 1 roll .forceput } { pop pop @@ -1486,56 +1366,7 @@ mark } ifelse ] TTFDEBUG { (Encoding: ) print dup === flush } if -} bind def - -% to be removed 9.09...... -currentdict /postalias undef -% .....to be removed 9.09 - -% <file> .loadttfont <type42font> -/.loadttfont { - TTFDEBUG { (.loadttfont) = } if - //false 0 .loadttfonttables - .makesfnts - .getpost - .pickcmap - mark - % if we're loading to substitute for TTF in a PDF, - % load the font the "PDF way" - /prebuilt_encoding where - {pop .pdfcharkeys} - {.charkeys} ifelse - .ttkeys - /FontType 42 - /PaintType 0 - TTFDEBUG { - (numloca=) print numloca = - } if - .dicttomark - end end dup /FontName get exch definefont -} bind def - -% <file> .loadwofffont <type42font> -/.loadwofffont -{ - TTFDEBUG { (.loadwofffont) = } if - //false 0 .loadwofftables - .makesfnts - .getpost - .pickcmap - mark - .charkeys - .ttkeys - /FontType 42 - /PaintType 0 - TTFDEBUG { - (numloca=) print numloca = - } if - .dicttomark - end end dup /FontName get exch - definefont -} bind def - +} .bind executeonly odef % hides .forceput % ---------------- CIDFontType 2 font loading ---------------- % @@ -1569,11 +1400,11 @@ currentdict /postalias undef def % processCIDToGIDMap may replace. /CIDMap numloca maxstring le { % Use a single string. - numloca 2 mul string 0 .fill_identity_cmap + numloca 2 mul string 0 //.fill_identity_cmap exec } { % We must use 2 strings. - maxstring 2 mul string 0 .fill_identity_cmap - numloca maxstring sub 2 mul string maxstring .fill_identity_cmap + maxstring 2 mul string 0 //.fill_identity_cmap exec + numloca maxstring sub 2 mul string maxstring //.fill_identity_cmap exec 2 array astore } ifelse def @@ -1591,15 +1422,15 @@ currentdict /postalias undef .makesfnts % CIDFontType2 fonts don't have a cmap: they are indexed by CID. mark - .ttkeys + //.ttkeys exec .dicttomark dup % convert keys to dict and copy dict 3 -1 roll % Bring PDF substitute name to top of stack dup /fontname exch def /FontName exch put % replace any definition of /FontName - .definettcidfont -} bind def + //.definettcidfont exec +} .bind executeonly odef % <file> <SubfontID> .load_tt_font_stripped <font_data> % The font_data includes sfnts, NumGlyphs, TT_cmap, file_table_pos, Decoding. @@ -1609,17 +1440,17 @@ currentdict /postalias undef .makesfnts .pickcmap mark - .ttkeys + //.ttkeys exec /NumGlyphs numloca /TT_cmap cmaptab cmapdict /file_table_pos file_table_pos /Decoding Decoding .dicttomark end end -} bind def +} .bind executeonly def /.load_woff_for_cid { - //false exch .loadwofftables + //false exch //.loadwofftables exec .makesfnts % we have to set load_stripped here so % .pickcmap will follow the right logic @@ -1628,14 +1459,14 @@ currentdict /postalias undef .pickcmap /load_stripped //false def mark - .ttkeys + //.ttkeys exec /NumGlyphs numloca /TT_cmap cmaptab cmapdict % /file_table_pos file_table_pos /Decoding Decoding .dicttomark end end -} bind def +} .bind executeonly def % ---------------- PDF TrueType font loading ---------------- % @@ -1836,13 +1667,13 @@ currentdict /postalias undef % Finally, if none of that works, remove the Encoding, and treat it % as non-symbolic. is_symbolic { - <00030000> .findcmap + <00030000> //.findcmap exec { //true } { prebuilt_encoding //null eq { - <00030001> .findcmap + <00030001> //.findcmap exec {//true} - {<00010000> .findcmap} + {<00010000> //.findcmap exec} ifelse } {//false} @@ -1850,7 +1681,7 @@ currentdict /postalias undef } ifelse { - .pdfmapsymbolic + //.pdfmapsymbolic exec /prebuilt_encoding //null def //false } { @@ -1862,7 +1693,7 @@ currentdict /postalias undef } ifelse { - <00030001> .findcmap { + <00030001> //.findcmap exec { prebuilt_encoding //null ne { TTFDEBUG { (Using cmap 3.1 with prebuilt_encoding for non-symbolic.) = } if //true /.render_notdef gput @@ -1888,29 +1719,29 @@ currentdict /postalias undef exch pop % <<pbe>> TTFDEBUG { dup (<<\n) print { exch ( ) print =only (\t) print //== exec } forall (>>\n) print flush } if exch AdobeGlyphList - .pdfmapchars + //.pdfmapchars exec /Encoding prebuilt_encoding } { % Likely this branch is now obsolete. TTFDEBUG { (Using cmap 3.1 for non-symbolic.) = } if 0 dict exch - AdobeGlyphList .pdfmapchars + AdobeGlyphList //.pdfmapchars exec /Encoding /WinAnsiEncoding .findencoding % WinAnsiEncoding is just a stub here. % It will be replaced with one from font resource, % because PDF spec requires it. } ifelse } { - <00010000> .findcmap { + <00010000> //.findcmap exec { TTFDEBUG { (Using cmap 1.0 for non-symbolic.) = } if - 0 dict exch - .romanmacdict .pdfmapchars - /Encoding prebuilt_encoding //null ne { + prebuilt_encoding .invert_encoding exch .romanmacdict //.pdfmapchars exec prebuilt_encoding } { + 0 dict exch /MacRomanEncodingForTrueType .findencoding } ifelse + /Encoding exch } { % Apply the default algorithm for using the 'post'. .charkeys @@ -1922,7 +1753,7 @@ currentdict /postalias undef } ifelse } if TTFDEBUG { (.pdfcharkeys end) = } if -} bind def +} bind executeonly def % <file> <is_symbolic> <Encoding|null> <FontName> .loadpdfttfont <type42font> /.loadpdfttfont { @@ -1968,8 +1799,8 @@ currentdict /postalias undef .getpost .pickcmap mark - .pdfcharkeys - .ttkeys + //.pdfcharkeys exec + //.ttkeys exec /FontType 42 /PaintType 0 /.render_notdef .render_notdef @@ -1980,4 +1811,213 @@ currentdict /postalias undef dup /FontName font_name put % replace any definition of /FontName end end .completefont +} .bind executeonly odef + +%--------- Define main type42font loading routines, after their dependencies ------------ +% <file> .loadttfont <type42font> +/.loadttfont { + TTFDEBUG { (.loadttfont) = } if + //false + % if this came from Fontmap, there may be a dictionary on the dict stack + % with a SubfontID in it. Validate it *is* a Fontmap record by also + % checking for a Path key + /SubfontID where + { + dup /Path known + {/SubfontID get} + {pop 0} ifelse + } + {0} ifelse + .loadttfonttables + .makesfnts + .getpost + .pickcmap + mark + % if we're loading to substitute for TTF in a PDF, + % load the font the "PDF way" + /prebuilt_encoding where + {pop //.pdfcharkeys exec} + {.charkeys} ifelse + //.ttkeys exec + /FontType 42 + /PaintType 0 + TTFDEBUG { + (numloca=) print numloca = + } if + .dicttomark + end end dup /FontName get exch definefont +} .bind executeonly def + +% <file> .loadwofffont <type42font> +/.loadwofffont +{ + TTFDEBUG { (.loadwofffont) = } if + //false 0 //.loadwofftables exec + .makesfnts + .getpost + .pickcmap + mark + .charkeys + //.ttkeys exec + /FontType 42 + /PaintType 0 + TTFDEBUG { + (numloca=) print numloca = + } if + .dicttomark + end end dup /FontName get exch + definefont +} .bind executeonly def + +% ----- Utilities for loading possible TrueType font ------ +% <file> .findttfontname <fname> true +% <file> .findttfontname false +% Closes the file in either case. +/.findttfontname { + //true 0 .loadttfonttables + tabdict /name .knownget { + dup 8 getu32 f exch setfileposition + 12 getu32 + dup 65535 gt { pop 65535 } if % protect against extremely large name + string f exch readstring pop + dup + 6 findname not { + 4 findname % Try FullName + } { + exch pop //true + } + ifelse + } { + //false + } ifelse + f closefile end end } bind def + +/.findwoffname { + //true 0 //.loadwofftables exec + tabdict /name .knownget { + dup /clen exch 8 getu32 def + dup /olen exch 12 getu32 def + 4 getu32 f exch setfileposition + olen dup 65535 gt { pop 65535 } if % protect against extremely large name + /fs + clen olen ne + {f clen () /SubFileDecode filter /FlateDecode filter} + {f clen () /SubFileDecode filter} + ifelse def + string fs exch readstring pop + fs closefile + dup + 6 findname not { + 4 findname % Try FullName + } { + exch pop //true + } + ifelse + } { + //false + } ifelse + f closefile end end +} bind def + +/tt_tag_dict << <00010000> 0 (true) 0 (typ1) 0 (ttcf) 0 >> readonly def +/ttf_otf_tag_dict << <00010000> 0 (true) 0 (typ1) 0 (ttcf) 0 (OTTO) 0>> readonly def +% The wOFF tag is immediately followed by the sfnt "flavour" so for simplicity +% combine them +/woff_tag_dict << + (wOFF) 0 + <774F464600010000> 0 % (wOFF)<00010000> .concatstrings + (wOFFtrue) 0 + (wOFFtyp1) 0 +>> readonly def + +% <file> .is_ttf_or_otf <bool> +/.is_ttf_or_otf { + dup 0 setfileposition (1234) .peekstring { //ttf_otf_tag_dict exch known } { //false } ifelse +} bind def + +/.is_woff { + dup 0 setfileposition (1234) .peekstring { //woff_tag_dict exch known } { //false } ifelse +} bind def + +% <file> <key> .findfontvalue <value> true +% <file> <key> .findfontvalue false +% Closes the file in either case. +/.findnonttfontvalue /.findfontvalue load def +/.findfontvalue { + 1 index //.is_woff exec { + dup /FontType eq { + pop closefile 42 //true + } { + dup /FontName eq { pop //.findwoffname exec} { pop closefile //false } ifelse + } ifelse + } + { + 1 index //.is_ttf_or_otf exec { + % If this is a font at all, it's a TrueType font. + dup /FontType eq { + pop closefile 42 //true + } { + dup /FontName eq { pop //.findttfontname exec} { pop closefile //false } ifelse + } ifelse + } { + % Not a TrueType font. + .findnonttfontvalue + } ifelse + } ifelse +} bind executeonly def + +% Load a font file that might be a TrueType font. +% <file> .loadfontfile - +/.loadnonttfontfile /.loadfontfile load def +/.loadfontfile { + dup (12345678) .peekstring { //woff_tag_dict exch known } { //false } ifelse + { + //.loadwofffont exec pop + } + { + dup (1234) .peekstring { //tt_tag_dict exch known } { //false } ifelse { + % If this is a font at all, it's a TrueType font. + //.loadttfont exec pop + } { + % Not a TrueType font. + .loadnonttfontfile + } ifelse + } ifelse +} bind def + +% Undef the local utility funcs +[ + /.findttfontname + /.findwoffname + /ttf_otf_tag_dict + /tt_tag_dict + /woff_tag_dict + /.is_ttf_or_otf + /.is_woff +] +{currentdict exch .undef} forall +% ----- END .loadfontfile that supports possible TrueType font ------ + +% Undef these, not needed outside this file +[ + /.addglyph + /.definettcidfont + /.fill_identity_cmap + /.findseg + /.loadttfontdict + /.is_hex_digit + /.pop3ex + /.popfex + /.ttkeys + /.printtab + /.readttdata + /.nname + /.loadttfont + /.loadwofffont + /.loadwofftables + /.findcmap + /.pdfmapsymbolic + /.pdfcharkeys + /.pdfmapchars +] {systemdict exch .forceundef} forall diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_typ32.ps b/Master/tlpkg/tlgs/Resource/Init/gs_typ32.ps index 9150f71873a..9799a0bec3e 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_typ32.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_typ32.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 diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_typ42.ps b/Master/tlpkg/tlgs/Resource/Init/gs_typ42.ps index 0374a3c3372..ba5074ce1a5 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_typ42.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_typ42.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 @@ -20,12 +20,6 @@ % interpreter. The real work is done in an operator: % <font> <code|name> <name> <glyphindex> .type42execchar - -(%Type42BuildChar) cvn % <font> <code> %Type42BuildChar - - { 1 index /Encoding get 1 index get .type42build - } bind def -(%Type42BuildGlyph) cvn % <font> <name> %Type42BuildGlyph - - { dup .type42build - } bind def /.type42build % <font> <code|name> <name> .type42build - { 2 index begin dup CharStrings exch .knownget not @@ -41,6 +35,14 @@ } if end .type42execchar } bind def +(%Type42BuildChar) cvn % <font> <code> %Type42BuildChar - + { 1 index /Encoding get 1 index get //.type42build exec + } bind executeonly def +(%Type42BuildGlyph) cvn % <font> <name> %Type42BuildGlyph - + { dup //.type42build exec + } bind executeonly def + +currentdict /.type42build .undef % Register the font type for definefont. buildfontdict 42 diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_type1.ps b/Master/tlpkg/tlgs/Resource/Init/gs_type1.ps index 96e1ced240c..6c7735bc0cc 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_type1.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_type1.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 @@ -38,7 +38,7 @@ dup .fontbbox { pop pop pop pop dup /FontInfo known not - { .growfontdict dup /FontInfo 2 dict put } + { //.growfontdict exec dup /FontInfo 2 dict put } if dup dup /FontInfo get dup dup /UnderlinePosition known exch /UnderlineThickness known and @@ -90,7 +90,7 @@ { % as luck would have it, we can just replace the "uni" with "16#" % to get something we can convert to a number - pop pop dup 0 (16#) putinterval {cvi} .internalstopped + pop pop dup 0 (16#) putinterval {cvi} //.internalstopped exec { pop //false} { % scratch(string) RAGL(dict) AGL(dict) CharStrings(dict) cstring gname cpoint dup 5 index exch known @@ -116,7 +116,7 @@ { % scratch(string) RAGL(dict) AGL(dict) CharStrings(dict) cstring gname aglname CFFDEBUG { (\nsetting alias: ) print dup ==only ( to be the same as glyph: ) print 1 index //== exec } if - 3 index exch 3 index //.growput systemdict /superexec known {//superexec}{1183615869 internaldict /superexec get exec} ifelse + 3 index exch 3 index .forceput % scratch(string) RAGL(dict) AGL(dict) CharStrings(dict) cstring gname } {pop} ifelse @@ -135,7 +135,7 @@ 3 1 roll pop pop } if pop - dup /.AGLprocessed~GS //true //.growput systemdict /superexec known {//superexec}{1183615869 internaldict /superexec get exec} ifelse + dup /.AGLprocessed~GS //true .forceput } if %% We need to excute the C .buildfont1 in a stopped context so that, if there @@ -148,34 +148,8 @@ {//.buildfont1} stopped 4 3 roll .setglobal {//.buildfont1 $error /errorname get signalerror} if - } bind def - -% If the diskfont feature isn't included, define a dummy .loadfontdict. -/.loadfontdict where - { pop } - { /.loadfontdict 0 dict readonly def } -ifelse -/.loadfontfile % <file> .loadfontfile - - { mark exch + } .bind executeonly def % hide .forceput - % In order to load fonts reliably, we should push systemdict - % here. However, Ed Taft says that Adobe implementations - % push userdict and nothing else! - % We really would just like systemdict on the stack, - % but fonts produced by Fontographer require a writable dictionary. - % However, we can't use any of the other well-known dictionaries - % (such as userdict), since the whole point of pushing systemdict - % is to make sure that nothing important has been redefined. - 32 dict begin - % We can't just use `run', because we want to check for .PFB files. - currentpacking - { //false setpacking .loadfont1 //true setpacking } - { .loadfont1 } - ifelse - end - { stop } if - cleartomark - } bind def % container for CloseSource flag (default //true to prevent buildup of file handles) /closesourcedict mark /CloseSource //true @@ -190,7 +164,7 @@ ifelse % Since the file might leave garbage on the operand stack, % we have to create a procedure to close the file reliably. dup read not { -1 } if - 2 copy unread 16#80 eq { + 2 copy .unread 16#80 eq { dup //closesourcedict //true /PFBDecode filter cvx exch .currentresourcefile eq { dup /.execasresource .systemvar @@ -203,21 +177,38 @@ ifelse cvx exec } ifelse } stopped -} bind def -% undefine a dict that is only used internally, and is immediately bound -currentdict /closesourcedict .undef +} bind executeonly def -% Here are the BuildChar and BuildGlyph implementation for Type 1 fonts. -% The names %Type1BuildChar and %Type1BuildGlyph are known to the interpreter. -% The real work is done in an operator: -% <font> <code|name> <name> <charstring> .type1execchar - +% If the diskfont feature isn't included, define a dummy .loadfontdict. +/.loadfontdict where + { pop } + { /.loadfontdict 0 dict readonly def } +ifelse +/.loadfontfile % <file> .loadfontfile - + { mark exch + + % In order to load fonts reliably, we should push systemdict + % here. However, Ed Taft says that Adobe implementations + % push userdict and nothing else! + % We really would just like systemdict on the stack, + % but fonts produced by Fontographer require a writable dictionary. + % However, we can't use any of the other well-known dictionaries + % (such as userdict), since the whole point of pushing systemdict + % is to make sure that nothing important has been redefined. + 32 dict begin + % We can't just use `run', because we want to check for .PFB files. + currentpacking + { //false setpacking //.loadfont1 exec //true setpacking } + { //.loadfont1 exec } + ifelse + end + { stop } if + cleartomark + } bind def +% undefine stuff that is only used internally, and is immediately bound +currentdict /closesourcedict .undef +currentdict /.loadfont1 .undef -(%Type1BuildChar) cvn { % <font> <code> %Type1BuildChar - - 1 index /Encoding get 1 index get .type1build .type1execchar -} bind def -(%Type1BuildGlyph) cvn { % <font> <name> %Type1BuildGlyph - - dup .type1build .type1execchar -} bind def % Note: this procedure is used for both Type 1 and Type 2 fonts. /.type1build { % <font> <code|name> <name> .type1build % <font> <code|name> <name> <charstring> @@ -236,6 +227,18 @@ currentdict /closesourcedict .undef end } bind def +% Here are the BuildChar and BuildGlyph implementation for Type 1 fonts. +% The names %Type1BuildChar and %Type1BuildGlyph are known to the interpreter. +% The real work is done in an operator: +% <font> <code|name> <name> <charstring> .type1execchar - + +(%Type1BuildChar) cvn { % <font> <code> %Type1BuildChar - + 1 index /Encoding get 1 index get //.type1build exec .type1execchar +} bind executeonly def +(%Type1BuildGlyph) cvn { % <font> <name> %Type1BuildGlyph - + dup //.type1build exec .type1execchar +} bind executeonly def + 1183615869 internaldict begin % CCRun is an undocumented procedure provided for Type 4 and Type 0 fonts. % Apparently there are two different argument lists for CCRun. @@ -294,10 +297,10 @@ buildfontdict 4 /.buildfont4 cvx put /.buildfont2 where not { (%END2) .skipeof } if pop (%Type2BuildChar) cvn { % <font> <code> %Type2BuildChar - - 1 index /Encoding get 1 index get .type1build .type2execchar -} bind def + 1 index /Encoding get 1 index get //.type1build exec .type2execchar +} bind executeonly def (%Type2BuildGlyph) cvn { % <font> <name> %Type2BuildGlyph - - dup .type1build .type2execchar -} bind def + dup //.type1build exec .type2execchar +} bind executeonly def buildfontdict 2 /.buildfont2 cvx put %END2 diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_wan_e.ps b/Master/tlpkg/tlgs/Resource/Init/gs_wan_e.ps index 226cb47959e..406c7fae370 100644 --- a/Master/tlpkg/tlgs/Resource/Init/gs_wan_e.ps +++ b/Master/tlpkg/tlgs/Resource/Init/gs_wan_e.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 diff --git a/Master/tlpkg/tlgs/Resource/Init/pdf_base.ps b/Master/tlpkg/tlgs/Resource/Init/pdf_base.ps index b45e9803165..1a218f42fbf 100644 --- a/Master/tlpkg/tlgs/Resource/Init/pdf_base.ps +++ b/Master/tlpkg/tlgs/Resource/Init/pdf_base.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 @@ -23,7 +23,6 @@ /.setlanguagelevel where { pop 2 .setlanguagelevel } if .currentglobal //true .setglobal -/pdfdict where { pop } { /pdfdict 100 dict def } ifelse pdfdict begin % Define the name interpretation dictionary for reading values. @@ -85,7 +84,10 @@ pdfdict begin % dictionary. The name procedures may do whatever they want % to the operand stack. /.pdftokenerror { % <count> <opdict> <errtoken> .pdftokenerror - - BXlevel 0 le { + % if we're called prior to actually drawing the page contents + % (i.e. for pageusestransparency) BXlevel may not be defined, yet. + /BXlevel where {/BXlevel get 0 le}{//true} ifelse + { ( **** Error: Unknown operator: ') pdfformaterror dup =string cvs pdfformaterror (') pdfformaterror @@ -130,26 +132,29 @@ currentdict /num-chars-dict .undef /.pdfexectoken { % <count> <opdict> <exectoken> .pdfexectoken ? PDFDEBUG { - pdfdict /PDFSTEPcount known not { pdfdict /PDFSTEPcount 1 .forceput } if + //pdfdict /PDFSTEPcount known not { //pdfdict /PDFSTEPcount 1 .forceput } executeonly if PDFSTEP { - pdfdict /PDFtokencount 2 copy .knownget { 1 add } { 1 } ifelse .forceput + //pdfdict /PDFtokencount 2 copy .knownget { 1 add } { 1 } ifelse .forceput PDFSTEPcount 1 gt { - pdfdict /PDFSTEPcount PDFSTEPcount 1 sub .forceput - } { + //pdfdict /PDFSTEPcount PDFSTEPcount 1 sub .forceput + } executeonly + { dup ==only ( step # ) print PDFtokencount =only ( ? ) print flush 1 //false .outputpage (%stdin) (r) file 255 string readline { token { - exch pop pdfdict /PDFSTEPcount 3 -1 roll .forceput - } { - pdfdict /PDFSTEPcount 1 .forceput - } ifelse % token + exch pop //pdfdict /PDFSTEPcount 3 -1 roll .forceput + } executeonly + { + //pdfdict /PDFSTEPcount 1 .forceput + } executeonly ifelse % token } { pop /PDFSTEP //false def % EOF on stdin } ifelse % readline } ifelse % PDFSTEPcount > 1 - } { + } executeonly + { dup ==only () = flush } ifelse % PDFSTEP } if % PDFDEBUG @@ -178,17 +183,17 @@ currentdict /num-chars-dict .undef %% we look for 0-9 as well as '.' ',' and '-' to permit those %% locales in which the separator is a comma, as well as negative %% numbers. We've seena t least one tool replace '0' with '-' *sometimes* - true exch + //true exch dup length 1 sub 0 1 3 -1 roll { 1 index exch get dup 44 lt { - pop exch pop false exch exit + pop exch pop //false exch exit }{ dup 57 gt { - pop exch pop false exch exit + pop exch pop //false exch exit }{ dup 47 eq { - pop exch pop false exch exit + pop exch pop //false exch exit }{ pop } ifelse @@ -237,7 +242,7 @@ currentdict /num-chars-dict .undef { token } stopped { dup type /filetype eq { pop } if pop pop stop - } if { + } if { dup type /nametype eq { dup xcheck { .pdfexectoken @@ -260,7 +265,7 @@ currentdict /num-chars-dict .undef pop pop exit } ifelse } - aload pop .packtomark cvx % file [ {cnt <<>> file ... } + aload pop //.packtomark exec cvx % file [ {cnt <<>> file ... } { loop } 0 get 2 packedarray cvx % file [ { {cnt <<>> file ... } loop } PDFSTOPONERROR { {exec //false} } { {stopped} } ifelse aload pop % file [ { {cnt <<>> file ... } loop } stopped @@ -275,8 +280,8 @@ currentdict /num-chars-dict .undef ( Output may be incorrect.\n) pdfformaterror } if } aload pop % file [ { {cnt <<>> file ... } loop } stopped /PDFsource PDFsource store {...} if - .packtomark cvx % file { { {cnt <<>> file ... } loop } stopped /PDFsource PDFsource store {...} if} - /PDFsource 3 -1 roll store % {...} + //.packtomark exec cvx % file { { {cnt <<>> file ... } loop } stopped /PDFsource PDFsource store {...} if} + /PDFsource 3 -1 roll store % {...} exec } bind executeonly def @@ -284,7 +289,9 @@ currentdict /num-chars-dict .undef % This temporarily rebinds LocalResources and DefaultQstate. /.pdfruncontext { % <resdict> <file> <opdict> .pdfruncontext - /.pdfrun load LocalResources DefaultQstate - /LocalResources 7 -1 roll store + /LocalResources 7 -1 roll + dup /ParentResources LocalResources put % save the parent LocalResources + store % store new LocalResources /DefaultQstate qstate store 3 .execn /DefaultQstate exch store @@ -320,7 +327,7 @@ currentdict /num-chars-dict .undef dup type /filetype eq { { dup ( ) .peekstring not { ({) } if //token_nofail_dict exch .knownget not { - //null 1 index { token } .internalstopped exit + //null 1 index { token } //.internalstopped exec exit } if exec } loop @@ -333,7 +340,7 @@ currentdict /num-chars-dict .undef } ifelse } { //null 1 index % stack: source null source - { token } .internalstopped { % stack: source null [source] + { token } //.internalstopped exec { % stack: source null [source] //null ne { pop } if pop //false } { % stack: source null ([post] token true | false) { 4 2 roll pop pop //true } @@ -841,7 +848,7 @@ currentdict /no_debug_dict undef } if 1 index dup 0 le exch NumObjects ge or { ( **** Error: Considering object with an invalid number ) - 2 index 20 string cvs concatstrings + 2 index 20 string cvs concatstrings ( as null.\n) concatstrings pdfformaterror ( Output may be incorrect.\n) pdfformaterror pop pop //null @@ -1172,11 +1179,11 @@ currentdict /pdf_rules_dict undef % Stack: readdata? dict /DecodeParms /Filter filterparms % Stack: readdata? dict parms filternames - 2 index /File .knownget not { + 2 index /File .knownget not { ( **** Error: Stream object is missing the stream data.\n) ( Output may be incorrect.\n) pdfformaterror pdfformaterror - () + () } if exch % Stack: readdata? dict parms file/string filternames dup length 0 eq { @@ -1248,7 +1255,7 @@ currentdict /pdf_rules_dict undef /.leafget { % <key> <pairs> .leafget <obj|null> dup length 2 eq { - dup 0 get 2 index eq { 1 oget } { pop null } ifelse + dup 0 get 2 index eq { 1 oget } { pop //null } ifelse exch pop } { dup length -1 bitshift -2 and 2 copy oget @@ -1275,7 +1282,7 @@ currentdict /pdf_rules_dict undef /.branchgetle { % <key> <leafkey> <kids> .branchgetle <key obj true|false> dup length 0 eq { - pop pop pop false + pop pop pop //false } { dup length -1 bitshift 2 copy oget dup /Limits oget aload pop @@ -1299,7 +1306,7 @@ currentdict /pdf_rules_dict undef /.leafgetle { % <key> <pairs> .leafget <obj|null> dup length 2 eq { dup 0 get - 2 index le { exch pop aload pop true } { pop pop false } ifelse + 2 index le { exch pop aload pop //true } { pop pop //false } ifelse } { dup length -1 bitshift -2 and 2 copy oget % Stack: key pairs mid pairs[mid] diff --git a/Master/tlpkg/tlgs/Resource/Init/pdf_draw.ps b/Master/tlpkg/tlgs/Resource/Init/pdf_draw.ps index 6b0ba93e1e7..e18a7c27f31 100644 --- a/Master/tlpkg/tlgs/Resource/Init/pdf_draw.ps +++ b/Master/tlpkg/tlgs/Resource/Init/pdf_draw.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,8 +18,7 @@ /.setlanguagelevel where { pop 2 .setlanguagelevel } if .currentglobal //true .setglobal -/pdfdict where { pop } { /pdfdict 100 dict def } ifelse -GS_PDF_ProcSet begin +/GS_PDF_ProcSet load begin pdfdict begin % For simplicity, we use a single interpretation dictionary for all @@ -113,7 +112,7 @@ pdfdict begin /resolvefunction { % <fndict> resolvefunction <function> .resolvefn - PDFDEBUG { pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%Function: ) print dup === flush } if } if + PDFDEBUG { //pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%Function: ) print dup === flush } if } if } bind executeonly def /resolvefnproc { % <fndict> resolvefnproc <proc> @@ -427,7 +426,7 @@ end } ifelse } bind executeonly def /sethalftonephases { - /sethalftonephase where { pop aload pop sethalftonephase } { pop } ifelse + aload pop -1 2 index 2 index .setscreenphase pop pop } bind executeonly def /HT { @@ -495,7 +494,16 @@ end dup { oforce exch gsparamdict exch .knownget { exec } { pop } ifelse } forall pop - } if + } { + //pdfdict /.gs_warning_issued known not { + (\n **** Error 'gs' ignored -- ExtGState missing from Resources.\n) + pdfformaterror + ( Output may be incorrect.\n) pdfformaterror + //pdfdict /.gs_warning_issued //true .forceput + PDFSTOPONERROR { /gs /undefined signalerror } if + } if + } + ifelse } bind executeonly def % ------ Transparency support ------ % @@ -520,7 +528,7 @@ end .currentSMask //null ne { % get rid of the current SMask (Bug 695471) - false % colorspace not set + //false % colorspace not set << /Subtype /None >> % Special type for this purpose 0 0 0 0 % fake BBox .begintransparencymaskgroup @@ -609,8 +617,9 @@ def matrix currentmatrix 4 1 roll mark currentcolor counttomark dup 4 add exch roll pop currentcolorspace 4 1 roll .getuseciecolor 4 1 roll + .swapcolors mark currentcolor counttomark dup 4 add exch roll pop currentcolorspace 4 1 roll .swapcolors currentuserparams /OverrideICC get 4 1 roll - mark /OverrideICC true .dicttomark setuserparams + mark /OverrideICC //true .dicttomark setuserparams % We can't simply set the group's gstate here because % we can't use gsave/grestore. So we actually set it @@ -660,6 +669,7 @@ def .endtransparencymask PDFfile exch setfileposition mark exch /OverrideICC exch .dicttomark setuserparams + .swapcolors setcolorspace setcolor .swapcolors .setuseciecolor setcolorspace setcolor setmatrix end % restore colorspace, color and ExtGState (end) @@ -712,6 +722,19 @@ def .begintransparencygroup } bind executeonly def +/.beginpagegroup { % groupdict bbox .beginformgroup - + currentcolorspace 3 1 roll + exch mark exch % bbox mark groupdict + dup /CS knownoget { resolvecolorspace dup setgcolorspace /CS exch 3 2 roll} if + dup /I knownoget { /Isolated exch 3 2 roll } if + dup /K knownoget { /Knockout exch 3 2 roll } if + pop .dicttomark + % Stack: bbox paramdict + exch aload pop + .begintransparencypagegroup + setcolorspace +} bind executeonly def + % .paintgroupform implements the Form PaintProc in the case where the % Form XObject dictionary includes a Group key. See .paintform below. /.paintgroupform { % <resdict> <stream> <formdict> .paintgroupform - @@ -797,7 +820,7 @@ currentdict /csncompdict undef mark exch { oforce } forall .dicttomark dup dup //true resolvestream /ReusableStreamDecode filter /DataSource exch put - + dup /.hash 0 put % placeholder for use by seticc icc_profile_cache key % Check that the number of components (/N) defined in the ICCBased % dictionry matches the actual profile. Bug #696120 dup /N get @@ -1073,7 +1096,7 @@ currentdict end readonly def %% finished running the PaintProc. /.actual_pdfpaintproc { % <patdict> <resdict> .pdfpaintproc - - PDFDEBUG { pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%Begin PaintProc) print dup === flush } if } if + PDFDEBUG { //pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%Begin PaintProc) print dup === flush } if } if PDFfile fileposition 3 1 roll q 1 index /PaintType oget 1 eq { @@ -1108,47 +1131,47 @@ currentdict end readonly def Q }{ (\n **** Error: File has unbalanced q/Q operators \(too many Q's\)\n Output may be incorrect.\n) - pdfdict /.Qqwarning_issued .knownget + //pdfdict /.Qqwarning_issued .knownget { { pop } { - currentglobal pdfdict gcheck .setglobal - pdfdict /.Qqwarning_issued //true .forceput + currentglobal //pdfdict gcheck .setglobal + //pdfdict /.Qqwarning_issued //true .forceput .setglobal pdfformaterror - } ifelse + } executeonly ifelse } { - currentglobal pdfdict gcheck .setglobal - pdfdict /.Qqwarning_issued //true .forceput + currentglobal //pdfdict gcheck .setglobal + //pdfdict /.Qqwarning_issued //true .forceput .setglobal pdfformaterror - } ifelse + } executeonly ifelse end } ifelse } loop { (\n **** Error: File has unbalanced q/Q operators \(too many q's\)\n Output may be incorrect.\n) - pdfdict /.Qqwarning_issued .knownget + //pdfdict /.Qqwarning_issued .knownget { { pop } { - currentglobal pdfdict gcheck .setglobal - pdfdict /.Qqwarning_issued //true .forceput + currentglobal //pdfdict gcheck .setglobal + //pdfdict /.Qqwarning_issued //true .forceput .setglobal pdfformaterror - } ifelse + } executeonly ifelse } { - currentglobal pdfdict gcheck .setglobal - pdfdict /.Qqwarning_issued //true .forceput + currentglobal //pdfdict gcheck .setglobal + //pdfdict /.Qqwarning_issued //true .forceput .setglobal pdfformaterror - } ifelse + } executeonly ifelse } if pop @@ -1156,7 +1179,7 @@ currentdict end readonly def /pdfemptycount exch def Q - PDFDEBUG { pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%End PaintProc) print dup === flush } if } if + PDFDEBUG { //pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%End PaintProc) print dup === flush } if } if PDFfile exch setfileposition } bind executeonly odef @@ -1172,13 +1195,13 @@ currentdict end readonly def %% If the name is inside_text_m then we are in a text block /inside_text_m eq }{ - pop false + pop //false } ifelse }{ - pop false + pop //false } ifelse }{ - pop false + pop //false } ifelse %% rearrange the operands, move the boolean to the back 3 1 roll @@ -1227,7 +1250,7 @@ currentdict end readonly def ] cvx put dup /BBox 2 copy knownoget { normrect FixPatternBBox put } { pop pop } ifelse dup /.pattern_uses_transparency 1 index patternusestransparency put - PDFDEBUG { pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%Pattern: ) print dup === flush } if } if + PDFDEBUG { //pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%Pattern: ) print dup === flush } if } if } bind executeonly def /ignore_color_op ( **** Error: Ignoring a color operation in a cached context.\n Output may be incorrect.\n) readonly def @@ -1495,9 +1518,9 @@ end 17 { /sGrayICC /ColorSpace findresource } bind executeonly 18 3 index % YCC is converted to RGB % 19 % CIEJab not supportec by PDF 1.7 -% 20 % e-sRGB -% 21 % ROMMRGB -% 24 % e-sYCC + 20 { /esRGBICC /ColorSpace findresource } bind executeonly % e-sRGB + 21 { /rommRGBICC /ColorSpace findresource} bind executeonly % ROMMRGB + 24 { /esRGBICC /ColorSpace findresource } bind executeonly % e-sYCC .dicttomark readonly def % Process jp2 blocks (aka boxes). All procedures have the signature @@ -1748,7 +1771,7 @@ currentdict /jp2_csp_dict .undef } if } ifelse }ifelse - /ICCProfileNError true def + /ICCProfileNError //true def }{cleartomark}ifelse } if } if @@ -1973,7 +1996,7 @@ currentdict /jp2_csp_dict .undef 2 copy % <<stream dict>> [] loopcount [] loopcount [] exch get % <<stream dict>> [] loopcount [] <<>> or -null- - dup null eq { + dup //null eq { pop exch % <<stream dict>> [] [] loopcount <</Height 5 index /Height oget % <<stream dict>> [] [] loopcount << /Height Height @@ -2208,16 +2231,24 @@ currentdict /last-ditch-bpc-csp undef PDFfile exch setfileposition 0 .endtransparencymask } ifelse - << /Subtype /Group /Isolated //true - /.image_with_SMask //true % pdfwrite needs : see gs/src/ztrans.c, gs/src/gdevpdft.c - >> 0 0 1 1 .begintransparencygroup - doimage + << /Subtype /Group /Isolated //true + /.image_with_SMask //true + % pdfwrite needs : see gs/src/ztrans.c, gs/src/gdevpdft.c + % Code to deal with a Matte in the SMask. We know the image dictionary must have an SMask + % entry if we get here, so we don't need to check its existence. Just pull it out and see if + % the SMask has a Matte entry. If it does, get the ColorSpace from the parent image and + % put a /CS key with that colour space in the Group that we manufacture. Bug #700686 + % We also need to actually set the current colour space to be the same as the group + % code only picks up the current colour space, not the space from the dictionary. + currentdict /SMask get /Matte known {/CS currentdict /ColorSpace get dup pdfopdict /cs get exec } if + >> 0 0 1 1 .begintransparencygroup + doimage .endtransparencygroup % tell the compositor we're done with the SMask. % Note that any SMask in the ExtGState should be reapplied % by the next call to setfill(stroke)state AND this relies % on our lazy evaulation of SMask groups - false << /Subtype /None >> 0 0 0 0 .begintransparencymaskgroup + //false << /Subtype /None >> 0 0 0 0 .begintransparencymaskgroup } { .currentSMask //null ne { % the image doesn't have an SMask, but the ExtGState does, force a group. @@ -2308,8 +2339,8 @@ currentdict /last-ditch-bpc-csp undef makemaskimage } if % Stack: datasource imagemask - { currentdict end setfillstate true ValidateDecode { imagemask } } - { ColorSpace setgcolorspace currentdict end setfillblend false ValidateDecode { image } } + { currentdict end setfillstate //true ValidateDecode { imagemask } } + { ColorSpace setgcolorspace currentdict end setfillblend //false ValidateDecode { image } } ifelse PDFSTOPONERROR { exec //false } { stopped } ifelse { dup type /dicttype eq { pop } if % Sometimes image fails to restore the stack @@ -2348,15 +2379,16 @@ currentdict /last-ditch-bpc-csp undef } bind executeonly def /IncrementAppearanceNumber { - pdfdict /AppearanceNumber .knownget { - 1 add pdfdict /AppearanceNumber 3 -1 roll .forceput - }{ - pdfdict /AppearanceNumber 0 .forceput - } ifelse + //pdfdict /AppearanceNumber .knownget { + 1 add //pdfdict /AppearanceNumber 3 -1 roll .forceput + } executeonly + { + //pdfdict /AppearanceNumber 0 .forceput + } executeonly ifelse }bind executeonly odef /MakeAppearanceName { - pdfdict /AppearanceNumber get + //pdfdict /AppearanceNumber get 10 string cvs dup length 10 add string dup 0 (\{FormName) putinterval dup 3 -1 roll @@ -2377,17 +2409,45 @@ currentdict /last-ditch-bpc-csp undef gsave initclip MakeNewAppearanceName .pdfFormName - pdfdict /.PreservePDFForm known {pdfdict /.PreservePDFForm get} {//false}ifelse exch - pdfdict /.PreservePDFForm true .forceput + //pdfdict /.PreservePDFForm known {//pdfdict /.PreservePDFForm get} {//false}ifelse exch + //pdfdict /.PreservePDFForm //true .forceput DoForm - pdfdict /.PreservePDFForm 3 -1 roll .forceput + //pdfdict /.PreservePDFForm 3 -1 roll .forceput grestore } bind executeonly odef +%% We don't want to do any high level forms stuff if the source +%% is PDF because : +%% 1) Transparent forms are handled separately and we don't want to ge confused +%% 2) PDF forms are too llikely to trip over the limitations in our support +%% 3) Its highly unusual to find a PDF file which uses forms sensibly. +%% +%% So we have a special PDF version of execform which doesn't do high level forms. + +pdfdict +/.PDFexecform { + % This is a separate operator so that the stacks will be restored + % properly if an error occurs. + dup /Matrix get concat + dup /BBox get aload pop + exch 3 index sub exch 2 index sub rectclip + dup /PaintProc get + 1 index /Implementation known not { + 1 index dup /Implementation //null .forceput readonly pop + } executeonly if + exec +} .bind executeonly put + +pdfdict +/PDFexecform { + gsave { //.PDFexecform exec } stopped + grestore {stop} if +} .bind executeonly put + /DoForm { %% save the current value, if its true we will set it to false later, in order %% to prevent us preserving Forms which are used *from* an annotation /Appearance. - pdfdict /.PreservePDFForm known {pdfdict /.PreservePDFForm get} {//false}ifelse exch + //pdfdict /.PreservePDFForm known {//pdfdict /.PreservePDFForm get} {//false}ifelse exch %% We may alter the Default* colour spaces, if the Resources %% ColorSpace entry contains one of them. But we don't want that @@ -2502,15 +2562,16 @@ currentdict /last-ditch-bpc-csp undef pdfemptycount countdictstack 3 -1 roll /pdfemptycount count 4 sub store - pdfdict /.PreservePDFForm known {pdfdict /.PreservePDFForm get}{//false} ifelse + //pdfdict /.PreservePDFForm known {//pdfdict /.PreservePDFForm get}{//false} ifelse { %% We must *not* preserve any subsidiary forms (curently at least) as PDF %% form preservation doesn't really work. This is used just for Annotation %% Appearances currently, and if they should happen to use a form, we do not %% want to preserve it. - pdfdict /.PreservePDFForm false .forceput + //pdfdict /.PreservePDFForm //false .forceput /q cvx /execform cvx 5 -2 roll - }{ + } executeonly + { /q cvx /PDFexecform cvx 5 -2 roll } ifelse @@ -2540,7 +2601,7 @@ currentdict /last-ditch-bpc-csp undef saved_DCMYK /DefaultCMYK exch /ColorSpace defineresource pop end } if - pdfdict /.PreservePDFForm 3 -1 roll .forceput + //pdfdict /.PreservePDFForm 3 -1 roll .forceput } bind executeonly odef /_dops_save 1 array def @@ -2699,13 +2760,13 @@ drawopdict begin % Start by getting the object number for a Form XObject dup Page /XObject obj_get dup 0 eq not { % Now get the recording dictionary and see if that object number has been seen - pdfdict /Recursive_XObject_D get 1 index known { + //pdfdict /Recursive_XObject_D get 1 index known { ( **** Error: Recursive XObject detected, ignoring ") print 1 index 256 string cvs print (", object number ) print 256 string cvs print (\n) print ( Output may be incorrect.\n) pdfformaterror //false }{ % We haven't seen it yet, so record it. - pdfdict /Recursive_XObject_D get 1 index null put + //pdfdict /Recursive_XObject_D get 1 index //null put 3 1 roll //true }ifelse @@ -2743,7 +2804,7 @@ drawopdict begin ( Output may be incorrect.\n) pdfformaterror } ifelse PDFfile exch setfileposition - pdfdict /Recursive_XObject_D get exch undef + //pdfdict /Recursive_XObject_D get exch undef }{ % Otherwise ignore it and tidy up the stacks pop pop @@ -2938,27 +2999,27 @@ end /annotsetcolor { % <annot> annotsetcolor bool /C knownoget { dup length 4 eq { - aload pop setcmykcolor true + aload pop setcmykcolor //true }{ dup length 3 eq { - aload pop setrgbcolor true + aload pop setrgbcolor //true }{ dup length 1 eq { - aload pop setgray true + aload pop setgray //true } { dup length 0 eq { pop - false + //false }{ ( **** Error: invalid color specified for annotation /C entry) - pdfformaterror false + pdfformaterror //false ( Output may be incorrect.\n) pdfformaterror } ifelse } ifelse } ifelse } ifelse } - { 0 setgray true} ifelse + { 0 setgray //true} ifelse } bind executeonly def % Set an annotation color. @@ -2967,27 +3028,27 @@ end /annotsetinteriorcolor { % <annot> annotsetcolor bool /IC knownoget { dup length 4 eq { - aload pop setcmykcolor true + aload pop setcmykcolor //true }{ dup length 3 eq { - aload pop setrgbcolor true + aload pop setrgbcolor //true }{ dup length 1 eq { - aload pop setgray true + aload pop setgray //true } { dup length 0 eq { pop - false + //false }{ ( **** Error: invalid color specified for annotation /C entry) - pdfformaterror false + pdfformaterror //false ( Output may be incorrect.\n) pdfformaterror } ifelse } ifelse } ifelse } ifelse } - { 0 setgray true} ifelse + { 0 setgray //true} ifelse } bind executeonly def % Draw the border. Currently, we ignore requests for beveling, and we @@ -4244,28 +4305,28 @@ currentdict /set_bc_color undef dup /C knownoget { dup length 4 eq { - aload pop setcmykcolor true + aload pop setcmykcolor //true }{ dup length 3 eq { - aload pop setrgbcolor true + aload pop setrgbcolor //true }{ dup length 1 eq { - aload pop setgray true + aload pop setgray //true } { dup length 0 eq { pop - false + //false }{ ( **** Error: invalid color specified for FreeText annotation /C entry) pdfformaterror ( Output may be incorrect.\n) pdfformaterror - false + //false } ifelse } ifelse } ifelse } ifelse }{ - false + //false } ifelse {dup annotrect %% Somewhat horrifyingly, rectfill maps directly to the device fill_rectangle @@ -4362,7 +4423,7 @@ currentdict /set_bc_color undef %% Heuristic to determine the height (ascender to descender) of the text %% for when we move down a line. gsave - /..TextHeight (Hy) false charpath pathbbox exch pop exch sub exch pop def + /..TextHeight (Hy) //false charpath pathbbox exch pop exch sub exch pop def grestore %% and use it immediatley to start the text one line down %% @@ -4806,9 +4867,9 @@ currentdict /drawannottypes undef /preserveannottypes 20 dict begin -/Circle {mark exch loadannot /ANN pdfmark false} bind executeonly def -/FileAttachment {mark exch loadannot /ANN pdfmark false} bind executeonly def -/FreeText {mark exch loadannot /ANN pdfmark false} bind executeonly def +/Circle {mark exch loadannot /ANN pdfmark //false} bind executeonly def +/FileAttachment {mark exch loadannot /ANN pdfmark //false} bind executeonly def +/FreeText {mark exch loadannot /ANN pdfmark //false} bind executeonly def /Highlight { mark exch @@ -4817,10 +4878,10 @@ currentdict /drawannottypes undef ApplyCTMToQuadPoints put } if - loadannot /ANN pdfmark false + loadannot /ANN pdfmark //false } bind executeonly def -/Ink {mark exch loadannot /ANN pdfmark false} bind executeonly def +/Ink {mark exch loadannot /ANN pdfmark //false} bind executeonly def /Line { mark exch dup /L .knownget { @@ -4828,11 +4889,11 @@ currentdict /drawannottypes undef 5 -1 roll astore 1 index /L 3 -1 roll put } if - loadannot /ANN pdfmark false + loadannot /ANN pdfmark //false } bind executeonly def /Link { - /NO_PDFMARK_DESTS where {pop NO_PDFMARK_DESTS not}{true}ifelse + /NO_PDFMARK_DESTS where {pop NO_PDFMARK_DESTS not}{//true}ifelse { mark exch dup /BS knownoget { << exch { oforce } forall >> /BS exch 3 -1 roll } if @@ -4916,14 +4977,14 @@ currentdict /drawannottypes undef } stopped {cleartomark} if } ifelse }{pop} ifelse - false + //false } bind executeonly def -/Movie {mark exch loadannot /ANN pdfmark false} bind executeonly def -/Popup {mark exch loadannot /ANN pdfmark false} bind executeonly def -/Sound {mark exch loadannot /ANN pdfmark false} bind executeonly def -/Square {mark exch loadannot /ANN pdfmark false} bind executeonly def -/Stamp {mark exch loadannot /ANN pdfmark false} bind executeonly def +/Movie {mark exch loadannot /ANN pdfmark //false} bind executeonly def +/Popup {mark exch loadannot /ANN pdfmark //false} bind executeonly def +/Sound {mark exch loadannot /ANN pdfmark //false} bind executeonly def +/Square {mark exch loadannot /ANN pdfmark //false} bind executeonly def +/Stamp {mark exch loadannot /ANN pdfmark //false} bind executeonly def /StrikeOut { mark exch @@ -4932,7 +4993,7 @@ currentdict /drawannottypes undef ApplyCTMToQuadPoints put } if - loadannot /ANN pdfmark false + loadannot /ANN pdfmark //false } bind executeonly def /Squiggly { @@ -4942,11 +5003,11 @@ currentdict /drawannottypes undef ApplyCTMToQuadPoints put } if - loadannot /ANN pdfmark false + loadannot /ANN pdfmark //false } bind executeonly def -/Text {mark exch loadannot /ANN pdfmark false} bind executeonly def -/TrapNet {mark exch loadannot /ANN pdfmark false} bind executeonly def +/Text {mark exch loadannot /ANN pdfmark //false} bind executeonly def +/TrapNet {mark exch loadannot /ANN pdfmark //false} bind executeonly def /Underline { mark exch @@ -4955,7 +5016,7 @@ currentdict /drawannottypes undef ApplyCTMToQuadPoints put } if - loadannot /ANN pdfmark false + loadannot /ANN pdfmark //false } bind executeonly def %% Widget annotations are only used with AcroForms, and since we don't preserve AcroForms @@ -4963,7 +5024,7 @@ currentdict /drawannottypes undef %% PDF won't know what values they should take. So we draw widget annotations instead. If we %% ever preserve AcroForms then we should alter this to preserve Widgets as well. %% simply chane "drawannot" to "mark exch loadannot /ANN pdfmark" -/Widget {mark exch {drawannot} PDFSTOPONERROR {exec}{stopped {(Error: Ignoring invalid annotation, output may be incorrect.\n) pdfformaterror} if} ifelse cleartomark false} bind executeonly def +/Widget {mark exch {drawannot} PDFSTOPONERROR {exec}{stopped {(Error: Ignoring invalid annotation, output may be incorrect.\n) pdfformaterror} if} ifelse cleartomark //false} bind executeonly def currentdict end readonly def diff --git a/Master/tlpkg/tlgs/Resource/Init/pdf_font.ps b/Master/tlpkg/tlgs/Resource/Init/pdf_font.ps index bea9ea95ad1..9fb85f60b60 100644 --- a/Master/tlpkg/tlgs/Resource/Init/pdf_font.ps +++ b/Master/tlpkg/tlgs/Resource/Init/pdf_font.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 @@ -37,8 +37,7 @@ /.setlanguagelevel where { pop 2 .setlanguagelevel } if .currentglobal //true .setglobal -/pdfdict where { pop } { /pdfdict 100 dict def } ifelse -GS_PDF_ProcSet begin +/GS_PDF_ProcSet load begin % from userdict at this point pdfdict begin % We cache the PostScript font in an additional element of the @@ -198,7 +197,7 @@ currentdict /known_symbolic_fonts undef } if } if exch pop /Subtype knownoget {/Type1C eq}{//false} ifelse - exch /Flags knownoget {4 and 4 eq not}{false}ifelse and + exch /Flags knownoget {4 and 4 eq not}{//false}ifelse and } {//false} ifelse 1 index /FontType get 2 eq and @@ -696,7 +695,7 @@ currentdict end readonly def exch pop exch % font-res font-dict g2u encoding|null userdict /.lastToUnicode get % font-res font-dict g2u Encoding|null CMap .convert_ToUnicode-into-g2u % font-res font-dict - //null % font-res font-dict null + //null % font-res font-dict //null } ifelse } ifelse } if @@ -714,7 +713,7 @@ currentdict end readonly def pop pop pop currentdict /.stackdepth .forceundef currentdict /.dstackdepth .forceundef - } + } executeonly {pop pop pop} ifelse @@ -838,7 +837,7 @@ setglobal % We also allow the font name analysis to override the Flags setting % for Italic/Oblique as this gives us results more consistent with % Acrobat. - 0 2 index .fontnameproperties 7 and or + 0 2 index //.fontnameproperties exec 7 and or % Rebind the default font name to Helvetica so that % fonts with no properties are handled correctly. //.pdfdfndict begin .substitutefontname end @@ -1221,18 +1220,18 @@ currentdict /eexec_pdf_param_dict .undef %% below will fail. It would be nice to fix the cases of this someday, but %% we use 'nodict'[ to store other PDF state stuff that isn't gstate, and we %% probably always will, so it may well be more trouble than its worth. - /Dummy false gput + /Dummy //false gput Font /Resources get exch pdfopdict /BuildCharDictDepth countdictstack def .pdfruncontext countdictstack BuildCharDictDepth sub { - pdfdict /.Qqwarning_issued .knownget {not}{//true} ifelse + //pdfdict /.Qqwarning_issued .knownget {not}{//true} ifelse { (\n **** Warning: Type 3 glyph has unbalanced q/Q operators \(too many q's\)\n Output may be incorrect.\n) pdfformatwarning - pdfdict /.Qqwarning_issued //true .forceput - } if + //pdfdict /.Qqwarning_issued //true .forceput + } executeonly if Q } repeat Q @@ -1807,7 +1806,7 @@ currentdict /CMap_read_dict undef 11 -1 roll pop % Stack: <w0x'> <w0y'> <llx> <lly> <urx> <ury> <w1x'> <w1y'> <vx'> <vy'> end % recover currentdict -} executeonly def +} bind executeonly def % <string> <match> tailmatch ==> <pre> true % ==> <string> false @@ -1868,16 +1867,12 @@ currentdict /CMap_read_dict undef /findCIDFont { { dup /CIDFont resourcestatus { - pop %size - % Check status. If its 1 then we loaded this CIDFont resource from disk, and - % its safe to use it. If its 0 then it was loaded from the PDF file and its - % *not* safe to use as a replacement for a missing font. If its 2 then its - % not loaded, but is available from external resource and is safe to use. So - % if status is 0, *don't* use this CIDFont. - 0 eq not { - /CIDFont findresource - exit - }if + pop pop dup /CIDFont findresource + dup /Path known + 1 index /ResourcePath known or + { exch pop exit } + { pop dup /CIDFont undefineresource } + ifelse } if .remove_font_name_prefix dup dup length string cvs @@ -2016,7 +2011,7 @@ currentdict /CMap_read_dict undef /CIDFallBack /CIDFont findresource } if exit - } if + } executeonly if } if } if @@ -2361,7 +2356,7 @@ currentdict /bndef undef dup //null eq {pop} { - pdfdict /InputPDFFileName .knownget {.CRCHashFilenameAndObject} if + //pdfdict /InputPDFFileName .knownget {.CRCHashFilenameAndObject} if exch dup /.OrigUniqueIDXUID .knownget not { dup /XUID .knownget not diff --git a/Master/tlpkg/tlgs/Resource/Init/pdf_main.ps b/Master/tlpkg/tlgs/Resource/Init/pdf_main.ps index 00da47a4871..5305ea6132a 100644 --- a/Master/tlpkg/tlgs/Resource/Init/pdf_main.ps +++ b/Master/tlpkg/tlgs/Resource/Init/pdf_main.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,8 +18,9 @@ /.setlanguagelevel where { pop 2 .setlanguagelevel } if .currentglobal //true .setglobal -/pdfdict where { pop } { /pdfdict 100 dict def } ifelse pdfdict begin +/GS_PDF_ProcSet dup load def % keep in pdfdict to hide it +userdict /GS_PDF_ProcSet undef % Patch in an obsolete variable used by some third-party software. /#? //false def @@ -165,7 +166,7 @@ pdfdict begin % WantsPageLabels means that pagelabels will be passed % using .pdfpagelabels and not using pdfmarks /WantsPageLabels /GetDeviceParam .special_op - {pop pop false}{true} ifelse + {pop pop //false}{//true} ifelse %% This is truly ugly..... %% GSView 5 redefines pdfmark and processes it itself. However if it gets @@ -175,11 +176,11 @@ pdfdict begin %% try not to break it. We happen to know that GSView 5 installs a GSview %% dictionary in userdict, so this test simply ensures we don't emit PAGELABEL %% pdfmarks if that dictioanry is present. - userdict /GSview known {pop false} if + userdict /GSview known {pop //false} if } bind executeonly % generate pagelabel pdfmark /dopagelabel { % -- dopagelabel -- - << /S null /P () /O 0 >> begin + << /S //null /P () /O 0 >> begin wantpagelabelmarks { Trailer /Root knownoget { oforce /PageLabels knownoget { @@ -304,14 +305,14 @@ currentdict /runpdfstring .undef /Page //null def /DSCPageCount 0 def /PDFSave //null def - GS_PDF_ProcSet begin - pdfdict begin + //pdfdict /GS_PDF_ProcSet get begin + //pdfdict begin pdfopen begin /CumulativePageCount currentpagedevice /PageCount get def } bind executeonly def /runpdfpagerange { % - runpdfpagerange <firstpage#> <lastpage#> -<</DisablePageHandler true>> setpagedevice +<</DisablePageHandler //true>> setpagedevice /PortfolioPage where { pop PortfolioPage cvi dup pdfpagecount add % a b+1 @@ -320,8 +321,8 @@ currentdict /runpdfstring .undef dup 3 index exch cvs pop % a b+1 /P (b+1) store 1 sub % a b - /FirstPage where { pop FirstPage <</DisablePageHandler true>> setpagedevice} { 1 } ifelse - /LastPage where { pop LastPage <</DisablePageHandler true>> setpagedevice} {2000000000} ifelse % a b fp lp + /FirstPage where { pop FirstPage <</DisablePageHandler //true>> setpagedevice} { 1 } ifelse + /LastPage where { pop LastPage <</DisablePageHandler //true>> setpagedevice} {2000000000} ifelse % a b fp lp 2 index 2 index lt { % b < fp 1e10 } { @@ -394,7 +395,7 @@ currentdict /runpdfstring .undef pop } forall - <</DisablePageHandler true>> setpagedevice + <</DisablePageHandler //true>> setpagedevice /PDFPageList pdfpagecount 1 add array def { (,) search { @@ -476,7 +477,7 @@ currentdict /runpdfstring .undef 1 pdfpagecount }{ /FirstPage where { - <</DisablePageHandler true>> setpagedevice + <</DisablePageHandler //true>> setpagedevice pop FirstPage dup pdfpagecount gt { (\nRequested FirstPage is greater than the number of pages in the file: ) print pdfpagecount = flush @@ -484,7 +485,7 @@ currentdict /runpdfstring .undef } { 1 } ifelse - /LastPage where {<</DisablePageHandler true>> setpagedevice pop LastPage pdfpagecount .min } { pdfpagecount } ifelse + /LastPage where {<</DisablePageHandler //true>> setpagedevice pop LastPage pdfpagecount .min } { pdfpagecount } ifelse 1 index 1 index gt { ( No pages will be processed \(FirstPage > LastPage\).) = flush } { @@ -507,7 +508,7 @@ currentdict /runpdfstring .undef /PDFPageList where { pop dup PDFPageList exch get 1 eq } - {true} ifelse + {//true} ifelse { dup /Page# exch store @@ -624,7 +625,7 @@ currentdict /runpdfstring .undef %% copied to a temporary file) and store it in pdfdict. We will use this for %% hashing fonts to detect if fonts with the same name are from different files. %% - dup currentglobal exch true setglobal .getfilename exch setglobal /InputPDFFileName exch pdfdict 3 1 roll .forceput + dup currentglobal exch //true setglobal .getfilename exch setglobal /InputPDFFileName exch //pdfdict 3 1 roll .forceput //runpdfbegin exec //pdf_collection_files exec @@ -757,7 +758,7 @@ pdfdict begin % Bug #696454 PDFfile fileposition /dictlevelcount 0 def - /TrailerSizeError false def + /TrailerSizeError //false def /TrailerSize 0 def { @@ -788,7 +789,7 @@ pdfdict begin TrailerSize growPDFobjects PDFfile exch setfileposition 0 % Initialize xref table error counter - false % Have we seen at least one section entry in this xref ? Bug #694342 + //false % Have we seen at least one section entry in this xref ? Bug #694342 { PDFfile token pop % first object # or trailer dup /trailer eq { %% check to see if we have seen at least an empty section for this xref @@ -822,9 +823,9 @@ pdfdict begin 2 copy add TrailerSize gt { TrailerSizeError not { - /TrailerSizeError true def + /TrailerSizeError //true def PDFSTOPONERROR not { - (**** Warning: Discovered more enties in xref than declared in trailer /Size\n) pdfformatwarning + (**** Warning: Discovered more entries in xref than declared in trailer /Size\n) pdfformatwarning } { /readorigxref cvx /rangecheckerror signalerror } ifelse @@ -879,7 +880,7 @@ pdfdict begin 1 add % increment object number } repeat pop % pop <obj #> - true % We have seen at least one entry in an xref section Bug #694342 + //true % We have seen at least one entry in an xref section Bug #694342 } loop 0 ne { ( **** Warning: length of some xref entries is not equal to 20 bytes.\n) @@ -1114,7 +1115,7 @@ currentdict /xref-char-dict undef % Copy bookmarks (outline) to the output. Trailer /Root knownoget { /Outlines knownoget { - /NO_PDFMARK_OUTLINES where {pop NO_PDFMARK_OUTLINES not}{true}ifelse + /NO_PDFMARK_OUTLINES where {pop NO_PDFMARK_OUTLINES not}{//true}ifelse { dup /First known { 100 dict exch %% dictionary for detecting circular references @@ -1166,17 +1167,28 @@ currentdict /xref-char-dict undef Trailer /Info {knownoget} stopped { ( **** Error: Unable to read Info dictionary from Trailer, Info will not be preserved.\n) pdfformaterror count pdfemptycount sub {pop} repeat + /emitProducer where {/emitProducer //false put} if } { { - mark exch - { /Author /Creator /Title /Subject /Keywords - % /Producer is Ghostscript; /CreationDate is now; /ModDate is also now. - } { - 2 copy knownoget { 3 -1 roll } { pop } ifelse - } forall - pop - dup mark ne { {/DOCINFO pdfmark} stopped {cleartomark} if } { pop } ifelse + % + % Bug #700820, if the Info dictionary isn't a dictionary, then don't try to use it.... + % + dup type /dicttype eq { + mark exch + { /Author /Creator /Title /Subject /Keywords + % /Producer is Ghostscript; /CreationDate is now; /ModDate is also now. + } { + 2 copy knownoget { 3 -1 roll } { pop } ifelse + } forall + pop + dup mark ne { {/DOCINFO pdfmark} stopped {cleartomark} if } { pop } ifelse + }{ + pop + ( **** Error: The Info dictionary is not a dictionary, Info will not be preserved.\n) pdfformaterror + count pdfemptycount sub {pop} repeat + /emitProducer where {/emitProducer //false put} if + } ifelse } if } ifelse } if @@ -1359,7 +1371,7 @@ currentdict /xref-char-dict undef } if } if } ifelse - } .internalstopped + } //.internalstopped exec { //true } if % If we stop then we need to rebuild % Stack: <filesize> <obj num> <need rebuild flag> { @@ -1390,7 +1402,7 @@ currentdict /xref-char-dict undef } bind executeonly def /pdfopenfile { % <file> pdfopenfile <dict> - pdfdict readonly pop % can't do it any earlier than this + //pdfdict readonly pop % can't do it any earlier than this 32 dict begin /LocalResources 0 dict def /DefaultQstate //null def % establish binding @@ -1401,8 +1413,8 @@ currentdict /xref-char-dict undef currentpagedevice /OutputFile known { currentpagedevice /OutputFile get (%d) search { pop pop pop - /NO_PDFMARK_OUTLINES true def - /NO_PDFMARK_DESTS true def + /NO_PDFMARK_OUTLINES //true def + /NO_PDFMARK_DESTS //true def } { pop }ifelse @@ -1413,10 +1425,11 @@ currentdict /xref-char-dict undef cvlit /PDFfile exch def /PDFsource PDFfile def /Repaired //false def + /emitProducer //true def /RepairedAnError //false def /StreamRunAborted //false def /NeedAppearances //false def - /ICCProfileNError false def + /ICCProfileNError //false def currentglobal //true .setglobal globaldict begin /UndefProcList 0 dict def end .setglobal @@ -1450,15 +1463,15 @@ currentdict /xref-char-dict undef /Trailer << >> def % Initialize to an emptry dict. {initPDFobjects findxref readxref} PDFSTOPONERROR not { - .internalstopped { + //.internalstopped exec { recover_xref_data % Read failed. Attempt to recover xref data. search_trailer % Search for the primary trailer - false % search_trailer sets up /Trailer, so don't run the code to do that... + //false % search_trailer sets up /Trailer, so don't run the code to do that... } { - true + //true } ifelse } { - exec true + exec //true } ifelse { @@ -1509,7 +1522,7 @@ currentdict /xref-char-dict undef { readxref } PDFSTOPONERROR not { - .internalstopped { + //.internalstopped exec { recover_xref_data % Read failed. Attempt to recover xref data. /PrevArray where {/PrevArray undef} if %% remove the array we were using to detect circular references exit % Exit loop since recover gets all obj data. @@ -1561,18 +1574,18 @@ currentdict /xref-char-dict undef << /EODCount 2 index bytesavailable %% fix data length at underlying bytes /EODString () %% make sure filter passes that many bytes, no EOD - /CloseSource false %% Be sure, tell the filter not to close the source file + /CloseSource //false %% Be sure, tell the filter not to close the source file >> /SubFileDecode filter dup %% -filter- -filter- token { %% -filter- <any> true | false %% token returned a value exch %% <any> filter closefile %% <any> - true %% <any> true + //true %% <any> true }{ %% token didn't find a value closefile %% - - false %% false + //false %% false } ifelse } { token @@ -1649,11 +1662,19 @@ currentdict /xref-char-dict undef } odef /printProducer { - Trailer /Info { knownoget_safe } stopped { pop pop //false } if { - /Producer knownoget not { //null } if + Trailer /Info { knownoget_safe } stopped { pop pop //false } if + + { + /emitProducer where {/emitProducer get}{//true} ifelse + { + /Producer knownoget not { //null } if + }{ + pop //null + } ifelse } { //null } ifelse + dup //null eq { pop } { @@ -1841,25 +1862,51 @@ currentdict /xref-char-dict undef ifelse } bind executeonly def -/obj_get { +/parent_obj_get { % /ResourceName pagedict /ObjType LocalResourceDir + /ParentResources .knownget { + dup 2 index .knownget { + % Found ObjType directory + 4 index .knownget { + 0 get 5 1 roll pop pop pop pop + } { + parent_obj_get % not found -- check it's parent. + } ifelse + } { + parent_obj_get % not found -- check it's parent. + } ifelse + } { + pop pop pop 0 + } ifelse +} bind executeonly def + +/obj_get { % /ResourceName pagedict /ObjType obj_get + % success: /ResourceName objnumber + % fail: /ResourceName /ResourceName 0 LocalResources 1 index knownoget { - dup 4 index known { - 3 index get - 0 get 4 1 roll pop pop pop - } if + dup 4 index .knownget { + 0 get 5 1 roll pop pop pop pop + } { + pop pop pop 0 + } ifelse } { + % Not in LocalResources. Try Page Resources. 1 index /Resources pget { 1 index knownoget { dup 4 index known { 3 index get 0 get 4 1 roll pop pop pop }{ - pop pop pop 0 + % Not in Page Resources, recursively try ParentResources as a last resort + pop % page Resources + LocalResources parent_obj_get }ifelse }{ - pop pop pop 0 + % No Page Resources, recursively try ParentResources as a last resort + pop % page Resources + LocalResources parent_obj_get } ifelse } { + % No Page Resources, recursively try ParentResources as a last resort pop pop pop 0 }ifelse }ifelse @@ -2642,7 +2689,7 @@ currentdict /PDF2PS_matrix_key undef % If the current device isn't CMYK, or if it is a HighLevelDevice (pdfwrite) we % don't need the special handling of Overprint transparency, so disable the checking. currentpagedevice dup /Colors get 4 lt exch /HighLevelDevice known or { - /checkOPtrans { pop false } def % NB: original will be restored from PDFsave + /checkOPtrans { pop //false } def % NB: original will be restored from PDFsave } if % Show the page within a PDF 1.4 device filter. 0 .pushpdf14devicefilter { @@ -2655,7 +2702,7 @@ currentdict /PDF2PS_matrix_key undef } { 1 index get_media_box pop /MediaBox exch } ifelse - oforce_elems normrect_elems fix_empty_rect_elems 4 array astore .beginformgroup + oforce_elems normrect_elems fix_empty_rect_elems 4 array astore .beginpagegroup showpagecontents .endtransparencygroup } { @@ -2671,7 +2718,7 @@ currentdict /PDF2PS_matrix_key undef .poppdf14devicefilter % NB: reset to DefaultQstate will also restore transfer function /DefaultQstate qstate store % device has changed -- reset DefaultQstate } { - /checkOPtrans { pop false } def % no-op the check if the page doesn't use transparency + /checkOPtrans { pop //false } def % no-op the check if the page doesn't use transparency % NB: original will be restored from PDFsave showpagecontents } ifelse @@ -2691,24 +2738,24 @@ currentdict /PDF2PS_matrix_key undef StreamRunAborted not { (\n **** Error: File has unbalanced q/Q operators \(too many q's\)\n Output may be incorrect.\n) - pdfdict /.Qqwarning_issued .knownget + //pdfdict /.Qqwarning_issued .knownget { { pop } { - currentglobal pdfdict gcheck .setglobal - pdfdict /.Qqwarning_issued //true .forceput + currentglobal //pdfdict gcheck .setglobal + //pdfdict /.Qqwarning_issued //true .forceput .setglobal pdfformaterror - } ifelse + } executeonly ifelse } { - currentglobal pdfdict gcheck .setglobal - pdfdict /.Qqwarning_issued //true .forceput + currentglobal //pdfdict gcheck .setglobal + //pdfdict /.Qqwarning_issued //true .forceput .setglobal pdfformaterror - } ifelse + } executeonly ifelse } if } if pop @@ -2717,8 +2764,8 @@ currentdict /PDF2PS_matrix_key undef Repaired % pass Repaired state around the restore RepairedAnError PDFSave restore - currentglobal pdfdict gcheck .setglobal - pdfdict /.Qqwarning_issued //false .forceput + currentglobal //pdfdict gcheck .setglobal + //pdfdict /.Qqwarning_issued //false .forceput .setglobal /RepairedAnError exch def /Repaired exch def @@ -2822,7 +2869,7 @@ currentdict /PDF2PS_matrix_key undef currentdevice 1 dict dup /ProcessColorModel dup put .getdeviceparams exch pop exch pop dup type /nametype ne { cvn } if - dup { setcolorspace } .internalstopped { pop /DeviceRGB } if + dup { setcolorspace } //.internalstopped exec { pop /DeviceRGB } if } bind executeonly def % ------ Transparency support ------ % @@ -2938,7 +2985,7 @@ currentdict /PDF2PS_matrix_key undef } if } if /Form eq { - dup /Group known {pop pop true exit}{ + dup /Group known {pop pop //true exit}{ 3 index exch resourceusestransparency { not exit } if } ifelse } { @@ -2960,6 +3007,29 @@ currentdict /PDF2PS_matrix_key undef pop } ifelse } if + dup /Font knownoget { + //false exch + { + exch pop oforce + dup type /dicttype eq { + dup /Subtype knownoget { + /Type3 eq + { + 3 index exch resourceusestransparency + { pop //true exit } if + } + {pop} ifelse + } + { + pop + }ifelse + } + { % probably a name object + pop + }ifelse + } forall + { pop //true exit } if + } if 2 copy //false put % Visited but not in the current chain. pop //false exit } loop @@ -3241,7 +3311,7 @@ currentdict /PDF2PS_matrix_key undef dup 0 get dup 4 index eq } { - 0 false + 0 //false }ifelse %% <calling obj_num> <XObjectdict> false value <form object or 0 if not indirect> <boolean> @@ -3444,13 +3514,13 @@ currentdict /PDF2PS_matrix_key undef end % pdfdict .setglobal -DELAYBIND not { %% This list of operators are used internally by various parts of the Ghostscript PDF interpreter. %% Since each operator is a potential security vulnerability, and any operator listed here %% is not required once the initislisation is complete and functions are bound, we undefine %% the ones that aren't needed at runtime. +/.PDF_UNDEF_OPLIST [ -/.pdfawidthshow /.pdfwidthshow +/.pdfawidthshow /.pdfwidthshow /.currentblackptcomp /.setblackptcomp /.setfillcolor /.setfillcolorspace /.setstrokecolor /.setstrokecolorspace /.currentrenderingintent /.setrenderingintent /.currenttextrenderingmode /.settextspacing /.currenttextspacing /.settextleading /.currenttextleading /.settextrise /.currenttextrise /.setwordspacing /.currentwordspacing /.settexthscaling /.currenttexthscaling @@ -3461,7 +3531,7 @@ DELAYBIND not { /.abortpdf14devicefilter /.pdfinkpath /.pdfFormName /.setstrokeconstantalpha /.setfillconstantalpha /.setalphaisshape /.currentalphaisshape /.settextspacing /.currenttextspacing /.settextleading /.currenttextleading /.settextrise /.currenttextrise -/.setwordspacing /.currentwordspacing /.settexthscaling /.currenttexthscaling +/.setwordspacing /.currentwordspacing /.settexthscaling /.currenttexthscaling /.setPDFfontsize /.currentPDFfontsize /.setdistillerparams % Used by our own test suite files @@ -3472,8 +3542,12 @@ DELAYBIND not { %/.endtransparencygroup % transparency-example.ps % undefining these causes errors/incorrect output -%/.settextrenderingmode /.setblendmode /.begintransparencygroup /.settextknockout /check_r6_password /.setstrokeoverprint /.setfilloverprint +%/.settextrenderingmode /.setblendmode /.begintransparencygroup /.settextknockout /.setstrokeoverprint /.setfilloverprint %/.currentstrokeoverprint /.currentfilloverprint /.currentfillconstantalpha /.currentstrokeconstantalpha -] +] def + +DELAYBIND not { +.PDF_UNDEF_OPLIST {systemdict exch .undef} forall +systemdict /.PDF_UNDEF_OPLIST .undef } if diff --git a/Master/tlpkg/tlgs/Resource/Init/pdf_ops.ps b/Master/tlpkg/tlgs/Resource/Init/pdf_ops.ps index 8672d617f36..285e582eff2 100644 --- a/Master/tlpkg/tlgs/Resource/Init/pdf_ops.ps +++ b/Master/tlpkg/tlgs/Resource/Init/pdf_ops.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 @@ -24,6 +24,7 @@ systemdict /pdfmark known not { userdict /pdfmark { cleartomark } bind executeonly put } if +systemdict /pdfdict where { pop } { /pdfdict 325 dict put } ifelse userdict /GS_PDF_ProcSet 256 dict dup begin % ---------------- Abbreviations ---------------- % @@ -174,24 +175,24 @@ currentdict /gput_always_allow .undef { (\n **** Error: File has unbalanced q/Q operators \(too many Q's\)\n Output may be incorrect.\n) - pdfdict /.Qqwarning_issued .knownget + //pdfdict /.Qqwarning_issued .knownget { { pop } { - currentglobal pdfdict gcheck .setglobal - pdfdict /.Qqwarning_issued //true .forceput + currentglobal //pdfdict gcheck .setglobal + //pdfdict /.Qqwarning_issued //true .forceput .setglobal pdfformaterror - } ifelse + } executeonly ifelse } { - currentglobal pdfdict gcheck .setglobal - pdfdict /.Qqwarning_issued //true .forceput + currentglobal //pdfdict gcheck .setglobal + //pdfdict /.Qqwarning_issued //true .forceput .setglobal pdfformaterror - } ifelse + } executeonly ifelse } if } bind executeonly odef @@ -315,7 +316,7 @@ currentdict /gput_always_allow .undef ( Output may be incorrect.\n) print } if setcolorspace - /ICCProfileNError where {/ICCProfileNError true put} if + /ICCProfileNError where {/ICCProfileNError //true put} if } ifelse }ifelse }{ @@ -349,7 +350,7 @@ currentdict /gput_always_allow .undef ( Output may be incorrect.\n) print } if setcolorspace - /ICCProfileNError where {/ICCProfileNError true put} if + /ICCProfileNError where {/ICCProfileNError //true put} if } ifelse }ifelse }{ @@ -439,7 +440,8 @@ currentdict /gput_always_allow .undef dup type /booleantype eq { .currentSMask type /dicttype eq { .currentSMask /Processed 2 index .forceput - } { + } executeonly + { .setSMask }ifelse }{ @@ -456,7 +458,7 @@ currentdict /gput_always_allow .undef /BM { /.setblendmode where { pop [ exch dup type /nametype ne { aload pop } if /Normal ] { - { .setblendmode } .internalstopped not { exit } if pop + { .setblendmode } //.internalstopped exec not { exit } if pop } forall } { pop @@ -468,7 +470,7 @@ currentdict /gput_always_allow .undef /UseBlackPtComp { %% Our implementation of black point compensation uses 0 or 1, not a boolean - /.setblackptcomp where {pop false eq {0}{1}ifelse .setblackptcomp }{ pop } ifelse + /.setblackptcomp where {pop //false eq {0}{1}ifelse .setblackptcomp }{ pop } ifelse } bind executeonly def % ---------------- Color installation ---------------- % @@ -573,7 +575,7 @@ currentdict /gput_always_allow .undef ( Output may be incorrect.\n) print } if setcolorspace - /ICCProfileNError true def + /ICCProfileNError //true def } ifelse }ifelse }{ @@ -691,7 +693,14 @@ end def { PDFusingtransparency { .currentSMask //null ne { - mark /Subtype /Group /Isolated //true .dicttomark pathbbox .begintransparencygroup + mark /Subtype /Group /Isolated //true .dicttomark + 1 index /stroke eq { + % BBox needs to include line width / line join expansion. + gsave strokepath pathbbox grestore + } { + pathbbox % fill/eofill cases + } ifelse + .begintransparencygroup .currentshapealpha .currentopacityalpha 3 -1 roll % avoid double application 1 .setopacityalpha 1 .setshapealpha } if @@ -973,9 +982,9 @@ end readonly def 3 1 roll mul exch sub 0 eq { - true + //true }{ - false + //false } ifelse } bind executeonly def @@ -1120,19 +1129,19 @@ end readonly def %% Set the special version of the path constructoin operators, so that %% they will work as expected if they are illgeally present in a text block. switch_to_text_marking_ops - + %% If needed, let the pdf14 device know we are in a BT condition. This %% distinguishes BT from an Annotation /FreeText show command which also %% can come into pdf_text_begin with an opacity not equal to 1. PDFusingtransparency .currenttextknockout and { .begintransparencytextgroup } if - + } bind executeonly def /ET_NO_TXT_KO { currentdict /TextSaveMatrix known { - .currenttextrenderingmode 4 ge { .currentfilladjust 0 .setfilladjust clip .setfilladjust} if + .currenttextrenderingmode 4 ge { .currentfilladjust2 0 dup .setfilladjust2 clip .setfilladjust2} if newpath TextSaveMatrix setmatrix currentdict /TextSaveMatrix undef @@ -1160,7 +1169,7 @@ end readonly def % Group push occurred in pdf14_text_begin. PDFusingtransparency .currenttextknockout and { .endtransparencytextgroup - } if + } if } bind executeonly def /Tc { .settextspacing { showfirst } /Show gput } bind executeonly def @@ -1920,7 +1929,7 @@ end readonly def { /FDepVector get 0 get /FontBBox get} { - pop null % force an error + pop //null % force an error } ifelse }if dup 1 get neg exch 3 get % MaxLen (V) Ff Q dx dy yy desc asc diff --git a/Master/tlpkg/tlgs/Resource/Init/pdf_rbld.ps b/Master/tlpkg/tlgs/Resource/Init/pdf_rbld.ps index 03654414065..3aca13d8cb9 100644 --- a/Master/tlpkg/tlgs/Resource/Init/pdf_rbld.ps +++ b/Master/tlpkg/tlgs/Resource/Init/pdf_rbld.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 @@ -374,7 +374,7 @@ } ifelse % Read a line from file. If the line does not fit into our working string, % or any other error, then we will discard it. - PDFfile exch { readline } .internalstopped + PDFfile exch { readline } //.internalstopped exec { pop pop //false } if % indicate no string if we stopped { % stack: <length> <working_str> <loc> <string> % Now that we have line, get obj num, ref num, and 'obj'. Verify that each diff --git a/Master/tlpkg/tlgs/Resource/Init/pdf_sec.ps b/Master/tlpkg/tlgs/Resource/Init/pdf_sec.ps index 143efb7ea59..0f77e556253 100644 --- a/Master/tlpkg/tlgs/Resource/Init/pdf_sec.ps +++ b/Master/tlpkg/tlgs/Resource/Init/pdf_sec.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 @@ -39,7 +39,6 @@ /.setlanguagelevel where { pop 2 .setlanguagelevel } if .currentglobal //true .setglobal -/pdfdict where { pop } { /pdfdict 100 dict def } ifelse pdfdict begin % Older ghostscript versions do not have .pdftoken, so we use 'token' instead. @@ -422,14 +421,14 @@ def dup 6 eq { pop % First, try the password as UTF-8. - dup Trailer /Encrypt oget check_r6_password { + dup Trailer /Encrypt oget //check_r6_password exec { exch pop //true } { % The password didn't work as UTF-8, so maybe it's in the % locale character set instead. If possible, convert it to % UTF-8 and try again. /.locale_to_utf8 where { - pop .locale_to_utf8 Trailer /Encrypt oget check_r6_password + pop .locale_to_utf8 Trailer /Encrypt oget //check_r6_password exec } { pop //false } ifelse @@ -444,6 +443,7 @@ def } ifelse } ifelse } bind executeonly def +systemdict /check_r6_password .forceundef % Process the encryption information in the Trailer. /pdf_process_Encrypt { @@ -644,14 +644,14 @@ def } ifelse } - aload pop .packtomark cvx + aload pop //.packtomark exec cvx { loop } 0 get 2 packedarray cvx { stopped } 0 get /PDFScanRules .getuserparam //null eq { //PDFScanRules_null { setuserparams } 0 get % reset PDF scannig mode if it was off } if /PDFsource PDFsource - { store { stop } if } aload pop .packtomark cvx + { store { stop } if } aload pop //.packtomark exec cvx /PDFsource 3 -1 roll store exec } bind executeonly def currentdict /PDFScanRules_true undef @@ -748,4 +748,7 @@ currentdict /PDFScanRules_null undef } bind executeonly def end % pdfdict + +systemdict /pdfdict .forceundef % hide pdfdict + .setglobal |