~ubuntu-branches/ubuntu/precise/ghostscript/precise-security

« back to all changes in this revision

Viewing changes to Resource/Init/pdf_ops.ps

  • Committer: Package Import Robot
  • Author(s): Till Kamppeter
  • Date: 2012-01-25 21:22:59 UTC
  • mfrom: (1.1.28)
  • Revision ID: package-import@ubuntu.com-20120125212259-5zxmix6e1b2wkvlp
Tags: 9.05~dfsg~20120125-0ubuntu1
* New upstream release
   - GIT snapshot from January, 25 2012.
   - Snapshot close before GS 9.05 upstream release to test for last bugs\
     before the release.
* debian/patches/020110812~46b4ee6-pxl-landscape.patch,
  debian/patches/020110812~d9e044e-lips4v-fix.patch,
  debian/patches/020110815-05b517b-gdevcups-c-eliminate-compiler-warning.patch,
  debian/patches/020110815-1920f21-cups-raster-set-default-color-profiles.patch,
  debian/patches/020110815-eb6b631-cups-raster-generate-cups-rgbw.patch,
  debian/patches/020110816-781b738-cups-raster-fix-segfaults-on-color-model-change.patch,
  debian/patches/020110816-d8da050-cups-raster-improve-black-recognition-on-cmyk-to-rgbw.patch,
  debian/patches/020110817-766df64-cups-raster-suppress-warnings.patch,
  debian/patches/020110819~fa67a1d.patch,
  debian/patches/020110923-5688545-fix-setting-the-iccprofilesdir-userparam.patch,
  debian/patches/020110923-7e048c5-dont-crash-when-not-finding-icc-profile.patch,
  debian/patches/020111005-d5f1e72-clist-fix-for-rgbw-color-mode.patch,
  debian/patches/020111114-4258227-lzw-encode-filter-fix.patch,
  debian/patches/029111114-08dc129-ps2write-truetype-fix.patch,
  debian/patches/020111122-5cce070-ps2write-postscript-duplex-command-insertion.patch,
  debian/patches/020111122-cd8f397-ps2write-fix-handling-of-format-4-cmap-subtables-in-truetype-fonts.patch,
  debian/patches/020111125-979f218-ps2write-fix-conversion-of-escaped-string-to-hex-string.patch,
  debian/patches/020111209-5359a2d-do-not-use-hexadecimal-names-for-type42-charstrings-and-encoding.patch: Removed upstream patches.
* debian/patches/1001_autoconfigure_cms_choice.patch: Removed, build system
  is appropriately approved by upstream.
* debian/rules: linked base/configure.ac and base/Makefile.in to package
  root directory so that the autotools find them (needed on GIT snapshots).
* debian/rules, debian/control: Removed build dependency on liblcms1-dev,
  icc34.h is shipped with Ghostscript now.
* debian/rules: Added ./icclib/ and ./openjpeg/ directories to
  DEB_UPSTREAM_REPACKAGE_EXCLUDES and removed the files in Resource/CMap/
  (they are free now).
