From 2901c7d78c9880b6fda7ccf9b000d847724071e4 Mon Sep 17 00:00:00 2001 From: Paul Gardiner Date: Tue, 5 Nov 2013 16:48:13 +0000 Subject: Fix bug 694730: Wrong bbox in one-point ink annotation Zero and one-point case both lead to an empty rectangle, but the one-point case needs expanding but wasn't because fz_expand_rect treats an empty rectangle as a special case (as it should) --- source/pdf/pdf-annot.c | 14 +++++++++++++- source/pdf/pdf-appearance.c | 15 +++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c index 21cc00cc..338ca1ac 100644 --- a/source/pdf/pdf-annot.c +++ b/source/pdf/pdf-annot.c @@ -920,7 +920,19 @@ pdf_set_ink_annot_list(pdf_document *doc, pdf_annot *annot, fz_point *pts, int * } } - fz_expand_rect(&rect, thickness); + /* + Expand the rectangle by thickness all around. We cannot use + fz_expand_rect because the rectangle might be empty in the + single point case + */ + if (k > 0) + { + rect.x0 -= thickness; + rect.y0 -= thickness; + rect.x1 += thickness; + rect.y1 += thickness; + } + pdf_dict_puts_drop(annot->obj, "Rect", pdf_new_rect(doc, &rect)); update_rect(ctx, annot); diff --git a/source/pdf/pdf-appearance.c b/source/pdf/pdf-appearance.c index 0b1a290a..21cf5ae2 100644 --- a/source/pdf/pdf-appearance.c +++ b/source/pdf/pdf-appearance.c @@ -1580,6 +1580,7 @@ void pdf_update_ink_appearance(pdf_document *doc, pdf_annot *annot) float width; pdf_obj *list; int n, m, i, j; + int empty = 1; cs = pdf_to_color(doc, pdf_dict_gets(annot->obj, "C"), color); if (!cs) @@ -1620,6 +1621,7 @@ void pdf_update_ink_appearance(pdf_document *doc, pdf_annot *annot) { rect.x0 = rect.x1 = pt.x; rect.y0 = rect.y1 = pt.y; + empty = 0; } else { @@ -1638,6 +1640,19 @@ void pdf_update_ink_appearance(pdf_document *doc, pdf_annot *annot) fz_stroke_path(dev, path, stroke, page_ctm, cs, color, 1.0f); fz_expand_rect(&rect, width); + /* + Expand the rectangle by width all around. We cannot use + fz_expand_rect because the rectangle might be empty in the + single point case + */ + if (!empty) + { + rect.x0 -= width; + rect.y0 -= width; + rect.x1 += width; + rect.y1 += width; + } + fz_transform_rect(&rect, page_ctm); pdf_set_annot_appearance(doc, annot, &rect, strike_list); -- cgit v1.2.3