| 1 |
% Copyright (C) 2001-2023 Artifex Software, Inc. |
| 2 |
% All Rights Reserved. |
| 3 |
% |
| 4 |
% This software is provided AS-IS with no warranty, either express or |
| 5 |
% implied. |
| 6 |
% |
| 7 |
% This software is distributed under license and may not be copied, |
| 8 |
% modified or distributed except as expressly authorized under the terms |
| 9 |
% of the license contained in the file LICENSE in this distribution. |
| 10 |
% |
| 11 |
% Refer to licensing information at http://www.artifex.com or contact |
| 12 |
% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, |
| 13 |
% CA 94129, USA, for further information. |
| 14 |
% |
| 15 |
|
| 16 |
% basic colorspace mechanism |
| 17 |
|
| 18 |
% |
| 19 |
% There have been some major changes to the PostScript colour handling. |
| 20 |
% In particular, the vast majority of the colour space code has been |
| 21 |
% converted from PostScript to C. This file has been extensively |
| 22 |
% modified, as has gs_icc.ps. The remaining PostScript files which |
| 23 |
% previously implemented colour space handling; gs_ciecs2.ps, gs_ciecs3.ps |
| 24 |
% gs_devcs.ps, gs_devn.ps, gs_devpxl.ps, gs_indxd.ps, gs_patrn.ps and |
| 25 |
% gs_sepr.ps have been superceded by the C code and removed. |
| 26 |
% |
| 27 |
% gs_lev2.ps and gs_ll3.ps have also been modified so that they no longer |
| 28 |
% attempt to execute these PostScript files. |
| 29 |
% |
| 30 |
.currentglobal //true .setglobal |
| 31 |
systemdict begin |
| 32 |
|
| 33 |
% |
| 34 |
% gs_res.ps, and possibly other files, use this dictionary. Formerly |
| 35 |
% in cspace_util, moved to systemdict. |
| 36 |
% |
| 37 |
20 dict dup /colorspacedict exch def |
| 38 |
|
| 39 |
begin % colorspacedict |
| 40 |
|
| 41 |
% |
| 42 |
% gs_res.ps uses these entries in colorspacedict |
| 43 |
% to populate the ColorSpaceFamily resource, so we need |
| 44 |
% to add the supported spaces. |
| 45 |
% |
| 46 |
/DeviceGray [] def |
| 47 |
/DeviceRGB [] def |
| 48 |
/DeviceCMYK [] def |
| 49 |
end % colorspacedict |
| 50 |
|
| 51 |
% |
| 52 |
% Global, read-only, unpacked, array-form device color spaces |
| 53 |
% We need to return an array argument in response to currentcolorspace |
| 54 |
% even if the argument presented to setcolorspace was a simple device |
| 55 |
% space name. Not only that, but in order to satisfy some Adobe |
| 56 |
% applications, it must be the *same* array every time. The only way |
| 57 |
% to do that is to define an appropriate set initial arrays and always return |
| 58 |
% one of those. These arrays are defined here. |
| 59 |
% |
| 60 |
/DeviceGray_array /DeviceGray 1 array astore readonly def |
| 61 |
/DeviceRGB_array /DeviceRGB 1 array astore readonly def |
| 62 |
/DeviceCMYK_array /DeviceCMYK 1 array astore readonly def |
| 63 |
|
| 64 |
% |
| 65 |
% These routines used for the NOSUBSTDEVICECOLORS switch. This prevents |
| 66 |
% substitution of DeviceGray, DeviceRGB and DeviceCMYK with a Default* |
| 67 |
% colour space when /UseCIEColors is true. If the job includes a |
| 68 |
% definition of /DefaltGray, DefaultRGB or DefaultCMYK then it also executes |
| 69 |
% .includecolorspace to allow the device to record the substitute space. |
| 70 |
% |
| 71 |
/..page_default_spaces 3 dict def |
| 72 |
|
| 73 |
% |
| 74 |
% Used internally to retrieve any relevant default colour space. |
| 75 |
% |
| 76 |
% <Default space name> ..nosubstdevicetest false |
| 77 |
% <Default space name> [space] true |
| 78 |
% |
| 79 |
% If the boolean is true then the C code must set the additional colour space |
| 80 |
% and execute .includecolorspace before finally setting a DeviceGray space. |
| 81 |
% |
| 82 |
% called from C code, can't undef. Use this to trigger the code: |
| 83 |
% -sDEVICE=pkmraw -dMaxBitmap=4000m -r72 -dNOSUBSTDEVICECOLORS ./tests/Ghent_V3.0/110_defaultcolourspace_x3.pdf |
| 84 |
/..nosubstdevicetest |
| 85 |
{ |
| 86 |
//false mark 3 -1 roll |
| 87 |
% If we have already recorded this space, don't repeat it. |
| 88 |
systemdict /..page_default_spaces get 1 index known { |
| 89 |
cleartomark |
| 90 |
} { |
| 91 |
{ |
| 92 |
% Check to see if this space was defined by defineresource, if so then |
| 93 |
% the job defined it, otherwise its the usual default, so ignore it. |
| 94 |
dup /ColorSpace resourcestatus { |
| 95 |
pop 0 eq { |
| 96 |
% Default* defined by defineresource |
| 97 |
systemdict /..page_default_spaces get 1 index //true put |
| 98 |
dup /ColorSpace findresource 4 2 roll pop pop //true |
| 99 |
}{ |
| 100 |
cleartomark |
| 101 |
} ifelse |
| 102 |
}{ |
| 103 |
cleartomark |
| 104 |
} ifelse |
| 105 |
} stopped |
| 106 |
{cleartomark}if |
| 107 |
} ifelse |
| 108 |
}.internalbind def |
| 109 |
|
| 110 |
end |
| 111 |
|
| 112 |
% |
| 113 |
% Set the initial device space |
| 114 |
% |
| 115 |
systemdict /DeviceGray_array get setcolorspace |
| 116 |
|
| 117 |
.setglobal |