* debian/copyright: Added icclib/* and openjpeg/* to the list of excluded
  files. Updated entries for the files in Resource/CMap/. Updated for renaming
  cups/psto* to cups/gsto*.
* debian/symbols.common: Updated for new upstream source. Applied patch
  which dpkg-gensymbols generated for debian/libgs9.symbols to this file.
* Merge from Debian testing, remaining changes (recover after accidental sync
  in previous (upload):
  - debian/control:
    + Keep gs-common with dependency on ghostscript, still too many
      packages assuming gs-common has the binaries.
    + Really break and replace older ghostscript in libgs9-common.
  - debian/control, debian/rules, debian/libgs__VER__.install.in,
    debian/libgs-dev.install: Stop using d-shlibmove, it is not compatible
    with libcms2.
  - debian/rules, debian/ubuntu/apport-hook.py: Apport hook.
  - debian/rules, debian/ghostscript-cups.ppd-updater: Added data file to
    trigger the update of the PPD files of existing print queues by CUPS and
    to tell CUPS which PPD files to use for the update and how to match them
    with the PPDs of the existing queues.
  - debian/rules:
    + Generate ABI version number (variable "abi") correctly, cutting off
      repackaging and pre-release parts.
    + The scripts pv.sh and fixmswrd.pl are not shipped upstream any more,
      so we do not need to delete them any more.
    + Install ghostscript-cups.ppd-updater and remove the dependency on
      cups-client from ghostscript-cups.
  - debian/symbols.common: resync with Debian, with the exception of lcms2
    symbols which were only enabled in 9.04~dfsg-0ubuntu12 in Ubuntu.
  - debian/copyright: update credits for the Ubuntu changes.
  - debian/ghostscript.preinst: Use Ubuntu version numbers.
  - debian/ghostscript-cups.postinst: Removed the post-install script which
    was only there to update the PPDs of existing print queues.
  - debian/watch: Search for .tar.bz2 source tarballs

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
} bdef
87
87
 
88
88
/gput           % <value> <key> gput -
89
 
 { exch currentdict //nodict eq { /self dup load end 5 dict begin def } if
90
 
   def
 
89
 { 
 
90
   currentdict /n known {
 
91
     pop pop
 
92
     (   **** Ignoring changes to the graphic state after operator 'W'.\n)
 
93
     pdfformaterror
 
94
   } {
 
95
     exch currentdict //nodict eq { /self dup load end 5 dict begin def } if
 
96
     def
 
97
   } ifelse  
91
98
 } bdef
92
99
 
93
100
/q {
97
104
 
98
105
% Some PDF files have excess Q operators!
99
106
/Q {
 
107
  //false
 
108
  { currentdict /n known { end pop //true } { exit } ifelse 
 
109
  } loop {
 
110
    (   **** Dropping unfinished 'W' mode at 'Q'.\n)
 
111
    pdfformaterror
 
112
  } if
100
113
  currentdict /self .knownget {
101
114
    exec //nodict eq {
102
115
      end
581
594
  matrix /TextTempMatrix gput           % see settextposition
582
595
} bdef
583
596
/ET {
584
 
  TextRenderingMode 4 ge { clip newpath } if
 
597
  TextRenderingMode 4 ge { .currentfilladjust 0 .setfilladjust clip newpath .setfilladjust} if
585
598
  TextSaveMatrix setmatrix
586
599
  currentdict /TextSaveMatrix undef
587
600
} bdef
792
805
        % if the CTM had been unity.
793
806
          currentlinewidth dup
794
807
          matrix defaultmatrix idtransform TextSaveMatrix dtransform
795
 
          2 copy eq {
796
 
          pop
797
 
        }{
798
 
          % non-square scaling reduces to Text matrix in pdfwrite , so
799
 
          % we can ignore it. (wrong answer, but consistent)
800
 
          pop pop currentlinewidth
801
 
        }ifelse setlinewidth
802
 
        .swapcolors show .swapcolors setlinewidth} bind
 
808
          abs 2 copy abs eq {
 
809
            pop
 
810
          }{
 
811
            % non-square scaling reduces to Text matrix in pdfwrite , so
 
812
            % we can ignore it. (wrong answer, but consistent)
 
813
            pop pop currentlinewidth
 
814
          }ifelse setlinewidth
 
815
          show setlinewidth} bind
803
816
        % Tr 2 - Fill then Stroke
804
 
        { gsave 0 .settextrenderingmode
805
 
          setfillstate dup show currentpoint 3 -1 roll
806
 
          grestore gsave setstrokestate
807
 
        //false charpath
808
 
        % We need to make sure the matrix used for the stroke
809
 
        % and therefore stroke width does not include the
810
 
        % Text Matrix Tm.
811
 
        TextSaveMatrix setmatrix
812
 
        .swapcolors
813
 
        stroke
814
 
        .swapcolors
815
 
          grestore moveto
816
 
        } bind
 
817
        { currentlinewidth exch setstrokestate
 
818
        % Need to set the stroke width to a value which gives the correct
 
819
        % width under pdfwrite. Pdfwrite uses (in text mode) an identity
 
820
        % CTM, so we need to calculate the stroke width which would result
 
821
        % if the CTM had been unity.
 
822
          currentlinewidth dup
 
823
          matrix defaultmatrix idtransform TextSaveMatrix dtransform
 
824
          abs 2 copy abs eq {
 
825
            pop
 
826
          }{
 
827
            % non-square scaling reduces to Text matrix in pdfwrite , so
 
828
            % we can ignore it. (wrong answer, but consistent)
 
829
            pop pop currentlinewidth
 
830
          }ifelse setlinewidth
 
831
          setfillstate show setlinewidth} bind
817
832
        % Tr 3 - Neither fill nor stroke
818
833
        { setfillstate show } bind
 
834
        %
 
835
        % pdfwrite emits all text inside a gsave/grestore pair. As
 
836
        % a result we can't preserve any of the 'clip' modes, as the
 
837
        % clip gets undone by the restore. We need to handle the clip
 
838
        % separately.
 
839
        %
819
840
        % Tr 4 - Fill, add to clip
820
841
        { gsave 0 .settextrenderingmode
821
842
          setfillstate dup show grestore //true charpath } bind
822
843
        % Tr 5 - Stroke, add to clip
823
844
        { gsave 1 .settextrenderingmode
824
 
          setstrokestate dup .swapcolors show .swapcolors grestore
825
 
          //true charpath } bind
 
845
          currentlinewidth dup
 
846
          matrix defaultmatrix idtransform TextSaveMatrix dtransform
 
847
          abs 2 copy abs eq {
 
848
            pop
 
849
          }{
 
850
            % non-square scaling reduces to Text matrix in pdfwrite , so
 
851
            % we can ignore it. (wrong answer, but consistent)
 
852
            pop pop currentlinewidth
 
853
          }ifelse setlinewidth
 
854
          setstrokestate dup show grestore
 
855
          //true charpath} bind
826
856
        % Tr 6 - Fill, stroke, add to clip
827
 
        { gsave 0 .settextrenderingmode
828
 
          setfillstate dup show grestore gsave dup
829
 
          setstrokestate //false charpath
830
 
        % We need to make sure the matrix used for the stroke
831
 
        % and therefore stroke width does not include the
832
 
        % Text Matrix Tm.
833
 
        TextSaveMatrix setmatrix
834
 
        .swapcolors
835
 
        stroke .swapcolors grestore
836
 
          //true charpath } bind
 
857
        { gsave 2 .settextrenderingmode
 
858
          currentlinewidth dup
 
859
          matrix defaultmatrix idtransform TextSaveMatrix dtransform
 
860
          abs 2 copy abs eq {
 
861
            pop
 
862
          }{
 
863
            % non-square scaling reduces to Text matrix in pdfwrite , so
 
864
            % we can ignore it. (wrong answer, but consistent)
 
865
            pop pop currentlinewidth
 
866
          }ifelse setlinewidth
 
867
          setstrokestate setfillstate dup show grestore
 
868
          //true charpath} bind
837
869
        % Tr 7 - Add to clip
838
 
        { //true charpath } bind
 
870
        { //true charpath} bind
839
871
] readonly def
840
872
 
 
873
/setstrokeforTrpreservation {
 
874
      % Check to see if the current device supports Tr
 
875
      currentdevice 1 dict dup /PreserveTrMode dup put .getdeviceparams
 
876
      dup type /booleantype eq not {cleartomark //false}{3 1 roll cleartomark}ifelse
 
877
      {
 
878
        TextRenderingMode 1 eq TextRenderingMode 2 eq or
 
879
        TextRenderingMode 5 eq TextRenderingMode 6 eq or or {
 
880
          setstrokestate
 
881
          % Need to set the stroke width to a value which gives the correct
 
882
          % width under pdfwrite. Pdfwrite uses (in text mode) an identity
 
883
          % CTM, so we need to calculate the stroke width which would result
 
884
          % if the CTM had been unity. NOTE! Only interested in magnitudes,
 
885
          % not signs.
 
886
          currentlinewidth dup
 
887
          matrix defaultmatrix idtransform TextSaveMatrix dtransform
 
888
          abs 2 copy abs eq {
 
889
            pop
 
890
          }{
 
891
            % non-square scaling reduces to Text matrix in pdfwrite , so
 
892
            % we can ignore it. (wrong answer, but consistent)
 
893
            pop pop currentlinewidth
 
894
          }ifelse
 
895
          setlinewidth
 
896
      } if
 
897
    } if
 
898
} bind def
 
899
 
841
900
/setshowstate
842
901
 { WordSpacing 0 eq TextSpacing 0 eq and FontMatrixNonHV not and
843
902
    {
844
903
      % Check to see if the current device supports Tr
845
904
      currentdevice 1 dict dup /PreserveTrMode dup put .getdeviceparams
846
905
      dup type /booleantype eq not {cleartomark //false}{3 1 roll cleartomark}ifelse
847
 
        {
848
 
                pdfwrite_textrenderingprocs TextRenderingMode get
849
 
        }
850
 
        {
851
 
                TextRenderingMode 0 eq {
 
906
      {
 
907
              pdfwrite_textrenderingprocs TextRenderingMode get
 
908
      }
 
909
      {
 
910
              TextRenderingMode 0 eq {
852
911
                { setfillstate show }
853
912
              } {
854
913
                TextRenderingMode 3 eq {
866
925
                      dup dup 1 get 0 eq { 3 }{ 2 } ifelse 1 put
867
926
                    } if
868
927
                    setmatrix
869
 
                    2 index setfillstate show % Tr was set to graphic state.
 
928
                    currentpoint
 
929
                    4 index setfillstate show % Tr was set to graphic state.
 
930
                    moveto
870
931
                    setmatrix
871
932
                    % now set the currentpoint using the original matrix
872
933
                    gsave
879
940
                  { //false charpath textrenderingprocs TextRenderingMode get exec }
880
941
                } ifelse
881
942
              } ifelse
882
 
        } ifelse
 
943
       } ifelse
883
944
    }
884
 
    { TextRenderingMode 0 eq TextRenderingMode 3 eq or
885
 
       % Tr was set to graphic state.
886
 
       { FontMatrixNonHV {
 
945
    {
 
946
      % If we are doing a plain old fill, or no text at all, *or* we are going to
 
947
      % a device supporting text rendering modes, then go through this route.
 
948
      %
 
949
      TextRenderingMode 0 eq TextRenderingMode 3 eq or
 
950
      currentdevice 1 dict dup /PreserveTrMode dup put .getdeviceparams
 
951
      dup type /booleantype eq not {cleartomark //false}{3 1 roll cleartomark}ifelse
 
952
      % pdfwrite can't handle rendering modes which involve clipping
 
953
      TextRenderingMode 4 lt and or
 
954
      % Tr was set to graphic state.
 
955
      {
 
956
        FontMatrixNonHV {
887
957
           {
 
958
             % preserve current line width around possible stroke setup
 
959
             currentlinewidth exch
 
960
             setstrokeforTrpreservation
888
961
             setfillstate
889
962
             [ TextSpacing WordSpacing 3 index
890
963
               {                                            % str [... weach wword c undef|ythis xthis|undef
899
972
               } if
900
973
               cshow pop pop ]
901
974
             { xshow } { yshow } Vexch pop exec
 
975
             setlinewidth
902
976
           }
903
977
         } {
904
978
           WordSpacing 0 eq
905
 
            { { setfillstate TextSpacing 0 Vexch 3 -1 roll ashow } }
906
 
            { TextSpacing 0 eq
907
 
              { { setfillstate WordSpacing 0 Vexch 32 4 -1 roll widthshow } }
908
 
              { { setfillstate WordSpacing 0 Vexch 32
909
 
                   TextSpacing 0 Vexch 6 -1 roll awidthshow } }
 
979
            { {
 
980
              % preserve current line width around possible stroke setup
 
981
              % This *should* work the same as the others by using
 
982
              % currentlinewidth...setlinewidth, but it doesn't. In particular
 
983
              % Bug688796b.pdf throws an error. I am unabel to understand why.
 
984
              /MyDict 5 dict def
 
985
              MyDict begin
 
986
              /SaveLW currentlinewidth def end
 
987
 
 
988
              setstrokeforTrpreservation
 
989
              setfillstate TextSpacing 0 Vexch 3 -1 roll ashow
 
990
 
 
991
              MyDict begin
 
992
              SaveLW setlinewidth
 
993
              end
 
994
            } }
 
995
            {
 
996
              TextSpacing 0 eq
 
997
              { {
 
998
                % preserve current line width around possible stroke setup
 
999
                currentlinewidth exch
 
1000
                setstrokeforTrpreservation
 
1001
                setfillstate WordSpacing 0 Vexch 32 4 -1 roll widthshow
 
1002
                setlinewidth
 
1003
              } }
 
1004
              { {
 
1005
                % preserve current line width around possible stroke setup
 
1006
                currentlinewidth exch
 
1007
                setstrokeforTrpreservation
 
1008
                setfillstate WordSpacing 0 Vexch 32
 
1009
                TextSpacing 0 Vexch 6 -1 roll awidthshow
 
1010
                setlinewidth
 
1011
               } }
910
1012
              ifelse
911
1013
            }
912
1014
           ifelse
913
1015
         } ifelse
914
1016
       }
915
 
       { { WordSpacing TextSpacing
 
1017
       {
 
1018
         { currentlinewidth exch
 
1019
           WordSpacing TextSpacing
916
1020
                        % Implement the combination of t3 and false charpath.
917
1021
                        % Note that we must use cshow for this, because we
918
1022
                        % can't parse multi-byte strings any other way.
922
1026
                        % Stack: str wword wchar ccode xthis ythis
923
1027
             Vexch pop currentpoint 6 3 roll
924
1028
                        % Stack: str wthis xorig yorig wword wchar ccode
925
 
             (x) dup 0 3 index put //false charpath
 
1029
             (x) dup 0 3 index put
 
1030
             %
 
1031
             % for devices which can handle the text rendering mode we don't want
 
1032
             % to decompose into paths, we want to do a 'show'. However pdfwrite
 
1033
             % can't handle clipping text, so we *do* want to do the clip path
 
1034
             % as a 'true charpath'.
 
1035
             %
 
1036
             currentdevice 1 dict dup /PreserveTrMode dup put .getdeviceparams
 
1037
             dup type /booleantype eq not {cleartomark //false}{3 1 roll cleartomark}ifelse {
 
1038
               % NB we must have Tr at least 4 or the test above would have
 
1039
               % taken a different path, so we *know* the Tr involves clipping
 
1040
               % or we wouldn't be here. Subtract 4 from the Tr and preserve
 
1041
               % that mode, then do a charpath so the clip path gets set up
 
1042
               % correctly.
 
1043
               gsave TextRenderingMode 4 sub .settextrenderingmode
 
1044
               setstrokeforTrpreservation
 
1045
               setstrokestate setfillstate dup show grestore} if
 
1046
             //false charpath
926
1047
             3 copy 32 eq { add } { exch pop } ifelse
927
1048
                        % Stack: str wthis xorig yorig wword wchar ccode wextra
928
1049
             7 -3 roll moveto add
935
1056
              1 1 index length 1 sub getinterval cvx
936
1057
            } if
937
1058
           4 -1 roll cshow pop pop
938
 
           textrenderingprocs TextRenderingMode get exec
 
1059
           %
 
1060
           % If the device doesn't handle text rendering modes then we now have a suitable
 
1061
           % path, so call the correct routine to stroke/fill it (clip is handled when we
 
1062
           % get ET).
 
1063
           %
 
1064
           currentdevice 1 dict dup /PreserveTrMode dup put .getdeviceparams
 
1065
           dup type /booleantype eq not {cleartomark //false}{3 1 roll cleartomark}ifelse not {
 
1066
             textrenderingprocs TextRenderingMode get exec
 
1067
           } if
 
1068
           setlinewidth
939
1069
         }
940
1070
       }
941
1071
      ifelse