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.

111 lines
3.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. % We need LanguageLevel 2 or higher in order to have setuserparams and
  16. % << >> dictionaries
  17. languagelevel dup 2 .max .setlanguagelevel
  18. % ICCBased color space method dictionaries.
  19. % This assumes gs_ciecs2.ps has already been processed.
  20. .currentglobal //true .setglobal
  21. % gs_res.ps uses these entries in colorspacedict
  22. % to populate the ColorSpaceFamily resource, so we need
  23. % to add the supported spaces.
  24. %
  25. systemdict /colorspacedict get begin
  26. /ICCBased [] def
  27. end
  28. NOPSICC { (%END PSICC) .skipeof } if
  29. % Now set up ICC profile loading for PostScript %%BeginICCProfile sections.
  30. /cs-sig-dict <<
  31. (XYZ ) 3
  32. (Lab ) 3
  33. (Luv ) 3
  34. (YCbr) 3
  35. (Yxy ) 3
  36. (RGB ) 3
  37. (GRAY) 1
  38. (HSV ) 3
  39. (HLS ) 3
  40. (CMYK) 4
  41. (CMY ) 3
  42. >> readonly def
  43. systemdict begin
  44. /.ProcessICCcomment { % file comment -- file comment
  45. dup
  46. (%%BeginICCProfile) anchorsearch {
  47. pop pop
  48. DEBUG { (.ProcessICCcomment found %%BeginICCProfile) print flush } if
  49. % load an ICC profile defined as comments (hex encoded).
  50. % Ends with %%End at the start of a line. Read the data into
  51. % an array of strings. This string can be used directly as a
  52. % source for ReusableStreamDecode filter.
  53. %
  54. % stack: --file-- (%%BeginICCProfile: ...)
  55. 1 index 0 (%%EndICCProfile) /SubFileDecode filter
  56. [ { counttomark 1 add index
  57. 64000 string readhexstring
  58. not { exit } if
  59. } loop
  60. ] exch closefile
  61. % make a seekable -file- out of the string array
  62. mark /AsyncRead //true .dicttomark /ReusableStreamDecode filter
  63. % stack: --file-- (%%BeginICCProfile: ...) --icc_subfile--
  64. dup 16 setfileposition
  65. dup (1234) readstring pop
  66. 1 index 0 setfileposition
  67. //cs-sig-dict exch .knownget {
  68. 3 dict begin
  69. /Alternate {0 /DeviceGray 0 /DeviceRGB /DeviceCMYK } 2 index get def
  70. /N exch def
  71. /DataSource exch def
  72. [/ICCBased currentdict]
  73. end
  74. { setcolorspace } stopped {
  75. pop
  76. QUIET not { ( *** Unable to load ICC profile from PostScript DSC comments ***) = flush } if
  77. } if
  78. } {
  79. pop
  80. } ifelse
  81. } {
  82. pop % Not interested in this DSC comment
  83. } ifelse
  84. } .internalbind def
  85. currentdict /cs-sig-dict undef
  86. % Merge ProcessICCcomment with existing handler
  87. /.ProcessICCcomment load /exec load
  88. currentuserparams /ProcessDSCComment get
  89. dup //null eq {pop {pop pop}} if /exec load
  90. 4 array astore cvx readonly
  91. << /ProcessDSCComment 3 -1 roll >> setuserparams
  92. currentdict /.ProcessICCcomment .undef
  93. end % systemdict
  94. %END PSICC
  95. .setglobal
  96. .setlanguagelevel