summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Resource/Init/pdf_ops.ps')
-rw-r--r--Resource/Init/pdf_ops.ps204
1 files changed, 90 insertions, 114 deletions
diff --git a/Resource/Init/pdf_ops.ps b/Resource/Init/pdf_ops.ps
index d594035c..eb2168a5 100644
--- a/Resource/Init/pdf_ops.ps
+++ b/Resource/Init/pdf_ops.ps
@@ -279,8 +279,8 @@ currentdict /gput_always_allow .undef
/DeviceCMYK { [0 0 0 1] cvx } bind executeonly
/CIEBasedA { 0 } bind executeonly
/CIEBasedABC { [0 0 0] cvx } bind executeonly
- /CalGray { pop /DeviceGray 0 } bind executeonly
- /CalRGB { pop /DeviceRGB [0 0 0] cvx } bind executeonly
+ /CalGray { 0 } bind executeonly
+ /CalRGB { [0 0 0] cvx } bind executeonly
/Lab {[0 0 0] cvx } bind executeonly
/ICCBased { [ 1 index 1 oget /N get { 0 } repeat ] cvx } bind executeonly
/Separation { 1 } bind executeonly
@@ -701,7 +701,7 @@ end
% NB: setup_trans is defined as either setupOPtrans (for devices that can support
% overprint, or as setupSMtrans which pushes a group for SMask.
% Also see 'teardown_trans' that pops the group and resets the changed values.
-/setupOPtrans % <fillop|strokeop> setup_trans
+/setupOPtrans % [ pathbbox ] <fillop|strokeop> setup_trans
{ % Check OP and BM in case we need to push a group
//OPsaveDstack begin
//Dpush exec % push the current OPsaveDstack values into 'previous'
@@ -719,41 +719,34 @@ end
} ifelse
.currentSMask //null ne or { % push a group for OP or SMask
mark /Subtype /Group /Isolated .currentSMask //null ne .dicttomark
- 1 index /stroke eq {
- % BBox needs to include line width / line join expansion.
- gsave strokepath pathbbox grestore
- } {
- pathbbox % fill/eofill cases
- } ifelse
+ 2 index aload pop % pathbbox
.begintransparencygroup
% After group pushed, set opacityalpha, shapealpha and blendmode
/saveOA .currentopacityalpha def
/saveSA .currentshapealpha def
1 .setopacityalpha 1 .setshapealpha
/GroupPushed //true def
- } if
+ } {
+ /GroupPushed //false def
+ } ifelse
% we may change to CompatibleOverprint even if we didn't push a group.
ChangeBM {
/saveBM .currentblendmode def /CompatibleOverprint .setblendmode
} if
pop % fillop/strokeop
+ pop % pathbbox array
end % OPsaveDstack
} bind executeonly def
% Also see 'teardown_trans' that pops the group and resets the changed values.
-/setupSMtrans % <fillop|strokeop> setup_trans
+/setupSMtrans % [ pathbbox ] <fillop|strokeop> setup_trans
{
//OPsaveDstack begin
//Dpush exec % push the current OPsaveDstack values into 'previous'
.currentSMask //null ne 1 index /image ne and % only push for SMask if not from image
{
mark /Subtype /Group /Isolated //true .dicttomark
- exch /stroke eq {
- % BBox needs to include line width / line join expansion.
- gsave strokepath pathbbox grestore
- } {
- pathbbox % fill/eofill cases
- } ifelse
+ 2 index aload pop % pathbbox
.begintransparencygroup
% After group pushed, set opacityalpha, shapealpha and blendmode
/saveOA .currentopacityalpha def
@@ -762,9 +755,10 @@ end
/GroupPushed //true def
} {
/GroupPushed //false def
- pop % fillop/strokeop
} ifelse
end % OPsaveDstack
+ pop % fillop/strokeop
+ pop % pathbbox array
} bind executeonly def
% If a transparency group was pushed, pop it, and reset the settings.
@@ -791,9 +785,23 @@ currentdict dup /Dpush .undef /Dpop .undef
/fsexec % <fillop|strokeop> fsexec -
{
PDFusingtransparency {
- dup setup_trans
- cvx exec
- teardown_trans
+ dup /stroke eq 1 index /.fillstroke eq or 1 index /.eofillstroke eq or {
+ % BBox needs to include line width / line join expansion.
+ % strokepath will return empty path (no currentpoint) if nothing is stroked
+ { gsave strokepath pathbbox } stopped grestore {
+ % If we get an error, just emit an empty box
+ 0 0 0 0
+ } if
+ } {
+ % If we get an error, just emit an empty box
+ { pathbbox } stopped { 0 0 0 0 } if
+ } ifelse
+ % pathbbox valid -- proceed with drawing
+ 4 array astore % pathbbox
+ 1 index
+ setup_trans
+ cvx exec
+ teardown_trans
} {
cvx exec
} ifelse
@@ -924,23 +932,7 @@ currentdict dup /Dpush .undef /Dpop .undef
/B {
OFFlevels length 0 eq {
- PDFusingtransparency {
- % knockout trans group around the filled and stroked object
- mark
- /Isolated //true /Knockout //true
- .dicttomark
- % strokepath will return empty path (no currentpoint) if nothing is stroked
- gsave { strokepath pathbbox } stopped grestore not {
- 1 .setopacityalpha
- .begintransparencygroup
- gsave setfillstate fill grestore
- setstrokestate .swapcolors /stroke fsexec .swapcolors
- .endtransparencygroup
- } { newpath pop } ifelse
- } {
- gsave setfillstate fill grestore
- setstrokestate .swapcolors /stroke fsexec .swapcolors
- } ifelse
+ setstrokestate setfillstate /.fillstroke fsexec
} {
newpath
} ifelse
@@ -950,23 +942,7 @@ currentdict dup /Dpush .undef /Dpop .undef
/B* {
OFFlevels length 0 eq {
- PDFusingtransparency {
- % knockout trans group around the filled and stroked object
- mark
- /Isolated //true /Knockout //true
- .dicttomark
- % strokepath will return empty path (no currentpoint) if nothing is stroked
- gsave { strokepath pathbbox } stopped grestore not {
- 1 .setopacityalpha
- .begintransparencygroup
- gsave setfillstate eofill grestore
- setstrokestate .swapcolors /stroke fsexec .swapcolors
- .endtransparencygroup
- } { newpath pop } ifelse
- } {
- gsave setfillstate eofill grestore
- setstrokestate .swapcolors /stroke fsexec .swapcolors
- } ifelse
+ setstrokestate setfillstate /.eofillstroke fsexec
} {
newpath
} ifelse
@@ -982,49 +958,14 @@ currentdict dup /Dpush .undef /Dpop .undef
/f* { OFFlevels length 0 eq { gsave setfillstate eofill grestore } if n } bind executeonly def
/B {
OFFlevels length 0 eq {
- PDFusingtransparency {
- % knockout trans group around the filled and stroked object
- mark
- /Isolated //true /Knockout //true
- .dicttomark
- % strokepath will return empty path (no currentpoint) if nothing is stroked
- gsave {strokepath pathbbox } stopped grestore not
- {
- 1 .setopacityalpha
- .begintransparencygroup
- gsave setfillstate fill grestore
- setstrokestate .swapcolors /stroke fsexec .swapcolors
- .endtransparencygroup
- } {
- newpath pop
- } ifelse
- } {
- gsave setfillstate fill grestore
- setstrokestate .swapcolors /stroke fsexec .swapcolors
- } ifelse
+ .fillstroke
} if
n
} bind executeonly def
/b { closepath B } bind executeonly def
/B* {
OFFlevels length 0 eq {
- PDFusingtransparency {
- % knockout trans group around the filled and stroked object
- mark
- /Isolated //true /Knockout //true
- .dicttomark
- % strokepath will return empty path (no currentpoint) if nothing is stroked
- gsave {strokepath pathbbox} stopped grestore not {
- 1 .setopacityalpha
- .begintransparencygroup
- gsave setfillstate eofill grestore
- setstrokestate .swapcolors /stroke fsexec .swapcolors
- .endtransparencygroup
- } { newpath pop } ifelse
- } {
- gsave setfillstate eofill grestore
- setstrokestate .swapcolors /stroke fsexec .swapcolors
- } ifelse
+ .eofillstroke
} if
n
} bind executeonly def
@@ -1219,9 +1160,19 @@ end readonly def
} bind executeonly def
+/clip_if_required {
+ .currenttextrenderingmode 4 ge
+ {currentpoint} //.internalstopped exec
+ {//false}
+ {pop pop //true}
+ ifelse and
+ { .currentfilladjust2 0 dup .setfilladjust2 clip .setfilladjust2} if
+ newpath
+} bind def
+
/ET_NO_TXT_KO {
currentdict /TextSaveMatrix known {
- .currenttextrenderingmode 4 ge { .currentfilladjust2 0 dup .setfilladjust2 clip .setfilladjust2 newpath} if
+ //clip_if_required exec
TextSaveMatrix setmatrix
currentdict /TextSaveMatrix undef
@@ -1244,6 +1195,8 @@ end readonly def
} if
} bind executeonly def
+currentdict /clip_if_required .undef
+
/ET {
//ET_NO_TXT_KO exec
% Group push occurred in pdf14_text_begin.
@@ -1642,8 +1595,19 @@ end readonly def
% If current path is not known to be valid, use the clip path
/TextTransSetup { % showarg path_valid TextTransSetup showarg
% showarg path_valid false TextTransSetup showarg
+ gsave
% NB: if 'show' is used, then we use the clippath, but a smaller bbox is preferred
- not dup { gsave clippath } if //null setup_trans { grestore } if
+ {
+ % path was (probably) valid (CTM may not be invertable)
+ % Since TR mode may include stroking, expand for stroke
+ % If we get an error, just emit an empty box
+ { strokepath pathbbox } stopped { 0 0 0 0 } if
+ } {
+ clippath pathbbox stopped { 0 0 0 0 } if
+ } ifelse
+ grestore
+ 4 array astore //null
+ setup_trans
} bind executeonly def
/TextTransTeardown {
@@ -1678,25 +1642,35 @@ end readonly def
% operations when the CTM is singular.
% Work around this here.
{
- matrix currentmatrix dup dup
- dup 0 get 0 eq 1 index 1 get 0 eq and {
- dup dup 2 get 0 eq { 0 }{ 1 } ifelse 1 put
- } if
- dup 2 get 0 eq 1 index 3 get 0 eq and {
- dup dup 1 get 0 eq { 3 }{ 2 } ifelse 1 put
- } if
- setmatrix
- currentpoint
- % don't worry about transparency for invisible text
- 4 index settextfillstate show % Tr was set to graphic state.
- moveto
- setmatrix
- % now set the currentpoint using the original matrix
- gsave
- setmatrix
- //false charpath currentpoint newpath
- grestore
- moveto
+ matrix currentmatrix
+ % Previously we tested specifically for a scale factor of 0,
+ % but bug #701875 has a CTM which is minute, but not zero. If
+ % we try to use that at anything except low resolution FreeType
+ % ends up trying to deal with glyph metrics where one dimension is 0
+ % and it throws an error. So instead of looking for zero, we'll look
+ % for a really tiny CTM.
+ % We also used to patch up the CTM, and still use it, but frankly
+ % this is too much trouble. If the CTM is tiny then the displacement
+ % due to drawing the text will also be tiny. Negligible in fact.
+ % So if its that small then lets just ignore it.
+ dup 0 get abs 0.00001 lt 1 index 1 get 0.00001 abs lt and not {
+ dup 2 get abs 0.00001 lt 1 index 3 get abs 0.00001 lt and not {
+ pop
+ currentpoint
+ % don't worry about transparency for invisible text
+ 2 index settextfillstate show % Tr was set to graphic state.
+ moveto
+ % now set the currentpoint using the original matrix
+ gsave
+ //false charpath currentpoint newpath
+ grestore
+ moveto
+ } {
+ pop pop
+ }ifelse
+ } {
+ pop pop
+ }ifelse
}
} {
{ //false charpath textrenderingprocs .currenttextrenderingmode get exec }
@@ -1919,7 +1893,9 @@ end readonly def
1 .setopacityalpha
% While text will always have a currentpoint, strokepath seems to mess with it.
% we get the currentpoint, then use moveto to restore it for pathbbox
- gsave currentpoint strokepath moveto pathbbox grestore
+ { gsave currentpoint strokepath moveto pathbbox } stopped grestore {
+ /tB cvx /undefinedresult signalerror
+ } if
.begintransparencygroup
gsave tf grestore tS
.endtransparencygroup