diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2012-03-19 17:45:54 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2012-03-19 17:54:43 +0100 |
commit | 40ae12884335856f803dc76bfbe97b1c8743b9b9 (patch) | |
tree | 1691ae74c6277d1caae2961718d3a07921545e3d /fitz/dev_text.c | |
parent | 51cdfc4b174b6175c8dd1827998224ca680f3ca7 (diff) | |
download | mupdf-40ae12884335856f803dc76bfbe97b1c8743b9b9.tar.xz |
Fix typo in text device where lines would group into blocks too eagerly.
The default page userspace transform changed to a top-down coordinate
space, and I forgot this detail when updating the text device branch.
Also remove the final block sorting pass to give preference to the original
PDF text order.
Diffstat (limited to 'fitz/dev_text.c')
-rw-r--r-- | fitz/dev_text.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/fitz/dev_text.c b/fitz/dev_text.c index fb6ebdc6..5e7f8164 100644 --- a/fitz/dev_text.c +++ b/fitz/dev_text.c @@ -190,10 +190,12 @@ lookup_block_for_line(fz_context *ctx, fz_text_page *page, fz_text_line *line) for (i = 0; i < page->len; i++) { fz_text_block *block = page->blocks + i; - int w = block->bbox.x1 - block->bbox.x0; - if (block->bbox.y0 - line->bbox.y1 < size * PARAGRAPH_DIST) - if (line->bbox.x0 < block->bbox.x1 && line->bbox.x1 > block->bbox.x0) - if (ABS(line->bbox.x0 - block->bbox.x0) < w / 4) + float w = block->bbox.x1 - block->bbox.x0; + float dx = line->bbox.x0 - block->bbox.x0; + float dy = line->bbox.y0 - block->bbox.y1; + if (dy > -size * 1.5f && dy < size * PARAGRAPH_DIST) + if (line->bbox.x0 <= block->bbox.x1 && line->bbox.x1 >= block->bbox.x0) + if (ABS(dx) < w / 2) return block; } @@ -498,15 +500,6 @@ fz_text_ignore_text(fz_device *dev, fz_text *text, fz_matrix ctm) fz_text_extract(dev->ctx, tdev, text, ctm, style); } -static int cmp_block(const void *av, const void *bv) -{ - const fz_text_block *a = av; - const fz_text_block *b = bv; - int x = a->bbox.x0 - b->bbox.x0; - if (x) return x; - return -(a->bbox.y0 - b->bbox.y0); -} - static void fz_text_free_user(fz_device *dev) { @@ -516,8 +509,7 @@ fz_text_free_user(fz_device *dev) append_span(ctx, &tdev->cur_line, &tdev->cur_span); insert_line(ctx, tdev->page, &tdev->cur_line); - qsort(tdev->page->blocks, tdev->page->len, sizeof *tdev->page->blocks, cmp_block); - + /* TODO: smart sorting of blocks in reading order */ /* TODO: unicode NFC normalization */ /* TODO: bidi logical reordering */ |