[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-2035-gc3b184c
[email protected] (Ken Sharp) Sat, 14 Dec 2019 19:35:22 +0000 (UTC)
| Newsgroups | gmane.comp.printing.ghostscript.cvs |
|---|---|
| Message-ID | <[email protected]> |
The ghostpdl branch, master has been updated
via c3b184c41144a2650e5520643bbb1cff42c18acc (commit)
via 1246085e17ee35928f737f1fbf69d69fe6b7a2ae (commit)
via acccfd2fe90e25534e7d492ca2378dc32269e48e (commit)
via 5e5f7b41c080bdbd15fac5afbd09052a83e81a01 (commit)
via 4940c5cb80916017d3ee0c9b53475323cf5ebbd6 (commit)
via d95dd7a23f25e73042f3c8e6043c83285387d0a1 (commit)
from f25987c838ea9437b60f8b3b93f90e187013b641 (commit)
----------------------------------------------------------------------
commit c3b184c41144a2650e5520643bbb1cff42c18acc
Author: Ken Sharp <[email protected]>
Date: Sat Dec 14 19:13:27 2019 +0000
PDF interpreter - fix line ending positions on Line annotations
Bug #701889 "Annotation objects missing or incorrectly interpreted when appearance stream missing"
The calculation of the position of the line ending was incorrect, and
we were applying the wrong LE entry to each end of the line.
diff --git a/Resource/Init/pdf_draw.ps b/Resource/Init/pdf_draw.ps
index 1d1e3ce..2aab3ce 100644
--- a/Resource/Init/pdf_draw.ps
+++ b/Resource/Init/pdf_draw.ps
@@ -4044,10 +4044,12 @@ currentdict /set_bc_color undef
1 index aload pop % <annot> [x1 y1 x2 y2] [LE1 LE2] x1 y1 x2 y2
3 -1 roll sub % <annot> [x1 y1 x2 y2] [LE1 LE2] x1 x2 dy
3 1 roll exch sub % <annot> [x1 y1 x2 y2] [LE1 LE2] dy dx
- 2 copy translate
+ 3 index aload pop 4 2 roll pop pop
+ translate
+ 0 0 moveto
atan % <annot> [x1 y1 x2 y2] [LE1 LE2]
rotate
- dup 0 get % <annot> [x1 y1 x2 y2] [LE1 LE2] LE1
+ dup 1 get % <annot> [x1 y1 x2 y2] [LE1 LE2] LE1
dup //LineEnd_dict exch known not
{
pop /None
@@ -4061,10 +4063,12 @@ currentdict /set_bc_color undef
1 index aload pop % x1 y1 x2 y2
3 -1 roll sub % x1 x2 dy
3 1 roll exch sub % dy dx
- 2 copy translate
+ 3 index aload pop pop pop
+ translate
+ 0 0 moveto
atan 180 add
rotate
- 1 get dup //LineEnd_dict exch known not {pop /None} if //LineEnd_dict exch get 3 index exch exec
+ 0 get dup //LineEnd_dict exch known not {pop /None} if //LineEnd_dict exch get 3 index exch exec
grestore
}if
aload pop 4 2 roll
----------------------------------------------------------------------
commit 1246085e17ee35928f737f1fbf69d69fe6b7a2ae
Author: Ken Sharp <[email protected]>
Date: Sat Dec 14 15:24:57 2019 +0000
PDF interpreter - Add arrows to /CL lines in FreeText annotations
Bug #701889 "Annotation objects missing or incorrectly interpreted when appearance stream missing"
Add arrowheads to the ends of callout lines.
diff --git a/Resource/Init/pdf_draw.ps b/Resource/Init/pdf_draw.ps
index 4243350..1d1e3ce 100644
--- a/Resource/Init/pdf_draw.ps
+++ b/Resource/Init/pdf_draw.ps
@@ -4724,14 +4724,29 @@ currentdict /set_bc_color undef
grestore % in case the contents were rotated
dup /CL knownoget {
dup length 6 eq {
- aload pop moveto lineto lineto stroke
+ dup aload pop pop pop
} {
dup length 4 eq {
- aload pop moveto lineto stroke
+ dup aload pop
} {
- pop
+ pop 0
} ifelse
} ifelse
+ 4 2 roll
+ exch 4 -1 roll sub
+ 3 1 roll exch sub
+ atan exch
+ aload pop moveto lineto lineto
+ currentpoint
+% stroke
+% 0 1 0 setrgbcolor
+ moveto currentpoint translate 0 0 moveto
+ 360 exch sub rotate
+ currentpoint
+ -5 -8 rlineto
+ moveto
+ 5 -8 rlineto
+ stroke
} if
//endannottransparency exec
//false
----------------------------------------------------------------------
commit acccfd2fe90e25534e7d492ca2378dc32269e48e
Author: Ken Sharp <[email protected]>
Date: Fri Dec 13 15:13:58 2019 +0000
PDF interpreter - Fix multi-line FreeText annotation with /Rotate 270
The calculation of the 'width' of the container for the text was
incorrect, as was the starting x co-ordinate. Fixed here.
diff --git a/Resource/Init/pdf_draw.ps b/Resource/Init/pdf_draw.ps
index e1cc6b2..4243350 100644
--- a/Resource/Init/pdf_draw.ps
+++ b/Resource/Init/pdf_draw.ps
@@ -4621,10 +4621,10 @@ currentdict /set_bc_color undef
5 index /RD knownoget {
applyRD
} if
- 3 -1 roll add 2 index 2 index add exch
- moveto
- 270 rotate
- 1 index add
+ dup 4 -1 roll add 3 -1 roll 3 index add exch
+ moveto 270 rotate
+ exch pop currentpoint
+ pop dup 3 -1 roll add
}{
dup annotrect
5 index /RD knownoget {
@@ -4702,7 +4702,8 @@ currentdict /set_bc_color undef
} {
1 string dup 0 4 -1 roll
put dup %% llx urx (string) (int) (int)
- stringwidth pop currentpoint pop add 3 index gt {
+ stringwidth pop currentpoint pop add 3 index
+ gt {
currentpoint exch pop 4 index exch ..TextHeight sub moveto
} if
show
----------------------------------------------------------------------
commit 5e5f7b41c080bdbd15fac5afbd09052a83e81a01
Author: Ken Sharp <[email protected]>
Date: Fri Dec 13 11:55:15 2019 +0000
PDF interpreter - apply /C to more annotation types
Bug #701889 "Annotation objects missing or incorrectly interpreted when appearance stream missing"
Seems we also need to apply the /C colour to Polygon, Square and Circle
annotations before drawing them.
diff --git a/Resource/Init/pdf_draw.ps b/Resource/Init/pdf_draw.ps
index 4c78c3e..e1cc6b2 100644
--- a/Resource/Init/pdf_draw.ps
+++ b/Resource/Init/pdf_draw.ps
@@ -3707,14 +3707,19 @@ currentdict /set_bc_color undef
rectfill
grestore
dup /CA knownoget {.setopacityalpha} if
- drawborder
+ dup annotsetcolor {
+ drawborder
+ } if
//false
}{
dup annotrect
5 index /RD knownoget {
applyRD
} if
- drawopdict /re get exec strokeborderpath
+ drawopdict /re get exec
+ dup annotsetcolor {
+ strokeborderpath
+ } if
} ifelse
//endannottransparency exec
grestore
@@ -3756,7 +3761,9 @@ currentdict /set_bc_color undef
translate //drawellipse exec
dup
fillborderpath
- strokeborderpath
+ dup annotsetcolor {
+ strokeborderpath
+ } if
//endannottransparency exec
grestore
//false
@@ -3805,9 +3812,13 @@ currentdict /set_bc_color undef
fill
grestore
dup /CA knownoget {.setopacityalpha} if
- strokeborderpath
+ dup annotsetcolor {
+ strokeborderpath
+ } if
} {
- strokeborderpath
+ dup annotsetcolor {
+ strokeborderpath
+ } if
} ifelse
//endannottransparency exec
//false
----------------------------------------------------------------------
commit 4940c5cb80916017d3ee0c9b53475323cf5ebbd6
Author: Ken Sharp <[email protected]>
Date: Fri Dec 13 11:23:28 2019 +0000
PDF interpreter - more annotation improvements
Bug #701889 "Annotation objects missing or incorrectly interpreted when appearance stream missing"
Apply the /RD array (if present) to the annotation /Rect before using
the Rect to draw the border.
We were using the /C array in drawborder to set the colour before
stroking the border, there are two problems with this; firstly the /C
array is not used to specify a border colour, secondly we need to set
the colour for certain objects irrespective of whether they have a
border.
Remove annotsetcolor from drawborder and apply it to Squiggly, Strikeout,
Underline, Highlight, Line and Ink annotations in order to set the
colour before drawing the annotation. The specification says that this
is used for; the border of a Link annotation, the title bar of a
pop-up annotation's pop-up and the background of the annotation's icon
when closed, but in fact Acrobat also uses it to set the colour for all
the annotation types listed above.
There may still be more work needing done here, but this matches all the
test cases I currently have.
diff --git a/Resource/Init/pdf_draw.ps b/Resource/Init/pdf_draw.ps
index 70dbb11..4c78c3e 100644
--- a/Resource/Init/pdf_draw.ps
+++ b/Resource/Init/pdf_draw.ps
@@ -3100,17 +3100,20 @@ end
/strokeborder { % <annot> <width> <dash> strokeborder -
1 index 0 ne { % do not draw if border width is 0
gsave
- 2 index annotsetcolor
- {
+% 2 index annotsetcolor
+% {
0 setdash dup setlinewidth
- exch annotrect
+ exch dup annotrect
+ 5 -1 roll /RD knownoget {
+ applyRD
+ } if
2 { 4 index sub 4 1 roll } repeat
2 { 4 index 0.5 mul add 4 1 roll } repeat
rectstroke pop
grestore
- } {
- pop pop pop
- } ifelse
+% } {
+% pop pop pop
+% } ifelse
} {
pop pop pop
}ifelse
@@ -3151,7 +3154,8 @@ end
} if
{} 2 index /S knownoget {
/D eq { 2 index /D knownoget not { {3} } if exch pop } if
- } if 3 -1 roll pop strokeborder
+ } if
+ 3 -1 roll pop strokeborder
} {
dup 2 get
exch dup length 3 gt { 3 get } { pop {} } ifelse
@@ -3200,21 +3204,29 @@ end
/D eq { 2 index /D knownoget not { {3} } if exch pop } if
} if
3 index /CA knownoget {.setopacityalpha} if
- 3 -1 roll pop 2 index annotsetcolor {0 setdash setlinewidth stroke} if
+ 3 -1 roll pop
+% 2 index annotsetcolor {
+ 0 setdash setlinewidth stroke
+% } if
} {
dup 2 get
% If element 3 of the /Border array is 0, then don't draw the border
dup 0 ne {
exch dup length 3 gt { 3 get } { pop {} } ifelse
3 index /CA knownoget {.setopacityalpha} if
- 2 index annotsetcolor {0 setdash setlinewidth stroke} if
+% 2 index annotsetcolor {
+ 0 setdash setlinewidth stroke
+% } if
}{
pop pop
} ifelse
} ifelse
} {
3 index /CA knownoget {.setopacityalpha} if
- 1 {} 2 index annotsetcolor {0 setdash setlinewidth stroke} if
+ 1 {}
+% 2 index annotsetcolor {
+ 0 setdash setlinewidth stroke
+% } if
} ifelse
pop
grestore
@@ -4014,44 +4026,46 @@ currentdict /set_bc_color undef
} {
gsave
//startannottransparency exec
- dup /L knownoget {
- 1 index /LE knownoget { % <annot> [x1 y1 x2 y2] [LE1 LE2]
- gsave
- 1 index aload pop % <annot> [x1 y1 x2 y2] [LE1 LE2] x1 y1 x2 y2
- 3 -1 roll sub % <annot> [x1 y1 x2 y2] [LE1 LE2] x1 x2 dy
- 3 1 roll exch sub % <annot> [x1 y1 x2 y2] [LE1 LE2] dy dx
- 2 copy translate
- atan % <annot> [x1 y1 x2 y2] [LE1 LE2]
- rotate
- dup 0 get % <annot> [x1 y1 x2 y2] [LE1 LE2] LE1
- dup //LineEnd_dict exch known not
- {
- pop /None
- } if
- //LineEnd_dict exch % <annot> [x1 y1 x2 y2] [LE1 LE2] <dict> LE1
- get % <annot> [x1 y1 x2 y2] [LE1 LE2] {}
- 3 index exch % <annot> [x1 y1 x2 y2] [LE1 LE2] <annot> {}
- exec
- grestore
- gsave
- 1 index aload pop % x1 y1 x2 y2
- 3 -1 roll sub % x1 x2 dy
- 3 1 roll exch sub % dy dx
- 2 copy translate
- atan 180 add
- rotate
- 1 get dup //LineEnd_dict exch known not {pop /None} if //LineEnd_dict exch get 3 index exch exec
- grestore
- }if
- aload pop 4 2 roll
- moveto lineto
- strokeborderpath
- }{
- ( **** Error: Invalid L array for Line, annotation has not been drawn.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- pop
- } ifelse
+ dup annotsetcolor {
+ dup /L knownoget {
+ 1 index /LE knownoget { % <annot> [x1 y1 x2 y2] [LE1 LE2]
+ gsave
+ 1 index aload pop % <annot> [x1 y1 x2 y2] [LE1 LE2] x1 y1 x2 y2
+ 3 -1 roll sub % <annot> [x1 y1 x2 y2] [LE1 LE2] x1 x2 dy
+ 3 1 roll exch sub % <annot> [x1 y1 x2 y2] [LE1 LE2] dy dx
+ 2 copy translate
+ atan % <annot> [x1 y1 x2 y2] [LE1 LE2]
+ rotate
+ dup 0 get % <annot> [x1 y1 x2 y2] [LE1 LE2] LE1
+ dup //LineEnd_dict exch known not
+ {
+ pop /None
+ } if
+ //LineEnd_dict exch % <annot> [x1 y1 x2 y2] [LE1 LE2] <dict> LE1
+ get % <annot> [x1 y1 x2 y2] [LE1 LE2] {}
+ 3 index exch % <annot> [x1 y1 x2 y2] [LE1 LE2] <annot> {}
+ exec
+ grestore
+ gsave
+ 1 index aload pop % x1 y1 x2 y2
+ 3 -1 roll sub % x1 x2 dy
+ 3 1 roll exch sub % dy dx
+ 2 copy translate
+ atan 180 add
+ rotate
+ 1 get dup //LineEnd_dict exch known not {pop /None} if //LineEnd_dict exch get 3 index exch exec
+ grestore
+ }if
+ aload pop 4 2 roll
+ moveto lineto
+ strokeborderpath
+ }{
+ ( **** Error: Invalid L array for Line, annotation has not been drawn.\n)
+ pdfformaterror
+ ( Output may be incorrect.\n) pdfformaterror
+ pop
+ } ifelse
+ } if
//endannottransparency exec
//false
grestore
@@ -4119,14 +4133,16 @@ currentdict /set_bc_color undef
/Link { % <annot> -> <false>
//startannottransparency exec
- dup drawborder dup calc_annot_scale
- 2 copy mul 0 ne
- {3 -1 roll drawwidget //false}
- {
- pop pop
- ( **** Error: ignoring annotation with scale factor of 0\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- }ifelse
+ dup annotsetcolor {
+ dup drawborder dup calc_annot_scale
+ 2 copy mul 0 ne
+ {3 -1 roll drawwidget //false}
+ {
+ pop pop
+ ( **** Error: ignoring annotation with scale factor of 0\n) pdfformaterror
+ ( Output may be incorrect.\n) pdfformaterror
+ }ifelse
+ } if
//endannottransparency exec
} bind executeonly def
@@ -4140,7 +4156,8 @@ currentdict /set_bc_color undef
1 setlinewidth
1 setlinecap
1 setlinejoin
- dup annotsetcolor {
+ dup annotsetcolor
+ {
dup calc_annot_scale
2 copy mul 0 ne
{
@@ -4189,7 +4206,8 @@ currentdict /set_bc_color undef
//true
} {
0 setlinecap
- dup annotsetcolor {
+ dup annotsetcolor
+ {
dup calc_annot_scale
2 copy mul 0 ne
{
@@ -4229,7 +4247,8 @@ currentdict /set_bc_color undef
//true
} {
0 setlinecap
- dup annotsetcolor {
+ dup annotsetcolor
+ {
dup calc_annot_scale
2 copy mul 0 ne
{
@@ -4291,7 +4310,8 @@ currentdict /set_bc_color undef
//true
} {
0 setlinecap
- dup annotsetcolor {
+ dup annotsetcolor
+ {
/QuadPoints knownoget {
aload length 8 idiv {
6 -2 roll
@@ -4326,7 +4346,8 @@ currentdict /set_bc_color undef
//true
} {
//startannottransparency exec
- dup annotsetcolor {
+ dup annotsetcolor
+ {
dup calc_annot_scale
2 copy mul 0 ne
{
@@ -4657,7 +4678,6 @@ currentdict /set_bc_color undef
%% and use it immediatley to start the text one line down
%%
currentpoint ..TextHeight sub moveto
-
%% Now we process each character code in the string. If we find
%% a /r/ or /n then we drop a line. If the character would end up
%% outside the Annot Rect, then we drop a line before showing it.
----------------------------------------------------------------------
commit d95dd7a23f25e73042f3c8e6043c83285387d0a1
Author: Ken Sharp <[email protected]>
Date: Thu Dec 12 17:04:17 2019 +0000
PDF interpreter - apply RD array to Circle, Square and FreeText, apply Rotate to FreeText
Bug #701889 "Annotation objects missing or incorrectly interpreted when appearance stream missing"
The /RD array makes certain kinds of annotations be drawn in a smaller
area. Although the spec does not mention it, Acrobat applies the
/Rotate key if found to the text in a FreeText annotation.
Still more to do on the text; we are nto fitting the text correctly
when Rotate is 270, not certain why. Also we are not drawing Borders
when we should, some text is missing and text is in the wrong colour
(due to not applying /DS)
diff --git a/Resource/Init/pdf_draw.ps b/Resource/Init/pdf_draw.ps
index d64120e..70dbb11 100644
--- a/Resource/Init/pdf_draw.ps
+++ b/Resource/Init/pdf_draw.ps
@@ -3573,6 +3573,23 @@ currentdict /set_bc_color undef
} ifelse
} bind executeonly def
+/applyRD {
+ % x y w h [l t r b]
+ dup 0 get % x y w h [] l
+ 6 -1 roll add
+ 5 1 roll %x+l y w h []
+ dup 1 get %x+l y w h [] b
+ 5 -1 roll add %x+l w h [] b+y
+ 4 1 roll %x+l y+b w h []
+ aload pop %x+l y+b w h l t r b
+ exch %x+l y+b w h l t b r
+ 4 -1 roll add %x+l y+b w h t b r+l
+ 3 1 roll add %x+l y+b w h r+l t+b
+ 3 -1 roll exch sub %x+l y+b w r+l h-(t+b)
+ 3 1 roll sub %x+l y+b h-(t+b) w-(r+l)
+ exch
+} bind executeonly def
+
% Draw an annotation.
/drawannottypes 20 dict begin
@@ -3671,13 +3688,20 @@ currentdict /set_bc_color undef
{
gsave
dup /ca knownoget {.setopacityalpha} if
- dup annotrect rectfill
+ dup annotrect
+ 5 index /RD knownoget {
+ applyRD
+ } if
+ rectfill
grestore
dup /CA knownoget {.setopacityalpha} if
drawborder
//false
}{
dup annotrect
+ 5 index /RD knownoget {
+ applyRD
+ } if
drawopdict /re get exec strokeborderpath
} ifelse
//endannottransparency exec
@@ -3712,7 +3736,11 @@ currentdict /set_bc_color undef
} {
gsave
//startannottransparency exec
- dup annotrect 4 2 roll exch 3 index 2 div add exch 2 index 2 div add
+ dup annotrect
+ 5 index /RD knownoget {
+ applyRD
+ } if
+ 4 2 roll exch 3 index 2 div add exch 2 index 2 div add
translate //drawellipse exec
dup
fillborderpath
@@ -4439,7 +4467,11 @@ currentdict /set_bc_color undef
}{
//false
} ifelse
- {dup annotrect
+ {
+ dup annotrect
+ 5 index /RD knownoget {
+ applyRD
+ } if
%% Somewhat horrifyingly, rectfill maps directly to the device fill_rectangle
%% method, which bypasses transparency (!!) So we construct the rectangle,
%% and fill it, manually instead....
@@ -4500,23 +4532,93 @@ currentdict /set_bc_color undef
}ifelse
%% draw the border, if we don't have a border style dictionary, draw a default one.
- dup /BS knownoget {
+ dup /BS knownoget
+ {
pop dup drawborder
}{
newpath
0 setgray 1 setlinewidth
- dup annotrect 4 -1 roll 1 add 4 -1 roll 1 add 4 -1 roll 2 sub 4 -1 roll 2 sub
- 4 2 roll moveto
- currentpoint exch 3 index add exch lineto
- currentpoint 2 index add lineto
- exch currentpoint 3 1 roll exch sub exch lineto
- currentpoint 3 -1 roll sub lineto stroke
+ dup annotrect
+ 5 index /RD knownoget {
+ applyRD
+ 4 -1 roll 4 -1 roll 4 -1 roll 4 -1 roll
+ 4 2 roll
+ } {
+ 4 -1 roll 1 add 4 -1 roll 1 add 4 -1 roll 2 sub 4 -1 roll 2 sub
+ 4 2 roll
+ }ifelse
+ moveto
+ currentpoint exch 3 index add exch
+ lineto
+ currentpoint 2 index add
+ lineto
+ exch currentpoint 3 1 roll exch sub exch
+ lineto
+ currentpoint 3 -1 roll sub
+ lineto stroke
}ifelse
+ gsave % in case we rotate the contents
%% Start the current point at the top left of the annotation Rect
%%
- dup annotrect 4 -1 roll 2 add 4 -1 roll 2 add 4 -1 roll 4 sub 4 -1 roll 4 sub
- 3 -1 roll add 2 index exch moveto 1 index add
+ dup /Rotate knownoget
+ % x y w h - x' w' x' y'
+ {
+ dup 90 eq {
+ pop
+ dup annotrect
+ 5 index /RD knownoget {
+ applyRD
+ } if
+ exch pop 3 -1 roll 2 index
+ moveto 90 rotate
+ 1 index add
+ } {
+ dup 180 eq {
+ pop
+ dup annotrect
+ 5 index /RD knownoget {
+ applyRD
+ } if
+ pop 3 -1 roll 1 index add -1 mul exch 1 index -1 mul 4 -1 roll
+ moveto 180 rotate
+ 1 index add
+ }{
+ 270 eq {
+ dup annotrect
+ 5 index /RD knownoget {
+ applyRD
+ } if
+ 3 -1 roll add 2 index 2 index add exch
+ moveto
+ 270 rotate
+ 1 index add
+ }{
+ dup annotrect
+ 5 index /RD knownoget {
+ applyRD
+ 3 -1 roll add 2 index exch
+ moveto 1 index add
+ }{
+ 4 -1 roll 2 add 4 -1 roll 2 add 4 -1 roll 4 sub 4 -1 roll 4 sub
+ 3 -1 roll add 2 index exch
+ moveto 1 index add
+ } ifelse
+ } ifelse
+ } ifelse
+ } ifelse
+ }{
+ dup annotrect
+ 5 index /RD knownoget {
+ applyRD
+ 3 -1 roll add 2 index exch
+ moveto 1 index add
+ }{
+ 4 -1 roll 2 add 4 -1 roll 2 add 4 -1 roll 4 sub 4 -1 roll 4 sub
+ 3 -1 roll add 2 index exch
+ moveto 1 index add
+ } ifelse
+ } ifelse
%% Get the Contents string, if we don't have one, we're done
%%
@@ -4586,6 +4688,8 @@ currentdict /set_bc_color undef
} ifelse
} if
pop pop
+
+ grestore % in case the contents were rotated
dup /CL knownoget {
dup length 6 eq {
aload pop moveto lineto lineto stroke
Summary of changes:
Resource/Init/pdf_draw.ps | 321 ++++++++++++++++++++++++++++++++++------------
1 file changed, 238 insertions(+), 83 deletions(-)