diff options
author | Paul Gardiner <paulg.artifex@glidos.net> | 2013-07-30 12:19:11 +0100 |
---|---|---|
committer | Paul Gardiner <paulg.artifex@glidos.net> | 2013-07-30 12:19:11 +0100 |
commit | 08ad4bfc090a471b03c08d41c316133b3884eb19 (patch) | |
tree | d09b5734ec64df08af4d904673b9720d3ac5fd82 /source | |
parent | 324defe51aae2d8ca012caa6d555addca288766a (diff) | |
download | mupdf-08ad4bfc090a471b03c08d41c316133b3884eb19.tar.xz |
For freetext annotations, distinguish device and page space correctly.
Diffstat (limited to 'source')
-rw-r--r-- | source/pdf/pdf-annot.c | 13 | ||||
-rw-r--r-- | source/pdf/pdf-appearance.c | 11 |
2 files changed, 16 insertions, 8 deletions
diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c index c0254756..d137b162 100644 --- a/source/pdf/pdf-annot.c +++ b/source/pdf/pdf-annot.c @@ -953,6 +953,7 @@ void pdf_set_free_text_details(pdf_document *doc, pdf_annot *annot, fz_point *po pdf_da_info da_info; fz_buffer *fzbuf = NULL; fz_matrix ctm; + fz_point page_pos; fz_invert_matrix(&ctm, &annot->page->ctm); @@ -1008,16 +1009,18 @@ void pdf_set_free_text_details(pdf_document *doc, pdf_annot *annot, fz_point *po font_desc = pdf_load_font(doc, NULL, font, 0); pdf_measure_text(ctx, font_desc, (unsigned char *)text, strlen(text), &bounds); + page_pos = *pos; + fz_transform_point(&page_pos, &ctm); + bounds.x0 *= font_size; bounds.x1 *= font_size; bounds.y0 *= font_size; bounds.y1 *= font_size; - bounds.x0 += pos->x; - bounds.x1 += pos->x; - bounds.y0 += pos->y; - bounds.y1 += pos->y; - fz_transform_rect(&bounds, &ctm); + bounds.x0 += page_pos.x; + bounds.x1 += page_pos.x; + bounds.y0 += page_pos.y; + bounds.y1 += page_pos.y; pdf_dict_puts_drop(annot->obj, "Rect", pdf_new_rect(doc, &bounds)); update_rect(ctx, annot); diff --git a/source/pdf/pdf-appearance.c b/source/pdf/pdf-appearance.c index e7c3190d..81781ba6 100644 --- a/source/pdf/pdf-appearance.c +++ b/source/pdf/pdf-appearance.c @@ -1698,6 +1698,7 @@ void pdf_update_free_text_annot_appearance(pdf_document *doc, pdf_annot *annot) char *contents = pdf_to_str_buf(pdf_dict_gets(obj, "Contents")); char *da = pdf_to_str_buf(pdf_dict_gets(obj, "DA")); fz_rect rect = annot->rect; + fz_point pos; get_font_info(doc, dr, da, &font_rec); @@ -1708,14 +1709,18 @@ void pdf_update_free_text_annot_appearance(pdf_document *doc, pdf_annot *annot) case 4: cs = fz_device_cmyk(doc->ctx); break; } - fz_transform_rect(&rect, page_ctm); - text = layout_text(ctx, &font_rec, contents, rect.x0, rect.y0); + /* Adjust for the descender */ + pos.x = rect.x0; + pos.y = rect.y0 - font_rec.font->descent * font_rec.da_rec.font_size / 1000.0f; + + text = layout_text(ctx, &font_rec, contents, pos.x, pos.y); dlist = fz_new_display_list(ctx); dev = fz_new_list_device(ctx, dlist); fz_fill_text(dev, text, page_ctm, cs, font_rec.da_rec.col, 1.0f); - pdf_set_annot_appearance(doc, annot, &annot->rect, dlist); + fz_transform_rect(&rect, page_ctm); + pdf_set_annot_appearance(doc, annot, &rect, dlist); } fz_always(ctx) { |