?????????? ????????? - ??????????????? - /home/agenciai/public_html/cd38d8/Init.zip
???????
PK l�"\N�#b b gs_dscp.psnu �[��� % Copyright (C) 2001-2021 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. % % Postscript interface routines to DSC parser /send_orientation { % <orientation> send_orientation - % .parse_dsc_comments returns -1 for an Orientation key with an % unrecognized value. dup 0 ge { << /Orientation 2 index >> setpagedevice } if pop } bind def % This dictionary contains local handlers for DSC comments. % See header in zdscpars.c for more information. % <dsc_dict> handler <dsc_dict> /DSCparseprocs mark /Orientation { dup /Orientation get send_orientation } bind /PageOrientation { dup /PageOrientation .knownget { send_orientation } { dup /Orientation .knownget { send_orientation } if } ifelse } bind /Page { dup /Orientation .knownget { send_orientation } if } bind /NOP { } bind .dicttomark readonly def % This procedure is called whenever a DSC comment is found by the interpreter /do_parse_dsc //false def /parse_dsc { % <file> <DSC string> [<prev proc>] % parse_dsc - % Run any previously installed parser. 0 get dup //null eq { pop } { 3 copy exec pop } ifelse do_parse_dsc { % Check if this parser is enabled currentglobal //true setglobal % Go to global VM, save old state 3 1 roll % Put old VM state under <file> <string> dsc_dict exch % <VM state> <file> <dict> <string> .parse_dsc_comments % <VM state> <file> <dict> <DSC name> 4 -1 roll % Get old VM state from under <file> <dict> <DSC name> setglobal % restore previous VM state //DSCparseprocs exch .knownget { % Check DSC name against local handler list exec % execute any local handler } if } if pop pop % remove file, dict } bind def % Check whether the currently installed parser is the one defined in this file. /.using_parse_dsc { % - .using_parse_dsc <proc> <using?> currentuserparams /ProcessDSCComment get dup //null eq { pop {{//null} //parse_dsc exec} } if dup length 3 eq { dup dup length 1 sub get /parse_dsc load eq } { //false } ifelse } bind def % Establish a binding for dsc_dict. userdict /dsc_dict //null put % - dsc_init - /dsc_init { % Initialize DSC parser currentglobal //true setglobal /dsc_dict 50 dict store % Size must be large enough for all DSC values dsc_dict .initialize_dsc_parser .using_parse_dsc { % Already using this parser. pop } { % Encapsulate the previous parser. We know it is in global VM: % allocate the new one in global VM as well. 1 array astore /parse_dsc load /exec load 3 array astore cvx readonly << /ProcessDSCComment 3 -1 roll >> setuserparams } ifelse setglobal /do_parse_dsc //true def } bind def % Enable the DSC parser defined in this file. % - enable_dsc - /enable_dsc { dsc_init } bind def % Disable the DSC parser defined in this file. % - disable_dsc - /disable_dsc { % There might be another parser installed: if so, restore it. % (If it has encapsulated our parser, we can't.) .using_parse_dsc { % Restore the parser we encapsulated. 0 get 0 get currentglobal //true setglobal exch << /ProcessDSCComment 3 -1 roll >> exch setglobal setuserparams } { pop } ifelse % If we couldn't restore the old parser, at least disable ours. /do_parse_dsc //false def } bind def PK l�"\�]�x� � gs_frsd.psnu �[��� % Copyright (C) 2001-2021 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. % % Implementation of ReusableStreamDecode filter. % This file must be loaded after gs_lev2.ps and gs_res.ps. level2dict begin % ------ ReusableStreamDecode filter ------ % /.reusablestreamdecode { % <source> <dict> .reusablestreamdecode <file> % <source> .reusablestreamdecode <file> % Collect the filter parameters. dup type /dicttype eq { 2 copy } { dup 0 dict } ifelse dup .rsdparams % Construct the filter pipeline. % The very first filter should use the value of CloseSource % from the RSD dictionary; all the others should have % CloseSource = true. % Stack: source dict filters parms 2 index /CloseSource .knownget not { //false } if 5 -1 roll % Stack: dict filters parms CloseSource source 0 1 5 index length 1 sub { 4 index 1 index get % Stack: dict filters parms CloseSource source index filtname 4 index //null eq { 0 dict } { 4 index 2 index get dup //null eq { pop 0 dict} if } ifelse 3 -1 roll pop exch filter exch pop //true exch % set CloseSource for further filters } for % 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 exec } { //null //true } ifelse { pop % No luck. Read the entire contents of the stream now. dup type /filetype ne { % Make a stream from a procedure or string data source. 0 () .subfiledecode } if % We must allocate the string in the same VM space as its % source, since the reusable stream must be allocated there. .currentglobal 1 index gcheck .setglobal exch currentpacking //false setpacking exch 2 dict begin /filelen 0 def % scratch dict for filelen and pos (below). % Stack: dict filters parms CloseSource oldglobal oldpacking file [ exch { dup 40000 string readstring /filelen 2 index length filelen add def % accumulate filelen not { exit } if exch } loop exch pop ] { filelen string } stopped { % try allocating a single string pop % couldn't make a string - discard filelen value } { % transfer the array-of-strings to the single string. % stack: ... [() ...] string /pos 0 def exch { 1 index exch pos exch putinterval /pos pos 40000 add def } forall } ifelse % top of stack is either array of strings or one string == stream_data end % done with scratch dict % Stack: dict filters parms CloseSource oldglobal oldpacking stream_data 3 1 roll setpacking setglobal % Stack: dict filters parms CloseSource stream_data 1 index .reusablestream } if % We created the stream successfully: clean up. 4 { exch pop } repeat 1 index type /dicttype eq { exch pop } if exch pop } odef filterdict /ReusableStreamDecode /.reusablestreamdecode load put end % level2dict PK l�"\��F�W� W� gs_setpd.psnu �[��� % Copyright (C) 2001-2021 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. % % The current implementation of setpagedevice has the following limitations: % - It doesn't attempt to "interact with the user" for Policy = 2. languagelevel 1 .setlanguagelevel level2dict begin % ---------------- Redefinitions ---------------- % % 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. % We'd really like to avoid the cost of doing this, but we don't see how. % The names %gsavepagedevice, %savepagedevice, %gstatepagedevice, % %copygstatepagedevice, and %currentgstatepagedevice are known to the % interpreter. (%gsavepagedevice) cvn { currentpagedevice pop gsave } bind def (%savepagedevice) cvn { currentpagedevice pop save } bind def (%gstatepagedevice) cvn { currentpagedevice pop gstate } bind def (%copygstatepagedevice) cvn { currentpagedevice pop copy } bind def (%currentgstatepagedevice) cvn { currentpagedevice pop currentgstate } bind def % Define interpreter callouts for handling gstate-restoring operators % when the current page device needs to be changed. % The names %grestorepagedevice, %grestoreallpagedevice, % %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 exec { //null } if dup type /booleantype eq { pop pop } { SETPDDEBUG { (Error in .trysetparams!) = pstack flush } if {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 currentpagedevice /.LockSafetyParams .knownget not {systemdict /SAFER .knownget not {//false} } if .putdeviceparamsonly /.installpagedevice cvx /rangecheck signalerror } ifelse pop pop % A careful reading of the Red Book reveals that an erasepage % should occur, but *not* an initgraphics. erasepage .beginpage } bind executeonly def /.uninstallpagedevice { {2 .endpage { .currentnumcopies //false .outputpage } if} //.internalstopped exec pop nulldevice } bind executeonly def (%grestorepagedevice) cvn { .uninstallpagedevice grestore //.installpagedevice exec } bind def (%grestoreallpagedevice) cvn { .uninstallpagedevice grestore //.installpagedevice exec grestoreall } bind def (%restore1pagedevice) cvn { .uninstallpagedevice grestore //.installpagedevice exec restore } bind def (%restorepagedevice) cvn { .uninstallpagedevice restore //.installpagedevice exec } bind def (%setgstatepagedevice) cvn { .uninstallpagedevice setgstate //.installpagedevice exec } bind def % Redefine .currentpagedevice and .setpagedevice so they convert between % null and a fixed empty directionary. /.nullpagedevice 0 dict readonly def /.currentpagedevice { //.currentpagedevice exch dup //null eq { pop //.nullpagedevice } if exch } bind odef /.setpagedevice { dup //.nullpagedevice eq { pop //null } if //.setpagedevice } bind odef % ---------------- Auxiliary definitions ---------------- % % Define the required attributes of all page devices, and their default values. % We don't include attributes such as .MediaSize, which all devices % are guaranteed to supply on their own. /.defaultpolicies mark % M. Sweet, Easy Software Products % % Due to the fact that it is not possible to properly implement % the selection policies from a Ghostscript driver, we have changed % the default policy to "7" (impose) to avoid numerous problems with % printing within CUPS... % % If NOMEDIAATTRS is false, the set the default depending on whether % PSFitPage is true. Policy 13 does best fit with page scaling up or down % so it is only useful if FIXEDMEDIA is also specified, or if the set of % media in the InputAttributes dictionary is the actual available choices % and does not include any "range" page sizes. /PageSize NOMEDIAATTRS { 7 } { //systemdict /PSFitPage known { 13 } { 0 } ifelse } ifelse /PolicyNotFound 1 /PolicyReport { dup /.LockSafetyParams known { % Only possible error is invalidaccess /setpagedevice .systemvar /invalidaccess signalerror } if pop } bind .dicttomark readonly def % Note that the values of .requiredattrs are executed, not just fetched. /.requiredattrs mark /PageDeviceName //null /PageOffset [0 0] readonly % We populate InputAttributes with all of the known page sizes % followed by a dummy media type that handles pages of any size. % This will create some duplicates, but that only slightly slows % down the media selection (loop is in zmedia2.c). % % Some PostScript creators assume that slot 0 is the default media % size and some can't handle a non-standard 4-element array which % is a 'range' type page size (always put last). % % Real Devices that can only handle specific page sizes will override this. /InputAttributes { mark % First put the device's default page size in slot 0 % This satifies those that have devices built with a4 as the default 0 mark /PageSize /GetDeviceParam .special_op not {/setpagedevice .systemvar /configurationerror signalerror} if .dicttomark % Only populate the other entries if we aren't FIXEDMEDIA FIXEDMEDIA not { statusdict /.pagetypenames get { statusdict /.pagetypeprocs get exch get 0 2 getinterval cvlit counttomark 1 sub 2 idiv exch mark exch /PageSize exch % stack: mark --dict-- --dict-- ... key mark /PageSize [x y] % see note above about pagetype executable array contents. .dicttomark } forall % If NORANGEPAGESIZE is defined, (-dNORANGEPAGESIZE), then don't add % the 'match any' PageSize entry systemdict /NORANGEPAGESIZE known not { % Add one last entry which is the 4 element range array (non-standard) counttomark 2 idiv % PageSize with either dimension 0 will be detected in % match_page_size, so we can allow it here mark /PageSize [0 dup 16#7ffff dup] .dicttomark } if } if % FIXEDMEDIA false .dicttomark } (%MediaSource) 0 /OutputAttributes { mark 0 mark .dicttomark readonly .dicttomark } (%MediaDestination) 0 /Install {{.callinstall}} bind /BeginPage {{.callbeginpage}} bind /EndPage {{.callendpage}} bind /Policies .defaultpolicies /ImagingBBox //null % default value /UseCIEColor /.getuseciecolor load .dicttomark readonly def % Define currentpagedevice so it creates the dictionary on demand if needed, % adding all the required entries defined just above. /.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 { 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 { 2 index 2 index known { 1 index /Policies eq { % Merge policies from the device driver with defaults 2 index % <<>> /key value <<>> 3 2 roll get % <<>> value <<policies>> exch { 2 index 2 index known { pop pop } { 2 index 3 1 roll put } ifelse } forall pop } { pop pop } ifelse } { exec 2 index 3 1 roll put } ifelse } forall exch .setglobal % Remove any keys we don't want to be stored, before .setpagedevice % makes the dictionary read only .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 } def /currentpagedevice { .currentpagedevice { dup length 0 eq { pop //.makecurrentpagedevice exec } { % If any of the dynamic keys have changed, % we must update the page device dictionary. currentdevice //.volatilepdkeys .getdeviceparams .dicttomark { % Stack: current key value 2 index 2 index .knownget { 1 index ne } { //true } ifelse { 2 index wcheck not { % This is the first entry being updated. % Copy the dictionary to make it writable. 3 -1 roll currentglobal 1 index dup gcheck currentglobal and setglobal length dict exch setglobal .copydict 3 1 roll } if 2 index 3 1 roll put } { pop pop } ifelse } forall % If the device is the distiller device, update distillerparams that % may have been changed by setdistillerparams /IsDistiller /GetDeviceParam .special_op { exch pop }{ //false }ifelse { currentdistillerparams { % Stack: current key value 2 index 2 index .knownget { 1 index ne } { //true } ifelse { 2 index 3 1 roll put } { pop pop } ifelse } forall } if % If the dictionary was global and is now local, copy % any global subsidiary dictionaries to local VM. This % too is to work around the Word Perfect bug (see above). dup gcheck not { dup { dup type /dicttype eq { dup gcheck } { //false } ifelse { % Copy-on-write, see above. 2 index wcheck not { 3 -1 roll dup length dict .copydict 3 1 roll } if //.copytree exec 2 index 3 1 roll put } { pop pop } ifelse } forall } if % We would like to do a .setpagedevice so we don't keep % re-creating the dictionary. Unfortunately, the effect % of this is that if any dynamic key changes (PageCount % in particular), we will do the equivalent of a % setpagedevice at the next restore or grestore. % Therefore, we make the dictionary read-only, but % we don't store it away. I.e., NOT: % dup wcheck { .setpagedevice .currentpagedevice pop } if readonly } ifelse } if } bind odef % Define access to device defaults. /.defaultdeviceparams { finddevice //null .getdeviceparams } bind def % Select media (input or output). The hard work is done in an operator: % <pagedict> <attrdict> <policydict> <keys> .matchmedia <key> true % <pagedict> <attrdict> <policydict> <keys> .matchmedia false % <pagedict> null <policydict> <keys> .matchmedia null true /.selectmedia % <orig> <request> <merged> <failed> <-- retained % <attrdict> <policydict> <attrkeys> <mediakey> % .selectmedia { 5 index 5 -2 roll 4 index .matchmedia % Stack: orig request merged failed attrkeys mediakey % (key true | false) { 4 index 3 1 roll put pop } { % Adobe's implementations have a "big hairy heuristic" % to choose the set of keys to report as having failed the match. % For the moment, we report any keys that are in the request % and don't have the same value as in the original dictionary. 5 index 1 index .knownget { 4 index 3 1 roll put } { 3 index exch .undef } ifelse { % Stack: <orig> <request> <merged> <failed> <attrkey> 3 index 1 index .knownget { 5 index 2 index .knownget { ne } { pop //true } ifelse } { //false } ifelse % Stack: ... <failed> <attrkey> <report> { 2 copy /rangecheck put } if pop } forall } ifelse } bind def % Apply Policies to any unprocessed failed requests. % As we process each request entry, we replace the error name % in the <failed> dictionary with the policy value, % and we replace the key in the <merged> dictionary with its prior value % (or remove it if it had no prior value). % These procedures are called with the following on the stack: % <orig> <merged> <failed> <Policies> <key> <policy> % They are expected to consume the top 2 operands. % NOTE: we currently treat all values other than 0, 1, or 7 (for PageSize) % the same as 0, i.e., we signal an error. /0Policy { % Set errorinfo and signal a configurationerror. NOMEDIAATTRS { % NOMEDIAATTRS means that the default policy is 7... pop 2 index exch 7 put } { pop dup 4 index exch get 2 array astore $error /errorinfo 3 -1 roll put cleartomark /setpagedevice .systemvar /configurationerror signalerror } ifelse } bind executeonly odef % Making this an operator means we can properly hide % the contents - specifically .forceput /1Policy { % Roll back the failed request to its previous status. 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 } executeonly { 3 index exch .undef } ifelse } bind executeonly odef /7Policy { % For PageSize only, just impose the request. 1 index /PageSize eq { pop pop 1 index /PageSize 7 put } { .policyprocs 0 get exec } ifelse } bind executeonly odef /.applypolicies % <orig> <merged> <failed> .applypolicies % <orig> <merged'> <failed'> { 1 index /Policies get 1 index { type /integertype eq { pop % already processed }{ 2 copy .knownget not { 1 index /PolicyNotFound get } if % Stack: <orig> <merged> <failed> <Policies> <key> % <policy> dup 1 eq { 1Policy }{ dup 7 eq { 7Policy }{ 0Policy } ifelse } ifelse } ifelse } forall pop } .bind executeonly odef currentdict /0Policy undef currentdict /1Policy undef currentdict /7Policy undef % Put device parameters without resetting currentpagedevice. % (.putdeviceparams clears the current page device.) /.putdeviceparamsonly % <device> <Policies|null> <require_all> -mark- % <key1> <value1> ... .putdeviceparamsonly % On success: <device> <eraseflag> % On failure: <device> <Policies|null> <req_all> -mark- % <key1> <error1> ... { .currentpagedevice { counttomark 4 add 1 roll .putdeviceparams dup type /booleantype eq { 3 } { counttomark 5 add } ifelse -1 roll .setpagedevice } { pop .putdeviceparams } ifelse } 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 ---------------- % /setpagedevice { % To avoid VM mismatches caused by copying subsidiary % dictionaries to local VM (see WorPerfect bug in % .makecurrentpagedevice) we want to make the dict % returned by currentpagedevice local. However, if we % run with -dSAFER we get a call to setpagedevice from % .setsafe in gs_init.ps during startup. The dict returned % by currentpagdevice is stored to the graphics state by % .setpagedevice below, and returned by currentpagdevice. % The Display PostScript code insists that the savedinitialgstate % not have any pointers to local VM objects, so if we simply % make the dict local then we fail in gs_dps.ps. The only % solution is to make sure the VM mode is global during % startup (to satisfy gs_dps.ps) and local thereafter % (to satisfy the WordPerfect bug). dup /..StartupGlobal known { currentglobal exch //true setglobal dup /..StartupGlobal undef } { % ensure that we are always in local VM mode to avoid % mismatches. This is because we always create child % dictionaries in local VM, regardless of the current VM state, % (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 } ifelse %% We used to execute endpage after .tsrysetparams, but that actually alters %% the page device dictionary (in particular /PageSize) this is not correct. %% Testing with Adobe Acrobat Distiller shows that EndPage is ececuted if the %% page device dictionary is empty, and indeed even if setpagedevice returns %% an error (caught by stopped), so it seems pretty clear that we should %% run any required EndPage very early in the setpagedevice process. %% Bug 690667. 2 .endpage { 1 //true .outputpage (>>setpagedevice, press <return> to continue<<\n) //.confirm exec } if % We mustn't pop the argument until the very end, % so that the pseudo-operator machinery can restore the stack % if an error occurs. mark 1 index currentpagedevice % Check whether we are changing OutputDevice; % also handle the case where the current device % is not a page device. % Stack: mark <request> <current> SETPDDEBUG { (Checking.) = pstack flush } if dup /OutputDevice .knownget { % Current device is a page device. 2 index /OutputDevice .knownget { % A specific OutputDevice was requested. 2 copy eq { pop pop //null } { exch pop } ifelse } { pop //null } ifelse } { % Current device is not a page device. % Use the default device. 1 index /OutputDevice .knownget not { .defaultdevicename } if } ifelse dup //null eq { pop } { 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 } ifelse % Check whether a viewer wants to intervene. % We must check both the request (which takes precedence) % and the current dictionary. % Stack: mark <request> <orig> exch dup /ViewerPreProcess .knownget { exec } { 1 index /ViewerPreProcess .knownget { exec } if } ifelse exch % Construct a merged request from the actual request plus % any keys that should always be propagated. % Stack: mark <request> <orig> SETPDDEBUG { (Merging.) = pstack flush } if exch 1 index length 1 index length add dict .copiedkeys { % Stack: <orig> <request> <merged> <key> 3 index 1 index .knownget { 3 copy put pop } if pop } forall % Stack: <orig> <request> <merged> dup 2 index { % stack: <orig> <request> <merged> <merged> <rkey> <rvalue> //.mergespecial 2 index .knownget { exec } if put dup } forall pop % Hack: if FIXEDRESOLUTION is true, discard any attempt to % change HWResolution. 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 /PageSize 4 index /PageSize get put dup /HWSize 4 index /HWSize get put } if % Hack: to work around some files that take a PageSize % from InputAttributes and impose it, discard any attempt % to set PageSize to a 4-element value. % Stack: mark <orig> <request> <merged> dup /PageSize .knownget { length 2 ne { dup /PageSize 4 index /PageSize get put } if } if % Select input and output media. % Stack: mark <orig> <request> <merged> SETPDDEBUG { (Selecting.) = pstack flush } if 0 dict % <failed> 1 index /InputAttributes .knownget { 2 index /Policies get .inputattrkeys (%MediaSource) cvn //.selectmedia exec } if 1 index /OutputAttributes .knownget { 2 index /Policies get .outputattrkeys (%MediaDestination) cvn //.selectmedia exec } if 3 -1 roll 4 1 roll % temporarily swap orig & request .applypolicies 3 -1 roll 4 1 roll % swap back % Construct the new device, and attempt to set its attributes. % Stack: mark <orig> <request> <merged> <failed> SETPDDEBUG { (Constructing.) = pstack flush } if % Non-obvious: we need to check the name of the output device, to tell % whether we're going to have to replace the entire device chain (which % may be only one device, or may be multiple devices. % If we're not replacing the entire change, we have to use the device in % the graphics state, so the configuration of the entire device chain is % correctly set. .currentoutputdevice .devicename 2 index /OutputDevice get eq { currentdevice } { 1 index /OutputDevice get finddevice } ifelse %**************** We should copy the device here, %**************** but since we can't close the old device, %**************** we don't. This is WRONG. %****************copydevice 2 index /Policies get //.trysetparams dup type /booleantype ne { % The request failed. % Stack: ... <orig> <request> <merged> <failed> <device> % <Policies> true mark <name> <errorname> ... SETPDDEBUG { (Recovering.) = pstack flush } if counttomark 4 add index counttomark 2 idiv { dup 4 -2 roll put } repeat pop pop pop % Stack: mark ... <orig> <request> <merged> <failed> <device> % <Policies> 6 2 roll 3 -1 roll 4 1 roll .applypolicies 3 -1 roll 4 1 roll 6 -2 roll //.trysetparams % shouldn't fail! dup type /booleantype ne { 2 { counttomark 1 add 1 roll cleartomark } repeat /setpagedevice .systemvar exch signalerror } if } if % The attempt succeeded. Install the new device. % Stack: mark ... <merged> <failed> <device> <eraseflag> SETPDDEBUG { (Installing.) = pstack flush } if pop % .setdevice clears the current page device! .currentpagedevice pop exch { .setdevice } stopped { cleartomark exch pop /setpagedevice $error /errorname get signalerror } if pop .setpagedevice % Implement UseCIEColor directly if this is a LL3 system. % The color substitution feature is now implemented in % the interpreter, and this is used as an optimization. % % NB: This shoud be the only use of the .setuseciecolor % operator anywhere. % % Set some color space other than /DeviceGray, to insure % that initgraphics will actually perform a setcolorspace % operation (there is an optimization in setcolorspace % that does nothing if the operand and current color % spaces are the same) /.setuseciecolor where { pop 1 index /UseCIEColor .knownget { .setuseciecolor /DeviceRGB setcolorspace } if } if % Merge the request into the current page device, % unless we're changing the OutputDevice. % Stack: mark ... <merged> <failed> exch currentpagedevice dup length 2 index length add dict % Stack: mark ... <failed> <merged> <current> <newdict> 2 index /OutputDevice .knownget { 2 index /OutputDevice .knownget not { //null } if eq } { //true } ifelse { % Same OutputDevice, merge the dictionaries. .copydict } { % Different OutputDevice, discard the old dictionary. exch pop } ifelse .copydict % Initialize the default matrix, taking media matching % into account. //.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 2 index /HWResolution get dup 1 get exch 0 get 4 -1 roll mul 72 div 3 1 roll mul 72 div idtransform translate } if % We must install the new page device dictionary % before calling the Install procedure. dup .setpagedevice /HighLevelDevice /GetDeviceParam .special_op { exch pop not }{ //true }ifelse { .setdefaulthalftone % Set the default screen before calling Install. } if dup /Install .knownget { { .execinstall } stopped { pop % Install procedure failed. One element will have been left on the stack. % stack: mark <orig> <request> <failed> <merged> 1 index /Install $error /errorname get put % Put it in the "failed" dict % .applypolicies needs stack: <orig> <merged> <failed> 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 exec stop } { //.postinstall exec } ifelse } { //.postinstall exec } ifelse setglobal % return to original VM allocation mode } .bind executeonly odef % We break out the code after calling the Install procedure into a % separate procedure, since it is executed even if Install causes an error. % By making .execinstall a separate operator procedure, we get the stacks % mostly restored if it fails, except for one element (the operand). % Thus if it fails, there will be one element left on the op stack. /.execinstall { % <proc> .execinstall - dup % element left on the stack if the exec fails. % Because the interpreter optimizes tail calls, we can't just let % the body of this procedure be 'exec', because that would lose % the stack protection that is the whole reason for having the % procedure in the first place. The 'pop' for the dummy element % on the op stack suffices. exec pop % See above. } odef [ /.computemediasize /.prepareparams /.selectmedia /.trysetparams /.installpagedevice /.postinstall /.defaultdeviceparams /.makecurrentpagedevice /.mergespecial /.requiredattrs /.applypolicies % /.copytree % /.uninstallpagedevice % (called from C code) ] dup currentdict .undefinternalnames systemdict .undefinternalnames end % level2dict .setlanguagelevel PK l�"\Õ@�J� J� gs_lev2.psnu �[��� % Copyright (C) 2001-2021 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 Level 2 functions. % When this is run, systemdict is still writable, % but (almost) everything defined here goes into level2dict. level2dict begin % ------ System and user parameters ------ % % User parameters must obey save/restore, and must also be maintained % per-context. We implement the former, and some of the latter, here % with PostScript code. NOTE: our implementation assumes that user % parameters change only as a result of setuserparams -- that there are % no user parameters that are ever changed dynamically by the interpreter % (although the interpreter may adjust the value presented to setuserparams) % % There are two types of user parameters: those which are actually % maintained in the interpreter, and those which exist only at the % PostScript level. We maintain the current state of both types in % a read-only local dictionary named userparams, defined in systemdict. % In a multi-context system, each context has its own copy of this % dictionary. In addition, there is a constant dictionary named % psuserparams where each key is the name of a user parameter that exists % only in PostScript and the value is a procedure to check that the value % is legal: setuserparams uses this for checking the values. % setuserparams updates userparams explicitly, in addition to setting % any user parameters in the interpreter; thus we can use userparams % to reset those parameters after a restore or a context switch. % NOTE: the name userparams is known to the interpreter, and in fact % the interpreter creates the userparams dictionary. % Check parameters that are managed at the PostScript level. /.checkparamtype { % <newvalue> <type> .checkparamtype <bool> exch type eq } .bind def /.checksetparams { % <newdict> <opname> <checkdict> % .checksetparams <newdict> 2 .argindex { % Stack: newdict opname checkdict key newvalue 3 copy 3 1 roll .knownget { exec not { pop pop pop load /typecheck signalerror } if dup type /stringtype eq { dup rcheck not { pop pop pop load /invalidaccess signalerror } if } if } { pop } ifelse pop pop } forall pop pop } .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 % PostScript-level parameters to global VM. Currently we have strings % as well as arrays. For arrays, we also need to copy any contents that % are in VM. Also copying string parameters insures the contents won't % be changed. Also be careful to preserve 'executable' state. /.copyparam { % <value> .copyparam <value'> dup type /arraytype eq { .currentglobal //true .setglobal exch dup wcheck exch dup xcheck exch % original attributes dup length array exch dup { % stack: destination_array original_array original_array dup type /arraytype eq { dup 2 index ne { % avoid recursion .copyparam % recurse to handle composite array elements } { % this array self referenced, do it again (yuk!) pop 1 index % get copy of destination array } ifelse } { dup type /stringtype eq { .copyparam } if } ifelse 3 1 roll % keep arrays on top } forall pop astore exch { cvx } if % set executable state exch not { readonly } if % set readonly attribute as original exch .setglobal } if dup type /stringtype eq { dup wcheck exch % save attr for setting readonly .currentglobal //true .setglobal 1 index length string exch .setglobal copy exch not { readonly } if } if } .bind odef % Some user parameters are managed entirely at the PostScript level. % We take care of that here. systemdict begin /psuserparams 48 dict def /getuserparam { % <name> getuserparam <value> /userparams .systemvar 1 .argindex get exch pop } odef % Fill in userparams (created by the interpreter) with current values. mark .currentuserparams counttomark 2 idiv { userparams 3 1 roll put } repeat pop /.definepsuserparam { % <name> <value> .definepsuserparam - psuserparams 3 copy pop type cvlit //.checkparamtype /exec load 3 packedarray cvx put userparams 3 1 roll put } .bind def end /currentuserparams { % - currentuserparams <dict> /userparams .systemvar dup length dict .copydict } odef % We break out setuserparams into a separate procedure so that setvmxxx % can use it without affecting the command in case of an error. /.setuserparams2 { % Check that we will be able to set the PostScript-level % user parameters. /setuserparams /psuserparams .systemvar //.checksetparams exec % Set the C-level user params. If this succeeds, we know that % the password check succeeded. dup .setuserparams % Now set the PostScript-level params. % The interpreter may have adjusted the values of some of the % parameters, so we have to read them back. dup { /userparams .systemvar 2 index known { psuserparams 2 index known not { pop dup .getuserparam } if .copyparam % special protection for the security related parameters [ /PermitFileReading /PermitFileWriting /PermitFileControl ] { 2 index eq { % force all strings to readonly but make sure the % array is in the correct VM space (local/global). currentglobal exch dup gcheck setglobal dup length array exch { readonly exch } forall astore exch setglobal } if } forall % 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 } executeonly forall % A context switch might have occurred during the above loop, % causing the interpreter-level parameters to be reset. % Set them again to the new values. From here on, we are safe, % since a context switch will consult userparams. .setuserparams } .bind executeonly odef % must be bound and hidden for .forceput /setuserparams { % <dict> setuserparams - {.setuserparams2} stopped {/setuserparams load $error /errorname get signalerror} if } .bind odef % Initialize user parameters managed here. /JobName () .definepsuserparam % Restore must restore the user parameters. % (Since userparams is in local VM, save takes care of saving them.) /restore { % <save> restore - //restore /userparams .systemvar .setuserparams } .bind odef % The pssystemparams dictionary holds some system parameters that % are managed entirely at the PostScript level. systemdict begin currentdict /pssystemparams known not { /pssystemparams 40 dict readonly def } if /getsystemparam { % <name> getsystemparam <value> //pssystemparams 1 .argindex .knownget { exch pop } { .getsystemparam } ifelse } odef end /currentsystemparams { % - currentsystemparams <dict> mark .currentsystemparams //pssystemparams { } forall .dicttomark } odef /setsystemparams { % <dict> setsystemparams - % Check that we will be able to set the PostScript-level % system parameters. dup pop % check # of args /SAFETY .systemvar /safe get { % SAFER mode disallows some changes [ /GenericResourceDir /FontResourceDir /GenericResourcePathSep ] { 2 copy .knownget { exch //pssystemparams exch .knownget { ne { /setsystemparams /invalidaccess signalerror } if } { pop } ifelse } { pop } ifelse } forall } if /setsystemparams //pssystemparams mark exch { 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 % Now set the PostScript-level params. We must copy local strings % into global VM. dup { //pssystemparams 2 index known { % Stack: key newvalue .copyparam % 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 } executeonly forall pop } .bind executeonly odef % Initialize the passwords. % NOTE: the names StartJobPassword and SystemParamsPassword are known to % the interpreter, and must be bound to noaccess strings. % The length of these strings must be max_password (iutil2.h) + 1. /StartJobPassword 65 string noaccess def /SystemParamsPassword 65 string noaccess def % Redefine cache parameter setting to interact properly with userparams. /setcachelimit { { mark /MaxFontItem 2 .argindex .dicttomark setuserparams pop } stopped { /setcachelimit .systemvar $error /errorname get signalerror } if } .bind odef /setcacheparams { % The MaxFontCache parameter is a system parameter, which we might % not be able to set. Fortunately, this doesn't matter, because % system parameters don't have to be synchronized between this code % and the VM. counttomark 1 add copy setcacheparams currentcacheparams % mark size lower upper 3 -1 roll pop /MinFontCompress 3 1 roll /MaxFontItem exch .dicttomark { setuserparams cleartomark } stopped { /setcacheparams .systemvar $error /errorname get signalerror } if } .bind odef % Add bogus user and system parameters to satisfy badly written PostScript % programs that incorrectly assume the existence of all the parameters % listed in Appendix C of the Red Book. Note that some of these may become % real parameters later: code near the end of gs_init.ps takes care of % removing any such parameters from ps{user,system}params. % psuserparams /MaxFormItem 100000 .definepsuserparam /MaxPatternItem 20000 .definepsuserparam /MaxScreenItem 48000 .definepsuserparam /MaxUPathItem 0 .definepsuserparam % File Access Permission parameters .currentglobal //true .setglobal /.checkFilePermitparams { type /arraytype eq { currentuserparams /LockFilePermissions get { 5 { pop } repeat /setuserparams /invalidaccess signalerror }{ % in addition to validating the value, ensure the value is read/only dup { readonly exch } forall .currentglobal exch dup gcheck .setglobal length array exch .setglobal astore readonly } ifelse } { 5 { pop } repeat /setuserparams /typecheck signalerror } ifelse //true } .bind def % Initialize the File Permission access control to wide open % These will only be accessed via current/set userparams. % Values are a string containing multiple nul terminated path strings /PermitFileReading dup [ (*) ] .definepsuserparam psuserparams exch /.checkFilePermitparams load put /PermitFileWriting dup [ (*) ] .definepsuserparam psuserparams exch /.checkFilePermitparams load put /PermitFileControl dup [ (*) ] .definepsuserparam psuserparams exch /.checkFilePermitparams load put .setglobal 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. % These procedures take the file and comment string and file as operands. /.checkprocesscomment { dup //null eq { pop //true } { dup xcheck { type dup /arraytype eq exch /packedarraytype eq or } { pop //false } ifelse } ifelse } .bind def /ProcessComment //null .definepsuserparam 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 exec} put /.loadingfont //false def (%ProcessDSCComment) cvn { /ProcessDSCComment getuserparam dup //null eq .loadingfont or { pop pop pop } { exec } ifelse } bind def % ------ Miscellaneous ------ % (<<) cvn % - << -mark- /mark load def % (>> is defined primitively.) /languagelevel 2 def % When running in Level 2 mode, this interpreter is supposed to be % compatible with Adobe version 2017. /version (2017) readonly def % If binary tokens are supported by this interpreter, % set an appropriate default binary object format. /setobjectformat where { pop /RealFormat getsystemparam (IEEE) eq { 1 } { 3 } ifelse /ByteOrder getsystemparam { 1 add } if setobjectformat } if % Aldus Freehand versions 2.x check for the presence of the % setcolor operator, and if it is missing, substitute a procedure. % Unfortunately, the procedure takes different parameters from % the operator. As a result, files produced by this application % cause an error if the setcolor operator is actually defined % and 'bind' is ever used. Aldus fixed this bug in Freehand 3.0, % but there are a lot of files created by the older versions % still floating around. Therefore, at Adobe's suggestion, % we implement the following dreadful hack in the 'where' operator: % If the key is /setcolor, and % there is a dictionary named FreeHandDict, and % currentdict is that dictionary, % then "where" consults only that dictionary and not any other % dictionaries on the dictionary stack. .wheredict /setcolor { /FreeHandDict .where { /FreeHandDict get currentdict eq { pop currentdict /setcolor known { currentdict //true } { //false } ifelse } { .where } ifelse } { .where } ifelse } bind put % ------ Virtual memory ------ % /currentglobal % - currentglobal <bool> /currentshared load def /gcheck % <obj> gcheck <bool> /scheck load def /setglobal % <bool> setglobal - /setshared load def % We can make the global dictionaries very small, because they auto-expand. /globaldict currentdict /shareddict .knownget not { 4 dict } if def /GlobalFontDirectory SharedFontDirectory def % VMReclaim and VMThreshold are user parameters. /setvmthreshold { % <int> setvmthreshold - mark /VMThreshold 2 .argindex .dicttomark {.setuserparams2} stopped {pop /setvmthreshold load $error /errorname get signalerror} {pop} ifelse } odef /vmreclaim { % <int> vmreclaim - dup 0 gt { dup 2 le 1 index type /integertype eq and { pop % ignore user requests for vmreclaim % (reclaim will still happen controlled by vmthreshold) } { .vmreclaim } % let internal operator handle error conditions ifelse } { % VMReclaim userparam controls enable/disable GC mark /VMReclaim 2 index .dicttomark {.setuserparams2} stopped {pop /vmreclaim load $error /errorname get signalerror} {pop} ifelse } ifelse } .bind executeonly odef -1 setvmthreshold % ------ IODevices ------ % /.getdevparams where { pop /currentdevparams { % <iodevice> currentdevparams <dict> .getdevparams .dicttomark } odef } if /.putdevparams where { pop /setdevparams { % <iodevice> <dict> setdevparams - dup type /dicttype ne { /setdevparams .systemvar /typecheck signalerror } if mark 1 index { } forall counttomark 2 add index .putdevparams pop pop } odef } if % ------ Job control ------ % serverdict begin % We could protect the job information better, but we aren't attempting % (currently) to protect ourselves against maliciousness. /.jobsave //null def % top-level save object /.jobsavelevel 0 def % save depth of job (0 if .jobsave is null, % 1 otherwise) /.adminjob //true def % status of current unencapsulated job end % serverdict % Because there may be objects on the e-stack created since the job save, % we have to clear the e-stack before doing the end-of-job restore. % We do this by executing a 2 .stop, which is caught by the 2 .stopped % in .runexec; we leave on the o-stack a procedure to execute aftewards. % %**************** The definition of startjob is not complete yet, since % it doesn't reset stdin/stdout. /.startnewjob { % <exit_bool> <password_level> % .startnewjob - serverdict /.jobsave get dup //null eq { pop } { restore } ifelse exch { % Unencapsulated job serverdict /.jobsave //null put serverdict /.jobsavelevel 0 put serverdict /.adminjob 3 -1 roll 1 gt put } { % Encapsulated job pop serverdict /.jobsave save put serverdict /.jobsavelevel 1 put .userdict /quit { stop } .bind put % CET 28-10 requires a procedure } ifelse % Reset the interpreter state. clear cleardictstack initgraphics //false setglobal } bind executeonly def /.startjob { % <exit_bool> <password> <finish_proc> % .startjob <ok_bool> vmstatus pop pop serverdict /.jobsavelevel get eq 2 .argindex .checkpassword 0 gt and { exch .checkpassword exch count 3 roll count 3 sub { pop } repeat cleardictstack % Reset the e-stack back to the 2 .stopped in .runexec, % passing the finish_proc to be executed afterwards. 2 .stop } { % Password check failed pop pop pop //false } ifelse } odef /startjob { % <exit_bool> <password> startjob <ok_bool> % This is a hack. We really need some way to indicate explicitly % to the interpreter that we are under control of a job server. 1 .argindex type /booleantype ne { /startjob .systemvar /typecheck signalerror } if { .startnewjob //true } .startjob } odef systemdict begin /quit { % - quit - //systemdict begin serverdict /.jobsave get //null eq { end //quit } { /quit .systemvar /invalidaccess /signalerror load end exec } ifelse } bind odef end % We would like to define exitserver as a procedure, using the code % that the Red Book says is equivalent to it. However, since startjob % resets the exec stack, we can't do this, because control would never % proceed past the call on startjob if the exitserver is successful. % Instead, we need to construct exitserver out of pieces of startjob. serverdict begin /exitserver { % <password> exitserver - //true exch { .startnewjob } .startjob not { /exitserver /invalidaccess signalerror } if } bind def end % serverdict % ------ Compatibility ------ % % In Level 2 mode, the following replace the definitions that gs_statd.ps % installs in statusdict and serverdict. % Note that statusdict must be allocated in local VM. % We don't bother with many of these yet. % 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 % The following do not depend on the presence of setpagedevice. /buildtime 1 index /BuildTime get def % Also define /buildtime in systemdict because Adobe does so and some fonts use it as ID systemdict /buildtime dup load put /byteorder 1 index /ByteOrder get def /checkpassword { .checkpassword 0 gt } bind def dup /DoStartPage known { /dostartpage { /DoStartPage getsystemparam } 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 //.pair2dict exec setsystemparams } bind def } if %****** Setting jobname is supposed to set userparams.JobName, too. /jobname { /JobName getuserparam } bind def /jobtimeout { /JobTimeout getuserparam } bind def /ramsize { /RamSize getsystemparam } bind def /realformat 1 index /RealFormat get def dup /PrinterName known { /setprintername { /PrinterName //.pair2dict exec setsystemparams } bind def } if /printername { currentsystemparams /PrinterName .knownget not { () } if exch copy } bind def currentuserparams /WaitTimeout known { /waittimeout { /WaitTimeout getuserparam } bind def } if % The following do require setpagedevice. /.setpagedevice where { pop } { (%END PAGEDEVICE) .skipeof } ifelse /defaulttimeouts { currentsystemparams dup /JobTimeout .knownget not { 0 } if exch /WaitTimeout .knownget not { 0 } if currentpagedevice /ManualFeedTimeout .knownget not { 0 } if } bind def /margins { currentpagedevice /Margins .knownget { exch } { [0 0] } ifelse } bind def /pagemargin { currentpagedevice /PageOffset .knownget { 0 get } { 0 } ifelse } bind def /pageparams { currentpagedevice dup /Orientation .knownget { 1 and ORIENT1 { 1 xor } if } { 0 } ifelse exch dup /PageSize get aload pop 3 index 0 ne { exch } if 3 2 roll /PageOffset .knownget { 0 get } { 0 } ifelse 4 -1 roll } bind def /setdefaulttimeouts { exch mark /ManualFeedTimeout 3 -1 roll /Policies mark /ManualFeedTimeout 1 .dicttomark .dicttomark setpagedevice /WaitTimeout exch mark /JobTimeout 5 2 roll .dicttomark setsystemparams } bind def /setduplexmode { /Duplex //.pair2dict exec setpagedevice } bind def /setmargins { exch 2 array astore /Margins //.pair2dict exec 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 /Orientation 5 -1 roll ORIENT1 { 1 xor } if /PageOffset counttomark 2 add -1 roll 0 2 array astore .dicttomark setpagedevice } bind def /setresolution { count 1 lt { /setresolution /stackunderflow signalerror } if dup type dup /integertype eq exch /realtype eq or not { /setresolution /typecheck signalerror } if dup 2 array astore /HWResolution //.pair2dict exec { setpagedevice } stopped { pop /setresolution $error /errorname get signalerror } if } bind def %END PAGEDEVICE % The following are not implemented yet. %manualfeed %manualfeedtimeout %pagecount %pagestackorder %setpagestackorder % -------- ICC manager -------- % % All color management is going % through ICC flow. We need % to have the default device % spaces gray, RGB and CMYK % defined by ICC profiles //systemdict /ICCProfilesDir .knownget { % Set the directory sepcified by the command line option mark exch /ICCProfilesDir exch .dicttomark .setuserparams2 } { % 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 exec {pop //false} if { pop pop pop pop % current value was OK. Just clean up stack } { % Search for valid (iccprofiles) directory as a sibling to (Resource) % and set it as a default if found. LIBPATH { (Resource) rsearch { exch pop exch pop (iccprofiles) concatstrings .file_name_separator concatstrings dup (default_gray.icc) concatstrings status { pop pop pop pop mark exch /ICCProfilesDir exch .dicttomark .setuserparams2 exit } { pop } ifelse } { pop } ifelse } forall } ifelse % if currentuserparams ICCProfilesDir } ifelse % ICCProfilesDir set in systemdict (command line option) mark % collect dict key value pairs for anything set in systemdict (command line options) [ /DefaultRGBProfile /DefaultGrayProfile /DefaultCMYKProfile /DeviceNProfile /NamedProfile /SourceObjectICC /OverrideICC ] { dup //systemdict exch .knownget not { pop % discard keys not in systemdict } if } forall .dicttomark .setuserparams2 pop % currentsystemparams % Flag the current dictionary so it will be swapped when we % change language levels. (See zmisc2.c for more information.) /statusdict currentdict def currentdict end 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 % resource machinery. /devforall { % <proc> <scratch> devforall - exch { 1 index currentdevparams /Type .knownget { /FileSystem eq } { //false } ifelse { exec } { pop pop } ifelse } /exec load 3 packedarray cvx exch (*) 3 1 roll /IODevice resourceforall } odef /devstatus { % <(%disk*%)> devstatus <searchable> <writable> % <hasNames> <mounted> <removable> <searchOrder> % <freePages> <size> true % <string> devstatus false dup length 5 ge { dup 0 5 getinterval (%disk) eq { dup /IODevice resourcestatus { pop pop dup currentdevparams dup /Searchable get exch dup /Writeable get exch dup /HasNames get exch dup /Mounted get exch dup /Removable get exch dup /SearchOrder get exch dup /Free get exch /LogicalSize get 9 -1 roll pop //true } { pop //false } ifelse } { pop //false } ifelse } { pop //false } ifelse } odef % ------ Color spaces ------ % % gs_res.ps uses these entries in colorspacedict % to populate the ColorSpaceFamily resource, so we need % to add the supported spaces. % systemdict /colorspacedict get begin /CIEBasedA [] def /CIEBasedABC [] def /DevicePixel [] def /Indexed [] def /Pattern [] def /Separation [] def end % ------ CIE color rendering ------ % % Define findcolorrendering and a default ColorRendering ProcSet. /findcolorrendering { % <intentname> findcolorrendering % <crdname> <found> % Adobe interpreters report /findcolorrendering (literal name), not the % operator itself, if an error occurs in findcolorrendering. /findcolorrendering { /ColorRendering /ProcSet findresource 1 .argindex dup type /nametype eq { .namestring } if (.) concatstrings 1 index /GetPageDeviceName get exec dup type /nametype eq { .namestring } if (.) concatstrings 2 index /GetHalftoneName get exec dup type /nametype eq { .namestring } if concatstrings concatstrings cvn % stack: intentname procset crdname dup /ColorRendering resourcestatus { pop pop exch pop exch pop //true } { pop /GetSubstituteCRD get exec //false } ifelse } .errorexec } odef 5 dict dup begin /GetPageDeviceName { % - GetPageDeviceName <name> currentpagedevice dup /PageDeviceName .knownget { exch pop dup //null eq { pop /none } if } { pop /none } ifelse } bind def /GetHalftoneName { % - GetHalftoneName <name> currenthalftone /HalftoneName .knownget not { /none } if } bind def /GetSubstituteCRD { % <intentname> GetSubstituteCRD <crdname> pop /DefaultColorRendering } bind def end % The resource machinery hasn't been activated, so just save the ProcSet % and let .fixresources finish the installation process. /ColorRendering exch def % Define setcolorrendering. /.colorrenderingtypes 5 dict def /setcolorrendering { % <crd> setcolorrendering - dup /ColorRenderingType get dup type /integertype ne { /setcolorrendering .systemvar /typecheck signalerror } if //.colorrenderingtypes exch .knownget { exec } { /setcolorrendering .systemvar /rangecheck signalerror } ifelse } odef /.setcolorrendering1 where { pop } { (%END CRD) .skipeof } ifelse .colorrenderingtypes 1 { % Adobe ProcSet "Adobe_AGM_Core 2.0 0" places an /Intent key into CRD's dup /Intent .knownget { //.renderingintentdict exch .knownget { .setrenderingintent } if } if dup .buildcolorrendering1 .setcolorrendering1 } .bind put % Note: the value 101 in the next line must be the same as the value of % GX_DEVICE_CRD1_TYPE in gscrdp.h. .colorrenderingtypes 101 { dup .builddevicecolorrendering1 .setdevicecolorrendering1 } .bind put % sRGB output CRD, D65 white point mark /ColorRenderingType 1 /RangePQR [ -0.5 2 -0.5 2 -0.5 2 ] readonly % Bradford Cone Space /MatrixPQR [ 0.8951 -0.7502 0.0389 0.2664 1.7135 -0.0685 -0.1614 0.0367 1.0296] readonly /MatrixLMN [ 3.240449 -0.969265 0.055643 -1.537136 1.876011 -0.204026 -0.498531 0.041556 1.057229 ] readonly % Inverse sRGB gamma transform /EncodeABC [ { dup 0.00304 le { 12.92321 mul } { 1 2.4 div exp 1.055 mul 0.055 sub } ifelse } bind dup dup ] readonly /WhitePoint [ 0.9505 1 1.0890 ] readonly % D65 /BlackPoint [ 0 0 0 ] readonly % VonKries-like transform in Bradford Cone Space /TransformPQR % The implementations have been moved to C for performance. [ { .TransformPQR_scale_WB0 } bind { .TransformPQR_scale_WB1 } bind { .TransformPQR_scale_WB2 } bind ] readonly .dicttomark setcolorrendering %END CRD % Initialize a CIEBased color space for sRGB. /CIEsRGB [ /CIEBasedABC mark /DecodeLMN [ { dup 0.03928 le { 12.92321 div } { 0.055 add 1.055 div 2.4 exp } ifelse } bind dup dup ] readonly /MatrixLMN [ 0.412457 0.212673 0.019334 0.357576 0.715152 0.119192 0.180437 0.072175 0.950301 ] readonly /WhitePoint [0.9505 1.0 1.0890] readonly .dicttomark readonly ] readonly def % Special type to install % sRGB ICC profile color space /CIEsRGBICC [ /ICCBased mark /N 3 /DataSource (srgb) /Alternate [/DeviceRGB] /Name (srgb) .dicttomark ] def % Special type to install % sGray ICC profile color space /CIEsGRAYICC [ /ICCBased mark /N 1 /DataSource (sgray) /Alternate [/DeviceGray] /Name (sgray) .dicttomark ] def % Special type to install % e-sRGB ICC profile color space /CIEesRGBICC [ /ICCBased mark /N 3 /DataSource (esrgb) /Alternate [/DeviceRGB] /Name (esrgb) .dicttomark ] def % Special type to install % rommRGB ICC profile color space /CIErommRGBICC [ /ICCBased mark /N 3 /DataSource (rommrgb) /Alternate [/DeviceRGB] /Name (rommrgb) .dicttomark ] def % ------ Painting ------ % % A straightforward definition of execform that doesn't actually % do any caching. /.execform1 { % 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 {matrix currentmatrix exch} if 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 /UNROLLFORMS where {/UNROLLFORMS get}{//false}ifelse not %% [CTM] <<Form>> PaintProc .beginform - { %% First,, check to see if we have no /Implementation already defined (see above) 1 index /Implementation get //null eq { %% We don't, so copy the form dictionary 1 index 4 1 roll %% tell devices we're starting a form, run the PaintProc, and then tell the devices we've finished 3 -1 roll 2 index .beginform exec %% This is all horrible code to deal with illegal forms which leave junk on the operand stack %% Starting from 1 (not 0, we don't want to look at the loop count) and going up to the %% number of objects on the stack, check each object to see if its the Form dict (it is %% *supposed* to be the top object after executing the PaintProc). I don't currently check to see if %% the PaintProc ate the dict, but if there are extra objects, remove them and tell %% the user. %% count 1 1 3 -1 roll { dup index dup type /dicttype eq { /Implementation known { 2 sub 0 1 3 -1 roll { QUIET not { (\n WARNING - Form PaintProc left operands on the stack after execution.\n This is technically illegal and these have been removed, \n if output is incorrect run again with -dUNROLLFORMS.\n) = } if pop pop } for exit }if } { pop pop }ifelse } for .endform %% Ask devices if they have cached the form, and what ID to use if so %% returning -1 means 'no ID' .get_form_id dup -1 eq {pop pop} { %% The form is cached with a specific ID. Make a dictionary (which we'll store in the %% Form dictioanry using the /Implementation key). 1 dict dup /FormID 4 -1 roll put 1 index exch /Implementation exch .forceput readonly pop } executeonly ifelse } { %% We have a (non-null) Implementation, get the dictionary and pull the %% FormID key from it, then tell the device to use the stored form with the %% specified key. pop dup /Implementation get /FormID get .repeatform }ifelse } {exec} ifelse } .bind odef % must bind .forceput /.formtypes 5 dict dup 1 /.execform1 load put def /execform { % <form> execform - gsave { dup /FormType get //.formtypes exch get exec } stopped grestore { stop } if } odef /.patterntypes 5 dict dup 1 /.buildpattern1 load put def /makepattern { % <proto_dict> <matrix> makepattern <pattern> dup type /dicttype eq { % "<dict> makepattern" reports /typecheck on Adobe /makepattern .systemvar /typecheck signalerror } if //.patterntypes 2 .argindex /PatternType get .knownget not { /makepattern .systemvar /rangecheck signalerror } if .currentglobal //false .setglobal exch % Stack: proto matrix global buildproc 3 index dup length 1 add dict .copydict % Stack: proto matrix global buildproc newdict 3 index 3 -1 roll exec % Stack: proto matrix global newdict instance % Create an 'Implementation' entry for the pattern dict. The PRLM 3rd says % this about the contents of Implementation: "The type and value of this % entry are implementation-dependent." The CET (page 2 of 18-02f) expects % that this entry be an array and that the second element of the array be a % gstate. We put our pattern instance struct into the first element of the % array. 1 index /Implementation 3 -1 roll .getCPSImode { gstate } { //null } ifelse 2 array astore put % put Implementation into the pattern dict. % Stack: proto matrix global newdict readonly exch .setglobal exch pop exch pop } odef /setpattern { % [<comp1> ...] <pattern> setpattern - { currentcolorspace 0 get /Pattern ne { [ /Pattern currentcolorspace ] setcolorspace } if setcolor } stopped { /setpattern .systemvar $error /errorname get signalerror } if } odef % The following functions emulate the actions of findcmykcustomcolor and % setcustomcolor. These functions are described in Adobe's TN 5044. That % same document also says "The following "operators" are not defined in the % PostScript Language Reference Manual, but should be used as pseudo-operators % in your PostScript language output. Separation applications from Adobe % Systems and other vendors will redefine these convention operators to % separate your documents. Your application should conditionally define % procedures with these special names, as shown later in this document." % % We are providing these functions because we have found files created by % "QuarkXPress: pictwpstops filter 1.0" which produce bad shading dictionaries % if these operators are not defined. % Also we add a findrgbcustomcolor that was discovered in Adobe Illustrator % AI5 (Adobe Illustrator (R) Version 7.0 Full Prolog) ProcSet that allows % us to create Separation colorspace with a /DeviceRGB tint transform. % Conditionally disable the TN 5044 psuedo-ops if NO_TN5044 specified /NO_TN5044 where { pop (%END TN 5044 psuedo-ops) .skipeof } if % TN 5044 does not define the contents of the array. We are simply putting % the values given into an array. This is consistent with what we see when % testing with Adobe Distiller 6.0. % <cyan> <magenta> <yellow> <black> <key> findcmykcustomcolor <array> /findcmykcustomcolor { 5 array astore } bind executeonly def % The following isn't documented by Adobe, but was found in Adobe Illustrator (R) % Version 7.0 Full Prolog /findrgbcustomcolor { 4 array astore } bind executeonly def % Build a tint transform function for use by setcustomcolor. This function % is for a Separation color space which has either a DeviceCMYK base color space % (i.e. 1 input and 4 outputs) or a DeviceRGB colorspace (1 in, 3 out). % The input to buildcustomtinttransform is the array created by findcmykcustomcolor % and the length of the array is used to determine the alternate colorspace. % The resulting function for CMYK is: % { dup cyan mul exch dup magenta mul exch dup yellow mul exch black mul } % Where cyan, magenta, yellow, and black are values from the array. % For RGB, since the resulting function is: % { dup red mul exch dup green mul exch blue mul } /buildcustomtinttransform % <array> buildcustomtinttransform <function> { dup length 5 eq { % CMYK [ /dup load 2 index 0 get /mul load /exch load /dup load 6 index 1 get /mul load /exch load /dup load 10 index 2 get /mul load /exch load 13 index 3 get /mul load ] } { % RGB is assumed [ /dup load 2 index 0 get /mul load /exch load /dup load 6 index 1 get /mul load /exch load 9 index 2 get /mul load ] } ifelse cvx bind exch pop % Make executable and remove the input array } bind executeonly def % Construct the colorspace array to be used by setcolorspace from the array % result of either findcmykcustomcolor or findrgbcustomcolor. /buildcolorspacearray % <array> buildcustomtinttransform <colorspace_array> { % as with buildcustomtinttransform, the length of the array is used to % determine the alternate colorspace dup length 5 eq { % Start building Separation colorspace with CMYK alternate [ /Separation 2 index 4 get % Get separation name from array's key /DeviceCMYK 4 index //buildcustomtinttransform exec % build the tint transform function ] } { [ /Separation 2 index 3 get % Get separation name from array's key /DeviceRGB 4 index //buildcustomtinttransform exec % build the tint transform function ] } ifelse exch pop % remove the input array } bind executeonly def % Set a custom color based upon a tint and array which describes the custom % color. See findcmykcustomcolor. First we create and then set a Separation % colorspace. Then we set the specified color. % Note that older Adobe ProcSets apparently allow for 'null' as the tint % for some reason, so an alternate operational mode is tolerated: % null setcustomcolor - /setcustomcolor % <array> <tint> setcustomcolor - { dup //null eq { pop pop }{ % Check that the tint is a number between 0 and 1 dup type dup /integertype eq exch /realtype eq or not { /setcustomcolor /typecheck cvx signalerror } if dup 1 le not { /setcustomcolor /rangecheck cvx signalerror } if dup 0 ge not { /setcustomcolor /rangecheck cvx signalerror } if % The array is supposed to be the result of fundcmykcustomcolor. Our % implementation just pushes all the arguments into the array and that's % what buildcolorspacearray expects. So check that now. % Starting with the first N-1 elemenst which must be numbers where 0 <= x <= 1 1 index 0 1 2 index length 2 sub { 1 index exch get dup type dup /integertype eq exch /realtype eq or not { /setcustomcolor /typecheck cvx signalerror } if dup 1 le not { /setcustomcolor /rangecheck cvx signalerror } if 0 ge not { /setcustomcolor /rangecheck cvx signalerror } if } for % Finally, check the last element of the array, which must be a string. dup length 1 sub get type /stringtype eq not { /setcustomcolor /typecheck cvx signalerror } if exch //buildcolorspacearray exec setcolorspace % Set the Separation color space as current setcolor % Set the tint as the current color } ifelse } bind executeonly def % This proc is supposed to implement a version of overprinting. TN 5044 says % that this proc is not used by any shipping host-based application. We have % only found it being used in a proc set in files by Canvas from Deneba Systems. % Even their proc set does not actually do any overprinting. However their % files crash if this is not defined. Thus we have a copy of this proc but % we are simply checking for inputs being -1 and if so then we set the value % to 0. /setcmykoverprint { 4 { dup -1 eq { pop 0 } if 4 1 roll } repeat setcmykcolor } bind def /separation_all [/Separation /All /DeviceCMYK { dup dup dup } bind ] readonly def % Collect the arguments into the image dictionary % <width> <height> <bits/sample> <matrix> <proc> args2dict <dict> /args2dict { 10 dict begin {1 0} 1 { /ImageType /Decode /DataSource /ImageMatrix /BitsPerComponent /Height /Width } { exch def } forall currentdict end } bind def % Prints (1-gray) on all separations. % <gray> setseparationgray - /setseparationgray { //separation_all setcolorspace 1 exch sub setcolor } bind def % Renders an image whose sample values specify the amount of the custom color. % <width> <height> <bits/sample> <matrix> <proc> <array> customcolorimage - /customcolorimage { gsave //buildcolorspacearray exec setcolorspace //args2dict exec image grestore } bind def % Renders an image on all process and custom color plates. % <width> <height> <bits/sample> <matrix> <proc> /separationimage { gsave //separation_all setcolorspace //args2dict exec image grestore } bind def { /buildcustomtinttransform /buildcolorspacearray /separation_all /args2dict } { currentdict exch undef } forall %END TN 5044 psuedo-ops end % level2dict % undefine things defined in this file and not referenced elsewhere [ /.checkprocesscomment /.pair2dict /.setcolorrendering1 /.checkparamtype /.checksetparams ] dup level2dict .undefinternalnames systemdict .undefinternalnames PK l�"\�O�� gs_wan_e.psnu �[��� % Copyright (C) 2001-2021 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. % % Define the WinAnsi encoding vector. /currentglobal where { pop currentglobal { setglobal } //true setglobal } { { } } ifelse /WinAnsiEncoding ISOLatin1Encoding 0 39 getinterval aload pop /quotesingle ISOLatin1Encoding 40 5 getinterval aload pop /hyphen ISOLatin1Encoding 46 50 getinterval aload pop /grave ISOLatin1Encoding 97 30 getinterval aload pop /bullet % \20x % NOTE: /Euro, /Zcaron, and /zcaron are new for PDF 1.3. % We may have to take them out for backward compatibility. /Euro /bullet /quotesinglbase /florin /quotedblbase /ellipsis /dagger /daggerdbl /circumflex /perthousand /Scaron /guilsinglleft /OE /bullet /Zcaron /bullet /bullet /quoteleft /quoteright /quotedblleft /quotedblright /bullet /endash /emdash /tilde /trademark /scaron /guilsinglright /oe /bullet /zcaron /Ydieresis ISOLatin1Encoding 160 96 getinterval aload pop 256 packedarray 4 1 index .registerencoding .defineencoding exec PK l�"\�#l��8 �8 gs_cidfn.psnu �[��� % Copyright (C) 2001-2022 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. % % ProcSet for implementing CIDFont and CIDMap resources. % When this is run, systemdict is still writable. % ---------------- Defining CIDFont resources ---------------- % % Define a CIDFont resource. This is the defineresource implementation for % the CIDFont resource category. /.checkfonttype { % <cidfont> <fonttype> .checkfonttype <cidfont> <new?> 1 index /FID known { 1 index /FontType get ne { /definefont cvx /invalidfont signalerror } if //false } { 1 index /FontType 3 -1 roll put //true } ifelse } bind def /.cidfonttypes where { pop } { /.cidfonttypes 6 dict def } ifelse .cidfonttypes 30 dict begin /.gcompatstringcopy % <string> <global> .gcompatstringcopy <string> { dup 2 index gcheck eq { pop } { currentglobal 3 1 roll setglobal dup length string copy exch setglobal } ifelse } bind def % The key in .cidfonttypes is the CIDFontType value; % the value is a procedure that takes a font name and the CIDFont dictionary % and replaces the latter with a real font. % ------ CIDFontType 0 (FontType 9) ------ % % We add the following entries to the CIDFont dictionary, in addition to % the ones documented by Adobe: % SubrCache - dictionary for caching Subr arrays % For CIDFonts where we read the data from disk incrementally: % GlyphData is 0 (arbitrary) % DataSource - a ReusableStreamDecode filter for the data % We also add a FID entry, and possibly a Subrs entry, to each element of % FDArray. dup 0 { 9 //.checkfonttype exec { /CIDInit /ProcSet findresource begin .completefont9 end } if 1 index exch .buildfont9 .currentresourcefile dup type /filetype eq { //.filename {1 index gcheck //.gcompatstringcopy exec 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) % or for .buildfont9 (FDArray.Private.Subrs). /.completefont9 { % <cidfont0> .completefont9 <cidfont0> currentglobal 3 1 roll dup gcheck setglobal dup /FontMatrix known { dup /FDArray get { dup /FontMatrix get 0 get 1000000 ge { /FontMatrix matrix put % Bug 688517 } { pop } ifelse } forall } { dup /FontMatrix [0.001 0 0 0.001 0 0] put dup /FDArray get { currentglobal exch dup gcheck setglobal dup /FontMatrix get {1000 0 0 1000 0 0} matrix concatmatrix /FontMatrix exch put setglobal } forall } ifelse dup /FDArray get { % Read the Subrs if necessary. dup /Private get dup /Subrs known not { dup /SubrCount .knownget { % Stack: font Private SubrCount currentglobal 3 1 roll 1 index gcheck setglobal array 1 index /Subrs 3 -1 roll put % Stack: font global Private 2 index begin begin .loadsubrs end end setglobal } { pop } ifelse readonly pop } { pop pop } ifelse } forall 3 -1 roll setglobal } bind def % Read some Subrs for the current Type 1 subfont. % The subfont's Private dict is currentdict; the CIDFont itself is the % next dictionary on the stack. /.readsubrs { % <Subrs> <start> .readsubrs <Subrs> 1 SubrCount 1 sub { dup SDBytes mul SubrMapOffset add dup SDBytes .readint exch SDBytes add SDBytes .readint 1 index sub string ReadString 2 index 3 1 roll put } for } bind def % Ensure that all the Subrs for the current Type 1 subfont are loaded. % The subfont's Private dict is currentdict; the CIDFont itself is the % next dictionary on the stack. /.loadsubrs { Subrs length 0 ne { SubrCache SubrMapOffset .knownget { % We've already loaded some Subrs at this offset. % Make sure we've got as many as we need. dup length SubrCount lt { % We need to load more. SubrCount array exch 1 index copy length .readsubrs SubrCache SubrMapOffset 2 index put } if } { % We haven't loaded any Subrs at this offset yet. SubrCount array 0 .readsubrs SubrCache SubrMapOffset 2 index put } ifelse Subrs copy pop } if } bind def % ------ CIDFontType 1 (FontType 10) ------ % dup 1 { 10 //.checkfonttype exec pop 1 index exch .buildfont10 .currentresourcefile dup type /filetype eq { //.filename {1 index gcheck //.gcompatstringcopy exec 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 exec pop 1 index exch .buildfont11 .currentresourcefile dup type /filetype eq { //.filename {1 index gcheck //.gcompatstringcopy exec 1 index exch /ResourcePath exch put} if }{ pop} ifelse exch pop } put % Don't bind it here because gs_fapi.ps redefines .buildfont11 currentdict /.gcompatstringcopy .undef pop % .cidfonttypes % ---------------- Reading CIDFontType 0 files ---------------- % /StartData { % <(Binary)|(Hex)> <datalength> StartData - % (currentdict is CID font dict) % If we're loading a resource file and the data format is % binary, we can just save a pointer to the data and load it % incrementally. mark { % Previous versions of this code made provisions for % reading hex-encoded data incrementally. Since hex data % doesn't seem to be used in practice, we no longer bother. 2 index (Binary) ne { stop } if currentfile .currentresourcefile ne { stop } if % Hack: the pdfwrite driver relies on finalization to write % out fonts. However, the font may be finalized after the % resource file, in which case the resource file will be % closed. So if the current output device is pdfwrite, % don't use incremental loading. /AllowIncrementalCFF /GetDeviceParam .special_op { exch pop {stop}if }if currentfile fileposition } //.internalstopped exec { % File is not positionable, or uses hex data. % Load the data now. cleartomark exch currentfile exch (Hex) eq { /ASCIIHexDecode filter } if exch % Stack: file length dup 65400 le { % readstring with a 0-length string causes a rangecheck, % but a data length of 0 is allowed. string dup () ne { 1 index exch readstring pop } if } { mark 3 1 roll { % Stack: mark str ... file length dup 0 eq { pop exit } if dup 65400 .min dup string 3 index exch readstring pop % Stack: mark str ... file length newstrlen newstr 4 1 roll sub } loop counttomark 1 add 1 roll ] } ifelse /GlyphData exch def dup currentfile eq { pop } { closefile } ifelse } { % File is positionable and binary, just save a pointer. % Stack: (Binary) length -mark- pos /GlyphData 0 def exch pop 3 -1 roll pop exch % Stack: pos length /DataSource currentfile 2 index () .subfiledecode //true .reusablestream def currentfile 3 1 roll add setfileposition } ifelse /SubrCache 10 dict def CIDFontName currentdict /CIDFont defineresource pop end % CID font dict end % resource category dict } bind def % Some Adobe fonts include the line % /Setup /cid_Setup load def % This is apparently included only to prevent proper, conforming PostScript % interpreters (as opposed to ATM or a special Adobe font loader) from % loading the font, since Setup is not referenced anywhere else in the file. /cid_Setup { } def % ------ Generic ------ % % Read a string at a given offset in a "file" (binary file or % GlyphData in RAM). /ReadString { % <pos> <string> ReadString <string> GlyphData 0 eq { % Read from the file. DataSource 3 -1 roll setfileposition DataSource exch readstring pop } { % Read from a string or an array of strings. GlyphData .stringsreadstring } ifelse } bind def /.stringsreadstring % <pos> <string> <strings> .stringsreadstring % <vmstring> { dup type /stringtype eq { 3 1 roll length getinterval } { { % Stack: pos string glyphdata dup 0 get length dup 4 index gt { exit } if 4 -1 roll exch sub 3 1 roll dup length 1 sub 1 exch getinterval } loop % Stack: pos string glyphdata glyphdata[0]length % We know no request can span more than 2 strings. 3 index 3 index length add 1 index le { % Request fits in a single string: just return a substring. pop 0 get 3 1 roll length getinterval } { % Request spans 2 strings. Copy the first part. 1 index 0 get 4 index 3 -1 roll 1 index sub getinterval 2 index copy % Copy the second part. % Stack: pos str glyphdata str1 length exch 1 get 0 3 index length 3 index sub getinterval 2 index 3 1 roll putinterval exch pop } ifelse } ifelse } bind def % Interpret a byte string as a (big-endian) integer. /.cvbsi % <bytes> .cvbsi <int> { 0 exch { exch 8 bitshift add } forall } bind def % Read an integer from binary data. /.readint % <pos> <nbytes> .readint <int> { string ReadString .cvbsi } bind def currentdict end % ---------------- Rendering ---------------- % % ------ CIDFontType 0 ------ % /.readglyphdata { currentfont exch .type9mapcid FDArray exch get exch } bind executeonly def % BuildGlyph procedure for CIDFontType 0. % The name %Type9BuildGlyph is known to the interpreter. /.cid0buildstring 10 string def (%Type9BuildGlyph) cvn { % <cidfont> <cid> %Type9BuildGlyph - .currentglobal 3 1 roll 1 index gcheck .setglobal 1 index begin dup //.readglyphdata exec dup //null eq { % Substitute CID 0. **** WRONG **** pop pop 0 //.readglyphdata exec } if % Stack: cidfont cid subfont charstring dup //null eq { pop pop pop pop } { %**** WRONG **** 4 -1 roll pop 3 1 roll exch dup 4 -1 roll 0 0 moveto 3 index /FontType get 2 eq { .type2execchar } { .type1execchar } ifelse } ifelse %**** WRONG **** end .setglobal } bind executeonly def % ------ CIDFontType 2 ------ % % BuildGlyph procedure for CIDFontType 2. % 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 exec { pop /CharStrings get /.notdef get } if % Stack: cidfont cid glyphindex 1 index exch .type42execchar } bind executeonly def % ---------------- Define resources ---------------- % languagelevel exch 2 .setlanguagelevel % Define the CIDInit ProcSet resource. % The ProcSet dictionary is still on the stack. % We might have loaded CMap support already. However, Adobe's % protected font downloader defines a CIDInit ProcSet that will be % loaded from the filesystem later, so we must check specifically % for the ProcSet being defined in VM. /CIDInit /ProcSet 2 copy resourcestatus { pop 0 eq } { //false } ifelse { pop pop findresource dup length 4 index length add dict .copydict 4 -1 roll exch .copydict } { 3 -1 roll } ifelse exch defineresource pop % Define the CIDFont resource category. % We break out .buildcidfont because it appears that at least for % Type 32 (CIDFontType 4) fonts, the font can be registered in the Font % category with only a CIDFontType and no FontType. /.buildcidfont { % <name> <fontdict> .buildcidfont % <name> <cidfont> systemdict /ProvideUnicode .knownget not { //false } if { /FontEmulationProcs /ProcSet findresource /ProvideUnicodeDecoding get exec } if dup /CIDFontType get //.cidfonttypes exch get exec } bind executeonly odef /CIDFont /Generic /Category findresource dup length dict .copydict dup /InstanceType /dicttype put dup /DefineResource { dup /OrigFont known not { dup dup /OrigFont exch .growput % CPSI does it. Adding just for CET 33_all.PS conformity. } if dup /PaintType known not { dup /PaintType 0 .growput % CPSI does it. Adding just for CET 33_all.PS conformity. } if .buildcidfont /Generic /Category findresource /DefineResource get exec } put % CIDFonts may be defined in CFF OpenType files. % Check for this here. /.loadcidfontresource { dup .ResourceFile { {.loadfont} .execasresource } { dup /undefinedresource signalerror } ifelse } bind def dup /.LoadResource { currentglobal { //.loadcidfontresource exec } { //true setglobal {//.loadcidfontresource exec} stopped //false setglobal {stop} if } ifelse } bind put /Category defineresource pop % Add the new FontType resources. 9 1 11 { dup /FontType defineresource pop } for % Add the new FMapType resource. 9 dup /FMapType defineresource pop % Define the CIDMap resource category. % These aren't documented, but it's clear what they are for: % to give names to CIDMaps for CIDFontType 2 fonts. /CIDMap /Generic /Category findresource dup length dict .copydict dup /.CheckResource { % Allow a string, an array of strings, or (as of Adobe release 3011) % a dictionary. dup type dup dup /stringtype eq exch /dicttype eq or { pop //true } { dup /arraytype eq exch /packedarraytype eq or { //true exch { type /stringtype eq and } forall } { //false } ifelse } ifelse } bind put /Category defineresource pop .setlanguagelevel %% Replace 1 (gs_ciddc.ps) (gs_ciddc.ps) runlibfile % Undef these, not needed outside this file [ /.checkfonttype /.loadcidfontresource /.readglyphdata ] systemdict .undefinternalnames PK l�"\x�m�m m Fontmapnu �[��� %! % See Fontmap.GS for the syntax of real Fontmap files. %% Replace 1 (Fontmap.GS) (Fontmap.GS) .runlibfile PK l�"\����<