~ubuntu-branches/ubuntu/oneiric/ghostscript/oneiric

« back to all changes in this revision

Viewing changes to Resource/Init/gs_lev2.ps

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2011-07-15 16:49:55 UTC
  • mfrom: (1.1.23 upstream)
  • Revision ID: james.westby@ubuntu.com-20110715164955-uga6qibao6kez05c
Tags: 9.04~dfsg~20110715-0ubuntu1
* New upstream release
   - GIT snapshot from Jult, 12 2011.
* debian/patches/020110406~a54df2d.patch,
  debian/patches/020110408~0791cc8.patch,
  debian/patches/020110408~507cbee.patch,
  debian/patches/020110411~4509a49.patch,
  debian/patches/020110412~78bb9a6.patch,
  debian/patches/020110418~a05ab8a.patch,
  debian/patches/020110420~20b6c78.patch,
  debian/patches/020110420~4ddefa2.patch: Removed upstream patches.
* debian/rules: Generate ABI version number (variable "abi") correctly,
  cutting off repackaging and pre-release parts.
* debian/rules: Added ./lcms2/ directory to DEB_UPSTREAM_REPACKAGE_EXCLUDES.
* debian/copyright: Added lcms2/* to the list of excluded files.
* debian/symbols.common: Updated for new upstream source. Applied patch
  which dpkg-gensymbols generated for debian/libgs9.symbols to this file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
%    Copyright (C) 1990, 2000 Aladdin Enterprises.  All rights reserved.
2
 
 
2
%
3
3
% This software is provided AS-IS with no warranty, either express or
4
4
% implied.
5
 
 
5
%
6
6
% This software is distributed under license and may not be copied,
7
7
% modified or distributed except as expressly authorized under the terms
8
8
% of the license contained in the file LICENSE in this distribution.
9
 
 
9
%
10
10
% For more information about licensing, please refer to
11
11
% http://www.ghostscript.com/licensing/. For information on
12
12
% commercial licensing, go to http://www.artifex.com/licensing/ or
13
13
% contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14
14
% San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15
15
 
16
 
% $Id: gs_lev2.ps 12268 2011-03-10 06:19:17Z alexcher $
 
16
% $Id$
17
17
% Initialization file for Level 2 functions.
18
18
% When this is run, systemdict is still writable,
19
19
% but (almost) everything defined here goes into level2dict.
49
49
  exch type eq
50
50
} .bind def
51
51
/.checksetparams {              % <newdict> <opname> <checkdict>
52
 
                                %   .checksetparams <newdict>
 
52
                                %   .checksetparams <newdict>
53
53
  2 .argindex {
54
 
                % Stack: newdict opname checkdict key newvalue
 
54
                % Stack: newdict opname checkdict key newvalue
55
55
    3 copy 3 1 roll .knownget {
56
56
      exec not {
57
 
        pop pop pop load /typecheck signalerror
 
57
        pop pop pop load /typecheck signalerror
58
58
      } if
59
59
      dup type /stringtype eq {
60
 
        dup rcheck not {
61
 
          pop pop pop load /invalidaccess signalerror
62
 
        } if
 
60
        dup rcheck not {
 
61
          pop pop pop load /invalidaccess signalerror
 
62
        } if
63
63
      } if
64
64
    } {
65
65
      pop
75
75
% be changed. Also be careful to preserve 'executable' state.
76
76
/.copyparam {                   % <value> .copyparam <value'>
77
77
  dup type /arraytype eq {
78
 
    .currentglobal //true .setglobal exch 
 
78
    .currentglobal //true .setglobal exch
79
79
    dup wcheck exch dup xcheck exch             % original attributes
80
80
    dup length array exch dup { % stack: destination_array original_array original_array
81
81
      dup type /arraytype eq {
82
 
        dup 2 index ne {        % avoid recursion
 
82
        dup 2 index ne {        % avoid recursion
83
83
          .copyparam    % recurse to handle composite array elements
84
84
        } {
85
 
          % this array self referenced, do it again (yuk!)
86
 
          pop 1 index           % get copy of destination array
87
 
        } ifelse
 
85
          % this array self referenced, do it again (yuk!)
 
86
          pop 1 index           % get copy of destination array
 
87
        } ifelse
88
88
      } {
89
89
        dup type /stringtype eq {
90
 
          .copyparam
91
 
        } if 
 
90
          .copyparam
 
91
        } if
92
92
      }
93
93
      ifelse 3 1 roll           % keep arrays on top
94
94
    } forall pop astore
128
128
% We break out setuserparams into a separate procedure so that setvmxxx
129
129
% can use it without affecting the command in case of an error.
130
130
/.setuserparams2 {
131
 
        % Check that we will be able to set the PostScript-level
132
 
        % user parameters.
 
131
        % Check that we will be able to set the PostScript-level
 
132
        % user parameters.
133
133
  /setuserparams /psuserparams .systemvar .checksetparams
134
 
        % Set the C-level user params.  If this succeeds, we know that
135
 
        % the password check succeeded.
 
134
        % Set the C-level user params.  If this succeeds, we know that
 
135
        % the password check succeeded.
136
136
  dup .setuserparams
137
 
        % Now set the PostScript-level params.
138
 
        % The interpreter may have adjusted the values of some of the
139
 
        % parameters, so we have to read them back.
 
137
        % Now set the PostScript-level params.
 
138
        % The interpreter may have adjusted the values of some of the
 
139
        % parameters, so we have to read them back.
140
140
  dup {
141
141
    /userparams .systemvar 2 index known {
142
142
      psuserparams 2 index known not {
143
 
        pop dup .getuserparam
 
143
        pop dup .getuserparam
144
144
      } if
145
145
      .copyparam
146
146
      % special protection for the security related parameters
147
147
      [ /PermitFileReading /PermitFileWriting /PermitFileControl ]
148
148
      { 2 index eq { % force all strings to readonly but make sure the
149
 
                     % array is in the correct VM space (local/global).
150
 
        currentglobal exch dup gcheck setglobal
151
 
        dup length array exch { readonly exch } forall astore
152
 
        exch setglobal
 
149
                     % array is in the correct VM space (local/global).
 
150
        currentglobal exch dup gcheck setglobal
 
151
        dup length array exch { readonly exch } forall astore
 
152
        exch setglobal
153
153
        } if
154
154
      } forall
155
155
      % protect top level of parameters that we copied
159
159
      pop pop
160
160
    } ifelse
161
161
  } forall
162
 
        % A context switch might have occurred during the above loop,
163
 
        % causing the interpreter-level parameters to be reset.
164
 
        % Set them again to the new values.  From here on, we are safe,
165
 
        % since a context switch will consult userparams.
 
162
        % A context switch might have occurred during the above loop,
 
163
        % causing the interpreter-level parameters to be reset.
 
164
        % Set them again to the new values.  From here on, we are safe,
 
165
        % since a context switch will consult userparams.
166
166
  .setuserparams
167
167
} .bind def
168
168
/setuserparams {                % <dict> setuserparams -
191
191
  mark .currentsystemparams //pssystemparams { } forall .dicttomark
192
192
} odef
193
193
/setsystemparams {              % <dict> setsystemparams -
194
 
        % Check that we will be able to set the PostScript-level
195
 
        % system parameters.
 
194
        % Check that we will be able to set the PostScript-level
 
195
        % system parameters.
196
196
   dup pop              % check # of args
197
197
   /SAFETY .systemvar /safe get {
198
198
     % SAFER mode disallows some changes
199
199
     [ /GenericResourceDir /FontResourceDir /GenericResourcePathSep ] {
200
200
       2 copy .knownget {
201
 
         exch //pssystemparams exch .knownget {
 
201
         exch //pssystemparams exch .knownget {
202
202
           ne { /setsystemparams /invalidaccess signalerror } if
203
203
         } {
204
204
           pop
211
211
   /setsystemparams //pssystemparams mark exch {
212
212
     type cvlit /.checkparamtype cvx 2 packedarray cvx
213
213
   } forall .dicttomark .checksetparams
214
 
        % Set the C-level system params.  If this succeeds, we know that
215
 
        % the password check succeeded.
 
214
        % Set the C-level system params.  If this succeeds, we know that
 
215
        % the password check succeeded.
216
216
   dup .setsystemparams
217
 
        % Now set the PostScript-level params.  We must copy local strings
218
 
        % into global VM.
 
217
        % Now set the PostScript-level params.  We must copy local strings
 
218
        % into global VM.
219
219
   dup
220
220
    { //pssystemparams 2 index known
221
221
       {                % Stack: key newvalue
222
 
         .copyparam
223
 
         % protect top level parameters that we copied
 
222
         .copyparam
 
223
         % protect top level parameters that we copied
224
224
         dup type dup /arraytype eq exch /stringtype eq or { readonly } if
225
 
         //pssystemparams 3 1 roll .forceput    % pssystemparams is read-only
 
225
         //pssystemparams 3 1 roll .forceput    % pssystemparams is read-only
226
226
       }
227
227
       { pop pop
228
228
       }
246
246
    } if
247
247
} .bind odef
248
248
/setcacheparams {
249
 
        % The MaxFontCache parameter is a system parameter, which we might
250
 
        % not be able to set.  Fortunately, this doesn't matter, because
251
 
        % system parameters don't have to be synchronized between this code
252
 
        % and the VM.
 
249
        % The MaxFontCache parameter is a system parameter, which we might
 
250
        % not be able to set.  Fortunately, this doesn't matter, because
 
251
        % system parameters don't have to be synchronized between this code
 
252
        % and the VM.
253
253
  counttomark 1 add copy setcacheparams
254
254
  currentcacheparams    % mark size lower upper
255
255
    3 -1 roll pop
282
282
        % in addition to validating the value, ensure the value is read/only
283
283
        dup { readonly exch } forall
284
284
        .currentglobal exch dup gcheck .setglobal length array exch .setglobal
285
 
        astore readonly
 
285
        astore readonly
286
286
      }
287
287
      ifelse
288
288
    } {
450
450
 
451
451
/.jobsave //null def            % top-level save object
452
452
/.jobsavelevel 0 def            % save depth of job (0 if .jobsave is null,
453
 
                                % 1 otherwise)
 
453
                                % 1 otherwise)
454
454
/.adminjob //true def           % status of current unencapsulated job
455
455
 
456
456
end             % serverdict
463
463
%**************** The definition of startjob is not complete yet, since
464
464
% it doesn't reset stdin/stdout.
465
465
/.startnewjob {                 % <exit_bool> <password_level>
466
 
                                %   .startnewjob -
 
466
                                %   .startnewjob -
467
467
    serverdict /.jobsave get dup //null eq { pop } { restore } ifelse
468
468
    exch {
469
 
                        % Unencapsulated job
 
469
                        % Unencapsulated job
470
470
      serverdict /.jobsave //null put
471
471
      serverdict /.jobsavelevel 0 put
472
472
      serverdict /.adminjob 3 -1 roll 1 gt put
473
473
    } {
474
 
                        % Encapsulated job
 
474
                        % Encapsulated job
475
475
      pop
476
476
      serverdict /.jobsave save put
477
477
      serverdict /.jobsavelevel 1 put
478
478
      .userdict /quit { stop } .bind put  % CET 28-10 requires a procedure
479
479
    } ifelse
480
 
                % Reset the interpreter state.
 
480
                % Reset the interpreter state.
481
481
  clear cleardictstack
482
482
  initgraphics
483
483
  //false setglobal
484
484
  2 vmreclaim   % Make sure GC'ed memory is reclaimed and freed.
485
485
} bind def
486
486
/.startjob {                    % <exit_bool> <password> <finish_proc>
487
 
                                %   .startjob <ok_bool>
 
487
                                %   .startjob <ok_bool>
488
488
  vmstatus pop pop serverdict /.jobsavelevel get eq
489
489
  2 .argindex .checkpassword 0 gt and {
490
490
    exch .checkpassword exch count 3 roll count 3 sub { pop } repeat
491
491
    cleardictstack
492
 
                % Reset the e-stack back to the 2 .stopped in .runexec,
493
 
                % passing the finish_proc to be executed afterwards.
 
492
                % Reset the e-stack back to the 2 .stopped in .runexec,
 
493
                % passing the finish_proc to be executed afterwards.
494
494
    2 .stop
495
495
  } {           % Password check failed
496
496
    pop pop pop //false
497
497
  } ifelse
498
498
} odef
499
499
/startjob {                     % <exit_bool> <password> startjob <ok_bool>
500
 
        % This is a hack.  We really need some way to indicate explicitly
501
 
        % to the interpreter that we are under control of a job server.
 
500
        % This is a hack.  We really need some way to indicate explicitly
 
501
        % to the interpreter that we are under control of a job server.
502
502
  1 .argindex type /booleantype ne {
503
503
    /startjob .systemvar /typecheck signalerror
504
504
  } if
505
505
  { .startnewjob //true } .startjob
506
506
} odef
507
507
 
508
 
% The procedure to undo the job encapsulation 
 
508
% The procedure to undo the job encapsulation
509
509
/.endjob {
510
510
  clear cleardictstack
511
511
  serverdict /.jobsave get dup //null eq { pop } { restore } ifelse
630
630
%pagestackorder
631
631
%setpagestackorder
632
632
 
633
 
 
634
633
% -------- ICC manager -------- %
635
634
% All color management is going
636
635
% through ICC flow.  We need
646
645
  mark .currentuserparams .dicttomark /ICCProfilesDir get
647
646
  (default_gray.icc) concatstrings status {
648
647
    pop pop pop pop             % current value was OK. Just clean up stack
649
 
  } { 
 
648
  } {
650
649
    % Search for valid (iccprofiles) directory as a sibling to (Resource)
651
650
    % and set it as a default if found.
652
 
    LIBPATH { 
 
651
    LIBPATH {
653
652
      (Resource) search {
654
653
        exch pop exch pop (iccprofiles) concatstrings
655
654
        .file_name_separator concatstrings
702
701
.setuserparams
703
702
} if
704
703
 
 
704
//systemdict /SourceObjectICC .knownget{
 
705
mark exch /SourceObjectICC exch .dicttomark
 
706
.setuserparams
 
707
} if
 
708
 
 
709
//systemdict /OverrideICC .knownget{
 
710
mark exch /OverrideICC exch .dicttomark
 
711
.setuserparams
 
712
} if
 
713
 
 
714
//systemdict /OverrideRI .knownget{
 
715
mark exch /OverrideRI exch .dicttomark
 
716
.setuserparams
 
717
} if
 
718
 
705
719
pop             % currentsystemparams
706
720
 
707
721
% Flag the current dictionary so it will be swapped when we
724
738
  (*) 3 1 roll /IODevice resourceforall
725
739
} odef
726
740
/devstatus {            % <(%disk*%)> devstatus <searchable> <writable>
727
 
                        %   <hasNames> <mounted> <removable> <searchOrder>
728
 
                        %   <freePages> <size> true
729
 
                        % <string> devstatus false
 
741
                        %   <hasNames> <mounted> <removable> <searchOrder>
 
742
                        %   <freePages> <size> true
 
743
                        % <string> devstatus false
730
744
  dup length 5 ge {
731
745
    dup 0 5 getinterval (%disk) eq {
732
746
      dup /IODevice resourcestatus {
733
 
        pop pop dup currentdevparams
734
 
        dup /Searchable get
735
 
        exch dup /Writeable get
736
 
        exch dup /HasNames get
737
 
        exch dup /Mounted get
738
 
        exch dup /Removable get
739
 
        exch dup /SearchOrder get
740
 
        exch dup /Free get
741
 
        exch /LogicalSize get
742
 
        9 -1 roll pop //true
 
747
        pop pop dup currentdevparams
 
748
        dup /Searchable get
 
749
        exch dup /Writeable get
 
750
        exch dup /HasNames get
 
751
        exch dup /Mounted get
 
752
        exch dup /Removable get
 
753
        exch dup /SearchOrder get
 
754
        exch dup /Free get
 
755
        exch /LogicalSize get
 
756
        9 -1 roll pop //true
743
757
      } {
744
 
        pop //false
 
758
        pop //false
745
759
      } ifelse
746
760
    } {
747
761
      pop //false
765
779
/Separation [] def
766
780
end
767
781
 
768
 
 
769
 
 
770
782
% ------ CIE color rendering ------ %
771
783
 
772
784
% Define findcolorrendering and a default ColorRendering ProcSet.
773
785
 
774
786
/findcolorrendering {           % <intentname> findcolorrendering
775
 
                                %   <crdname> <found>
 
787
                                %   <crdname> <found>
776
788
    % Adobe interpreters report /findcolorrendering (literal name), not the
777
789
    % operator itself, if an error occurs in findcolorrendering.
778
790
    /findcolorrendering {
779
 
        /ColorRendering /ProcSet findresource
780
 
        1 .argindex dup type /nametype eq { .namestring } if (.) concatstrings
781
 
        1 index /GetPageDeviceName get exec dup type /nametype eq { .namestring } if (.) concatstrings
782
 
        2 index /GetHalftoneName get exec dup type /nametype eq { .namestring } if
783
 
        concatstrings concatstrings cvn % stack: intentname procset crdname
784
 
        dup /ColorRendering resourcestatus {
785
 
            pop pop exch pop exch pop //true
786
 
        } {
787
 
            pop /GetSubstituteCRD get exec //false
788
 
        } ifelse
 
791
        /ColorRendering /ProcSet findresource
 
792
        1 .argindex dup type /nametype eq { .namestring } if (.) concatstrings
 
793
        1 index /GetPageDeviceName get exec dup type /nametype eq { .namestring } if (.) concatstrings
 
794
        2 index /GetHalftoneName get exec dup type /nametype eq { .namestring } if
 
795
        concatstrings concatstrings cvn % stack: intentname procset crdname
 
796
        dup /ColorRendering resourcestatus {
 
797
            pop pop exch pop exch pop //true
 
798
        } {
 
799
            pop /GetSubstituteCRD get exec //false
 
800
        } ifelse
789
801
    } .errorexec
790
802
} odef
791
803
 
822
834
    /setcolorrendering .systemvar /typecheck signalerror
823
835
  } if
824
836
  //.colorrenderingtypes exch .knownget {
825
 
     exec 
 
837
     exec
826
838
  } {
827
839
    /setcolorrendering .systemvar /rangecheck signalerror
828
840
  } ifelse
831
843
/.setcolorrendering1 where { pop } { (%END CRD) .skipeof } ifelse
832
844
 
833
845
.colorrenderingtypes 1 {
834
 
  % Adobe ProcSet "Adobe_AGM_Core 2.0 0" places an /Intent key into CRD's 
 
846
  % Adobe ProcSet "Adobe_AGM_Core 2.0 0" places an /Intent key into CRD's
835
847
  dup /Intent .knownget {
836
848
    //.renderingintentdict exch .knownget { .setrenderingintent } if
837
849
  } if
851
863
 
852
864
% Bradford Cone Space
853
865
/MatrixPQR [ 0.8951 -0.7502  0.0389
854
 
             0.2664  1.7135 -0.0685
855
 
            -0.1614  0.0367  1.0296] readonly
 
866
             0.2664  1.7135 -0.0685
 
867
            -0.1614  0.0367  1.0296] readonly
856
868
 
857
869
/MatrixLMN [ 3.240449 -0.969265  0.055643
858
 
            -1.537136  1.876011 -0.204026
859
 
            -0.498531  0.041556  1.057229 ] readonly
 
870
            -1.537136  1.876011 -0.204026
 
871
            -0.498531  0.041556  1.057229 ] readonly
860
872
 
861
873
% Inverse sRGB gamma transform
862
874
/EncodeABC [ { dup 0.00304 le
873
885
   /TransformPQR
874
886
     % The implementations have been moved to C for performance.
875
887
     [ { .TransformPQR_scale_WB0 } bind
876
 
       { .TransformPQR_scale_WB1 } bind 
 
888
       { .TransformPQR_scale_WB1 } bind
877
889
       { .TransformPQR_scale_WB2 } bind
878
890
     ] readonly
879
891
.dicttomark setcolorrendering
895
907
  .dicttomark readonly
896
908
] readonly def
897
909
 
898
 
 
899
910
% Special type to install
900
911
% sRGB ICC profile color space
901
912
/CIEsRGBICC [ /ICCBased
902
913
  mark
903
 
    /N 3 
 
914
    /N 3
904
915
    /DataSource (srgb)
905
916
    /Alternate [/DeviceRGB]
906
 
    /Name (srgb) 
907
 
  .dicttomark 
 
917
    /Name (srgb)
 
918
  .dicttomark
908
919
] def
909
920
 
910
921
% Special type to install
911
922
% sGray ICC profile color space
912
923
/CIEsGRAYICC [ /ICCBased
913
924
  mark
914
 
    /N 1 
 
925
    /N 1
915
926
    /DataSource (sgray)
916
927
    /Alternate [/DeviceGray]
917
 
    /Name (sgray) 
918
 
  .dicttomark 
 
928
    /Name (sgray)
 
929
  .dicttomark
919
930
] def
920
931
 
921
932
% ------ Painting ------ %
923
934
% A straightforward definition of execform that doesn't actually
924
935
% do any caching.
925
936
/.execform1 {
926
 
        % This is a separate operator so that the stacks will be restored
927
 
        % properly if an error occurs.
 
937
        % This is a separate operator so that the stacks will be restored
 
938
        % properly if an error occurs.
928
939
  dup /Matrix get concat
929
940
  dup /BBox get aload pop
930
941
  exch 3 index sub exch 2 index sub rectclip
958
969
      /makepattern .systemvar /rangecheck signalerror
959
970
  } if
960
971
  .currentglobal //false .setglobal exch
961
 
                % Stack: proto matrix global buildproc
 
972
                % Stack: proto matrix global buildproc
962
973
  3 index dup length 1 add dict .copydict
963
 
                % Stack: proto matrix global buildproc newdict
 
974
                % Stack: proto matrix global buildproc newdict
964
975
  3 index 3 -1 roll exec
965
 
                % Stack: proto matrix global newdict instance
 
976
                % Stack: proto matrix global newdict instance
966
977
  % Create an 'Implementation' entry for the pattern dict.  The PRLM 3rd says
967
978
  % this about the contents of Implementation:  "The type and value of this
968
979
  % entry are implementation-dependent."  The CET (page 2 of 18-02f) expects
972
983
  1 index /Implementation 3 -1 roll
973
984
  .getCPSImode { gstate } { //null } ifelse 2 array astore
974
985
  put                           % put Implementation into the pattern dict.
975
 
                % Stack: proto matrix global newdict
 
986
                % Stack: proto matrix global newdict
976
987
  readonly exch .setglobal exch pop exch pop
977
988
} odef
978
989
 
996
1007
%
997
1008
% We are providing these functions because we have found files created by
998
1009
% "QuarkXPress: pictwpstops filter 1.0" which produce bad shading dictionaries
999
 
% if these operators are not defined. 
 
1010
% if these operators are not defined.
1000
1011
 
1001
1012
% Conditionally disable the TN 5044 psuedo-ops if NO_TN5044 specified
1002
1013
/NO_TN5044 where { pop (%END TN 5044 psuedo-ops) .skipeof } if