You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
4.0 KiB

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