summaryrefslogtreecommitdiff
path: root/apps/pdfapp.c
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2011-03-06 16:06:21 +0000
committerTor Andersson <tor@ghostscript.com>2011-03-06 16:06:21 +0000
commit4ba609fc289b18823a51093c8afea750c5636a5c (patch)
treed63792958e70b7c0b3064c8ed64edbe1a51d8a2d /apps/pdfapp.c
parent538d304ab289364510eaff37308bb8f4d6293d7b (diff)
downloadmupdf-4ba609fc289b18823a51093c8afea750c5636a5c.tar.xz
Transform text hitboxes to get the correct text when copying the selection.
Diffstat (limited to 'apps/pdfapp.c')
-rw-r--r--apps/pdfapp.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/apps/pdfapp.c b/apps/pdfapp.c
index 3980c57d..2fca8d0c 100644
--- a/apps/pdfapp.c
+++ b/apps/pdfapp.c
@@ -991,7 +991,8 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int sta
void pdfapp_oncopy(pdfapp_t *app, unsigned short *ucsbuf, int ucslen)
{
- int bx0, bx1, by0, by1;
+ fz_bbox hitbox;
+ fz_matrix ctm;
fz_textspan *span;
int c, i, p;
int seen;
@@ -1001,6 +1002,8 @@ void pdfapp_oncopy(pdfapp_t *app, unsigned short *ucsbuf, int ucslen)
int y0 = app->selr.y0;
int y1 = app->selr.y1;
+ ctm = pdfapp_viewctm(app);
+
p = 0;
for (span = app->page->text; span; span = span->next)
{
@@ -1008,15 +1011,11 @@ void pdfapp_oncopy(pdfapp_t *app, unsigned short *ucsbuf, int ucslen)
for (i = 0; i < span->len; i++)
{
- bx0 = span->text[i].bbox.x0;
- bx1 = span->text[i].bbox.x1;
- by0 = span->text[i].bbox.y0;
- by1 = span->text[i].bbox.y1;
-
+ hitbox = fz_transformbbox(ctm, span->text[i].bbox);
c = span->text[i].c;
if (c < 32)
c = '?';
- if (bx1 >= x0 && bx0 <= x1 && by1 >= y0 && by0 <= y1)
+ if (hitbox.x1 >= x0 && hitbox.x0 <= x1 && hitbox.y1 >= y0 && hitbox.y0 <= y1)
{
if (p < ucslen - 1)
ucsbuf[p++] = c;