summaryrefslogtreecommitdiff
path: root/source/pdf
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2017-07-24 16:49:44 +0200
committerSebastian Rasmussen <sebras@gmail.com>2017-07-24 23:15:44 +0800
commit2bd66c263ec4514b31966495924ed386413d8327 (patch)
tree72261f03476dfd8c1d1c196d96a2acbcee1cc054 /source/pdf
parentbc5284fb524de5f252da31f6d2ea68b1629bd35b (diff)
downloadmupdf-2bd66c263ec4514b31966495924ed386413d8327.tar.xz
Fix ordering of quadpoints in highlight synthesis.
The spec is full of lies. The internal ordering of points in a QuadPoint is not counterclockwise [ll lr ur ul], it's crosswise [ll lr ul ur].
Diffstat (limited to 'source/pdf')
-rw-r--r--source/pdf/pdf-appearance.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/source/pdf/pdf-appearance.c b/source/pdf/pdf-appearance.c
index f6414e15..c5e35d5a 100644
--- a/source/pdf/pdf-appearance.c
+++ b/source/pdf/pdf-appearance.c
@@ -1718,18 +1718,21 @@ void pdf_set_markup_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *an
for (i = 0; i < n; i += 4)
{
- fz_point pt0 = qp[i];
- fz_point pt1 = qp[i+1];
+ /* Contrary to the specification, the points within a QuadPoint are NOT ordered
+ * in a counterclockwise fashion. Experiments with Adobe's implementation
+ * indicates a cross-wise ordering is intended: ll, lr, ul, ur. */
+ fz_point ll = qp[i];
+ fz_point lr = qp[i+1];
fz_point up;
float thickness;
- up.x = qp[i+2].x - qp[i+1].x;
- up.y = qp[i+2].y - qp[i+1].y;
+ up.x = qp[i+2].x - qp[i].x; /* ul - ll vector */
+ up.y = qp[i+2].y - qp[i].y;
- pt0.x += line_height * up.x;
- pt0.y += line_height * up.y;
- pt1.x += line_height * up.x;
- pt1.y += line_height * up.y;
+ ll.x += line_height * up.x;
+ ll.y += line_height * up.y;
+ lr.x += line_height * up.x;
+ lr.y += line_height * up.y;
thickness = sqrtf(up.x * up.x + up.y * up.y) * line_thickness;
@@ -1750,8 +1753,8 @@ void pdf_set_markup_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *an
path = fz_new_path(ctx);
}
- fz_moveto(ctx, path, pt0.x, pt0.y);
- fz_lineto(ctx, path, pt1.x, pt1.y);
+ fz_moveto(ctx, path, ll.x, ll.y);
+ fz_lineto(ctx, path, lr.x, lr.y);
}
if (stroke)