From 94a5846502cd1f05ec4127872ef06dcd8606f34b Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 7 Nov 2017 19:32:37 +0100 Subject: Remove broken bidi reordering code. TODO: Implement visual to logical reordering on the fly when building the structured text line. --- source/fitz/stext-device.c | 80 +++------------------------------------------- source/fitz/stext-search.c | 4 +-- source/fitz/trace-device.c | 2 +- 3 files changed, 7 insertions(+), 79 deletions(-) (limited to 'source/fitz') diff --git a/source/fitz/stext-device.c b/source/fitz/stext-device.c index 117cd72e..cae3c583 100644 --- a/source/fitz/stext-device.c +++ b/source/fitz/stext-device.c @@ -135,7 +135,7 @@ static float max4(float a, float b, float c, float d) } static fz_stext_char * -add_char_to_line(fz_context *ctx, fz_stext_page *page, fz_stext_line *line, const fz_matrix *trm, fz_font *font, float size, int c, fz_point *p, fz_point *q, int rtl) +add_char_to_line(fz_context *ctx, fz_stext_page *page, fz_stext_line *line, const fz_matrix *trm, fz_font *font, float size, int c, fz_point *p, fz_point *q) { fz_stext_char *ch = fz_pool_alloc(ctx, page->pool, sizeof *line->first_char); fz_point a, d; @@ -149,7 +149,6 @@ add_char_to_line(fz_context *ctx, fz_stext_page *page, fz_stext_line *line, cons } ch->c = c; - ch->rtl = rtl; ch->origin = *p; ch->size = size; ch->font = font; /* TODO: keep and drop */ @@ -294,7 +293,7 @@ fz_add_stext_char_imp(fz_context *ctx, fz_stext_device *dev, fz_font *font, int if (cur_line && glyph < 0) { /* Don't advance pen or break lines for no-glyph characters in a cluster */ - add_char_to_line(ctx, page, cur_line, trm, font, size, c, &dev->pen, &dev->pen, 0); + add_char_to_line(ctx, page, cur_line, trm, font, size, c, &dev->pen, &dev->pen); dev->lastchar = c; return; } @@ -395,9 +394,9 @@ fz_add_stext_char_imp(fz_context *ctx, fz_stext_device *dev, fz_font *font, int /* Add synthetic space */ if (add_space) - add_char_to_line(ctx, page, cur_line, trm, font, size, ' ', &dev->pen, &p, rtl); + add_char_to_line(ctx, page, cur_line, trm, font, size, ' ', &dev->pen, &p); - add_char_to_line(ctx, page, cur_line, trm, font, size, c, &p, &q, rtl); + add_char_to_line(ctx, page, cur_line, trm, font, size, c, &p, &q); dev->lastchar = c; dev->pen = q; @@ -633,75 +632,6 @@ fz_stext_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_m fz_rethrow(ctx); } -/* RTL visual to logical order pass */ - -static void -fz_bidi_reorder_run(fz_stext_char *a, fz_stext_char *b, int dir) -{ - if (a < b && dir == -1) - { - fz_stext_char tmp; - fz_stext_char *m = a + (b - a) / 2; - while (a < m) - { - b--; - - tmp.c = a->c; - tmp.origin = a->origin; - tmp.bbox = a->bbox; - tmp.size = a->size; - tmp.font = a->font; - - a->c = b->c; - a->origin = b->origin; - a->bbox = b->bbox; - a->size = b->size; - a->font = b->font; - - b->c = tmp.c; - b->origin = tmp.origin; - b->bbox = tmp.bbox; - b->size = tmp.size; - b->font = tmp.font; - - a++; - } - } -} - -static void -fz_bidi_reorder_line(fz_stext_line *line) -{ - fz_stext_char *a, *b; - int dir, curdir; - - a = line->first_char; - curdir = 0; - for (b = line->first_char; b; b = b->next) - { - dir = b->rtl; - if (dir != curdir) - { - fz_bidi_reorder_run(a, b, curdir); - curdir = dir; - a = b; - } - } - fz_bidi_reorder_run(a, b, curdir); -} - -static void -fz_bidi_reorder_stext_page(fz_context *ctx, fz_stext_page *page) -{ - fz_stext_block *block; - fz_stext_line *line; - - for (block = page->first_block; block; block = block->next) - if (block->type == FZ_STEXT_BLOCK_TEXT) - for (line = block->u.t.first_line; line; line = line->next) - fz_bidi_reorder_line(line); -} - static void fz_stext_close_device(fz_context *ctx, fz_device *dev) { @@ -726,8 +656,6 @@ fz_stext_close_device(fz_context *ctx, fz_device *dev) /* TODO: smart sorting of blocks and lines in reading order */ /* TODO: unicode NFC normalization */ - - fz_bidi_reorder_stext_page(ctx, tdev->page); } static void diff --git a/source/fitz/stext-search.c b/source/fitz/stext-search.c index d9da2900..c8fbdc0b 100644 --- a/source/fitz/stext-search.c +++ b/source/fitz/stext-search.c @@ -40,8 +40,8 @@ int fz_stext_char_count(fz_context *ctx, fz_stext_page *page) const fz_stext_char *fz_stext_char_at(fz_context *ctx, fz_stext_page *page, int idx) { - static const fz_stext_char space = { ' ', 0, {0,0}, {0,0,0,0}, 0, NULL, NULL }; - static const fz_stext_char zero = { '\0', 0, {0,0}, {0,0,0,0}, 0, NULL, NULL }; + static const fz_stext_char space = { ' ', {0,0}, {0,0,0,0}, 0, NULL, NULL }; + static const fz_stext_char zero = { '\0', {0,0}, {0,0,0,0}, 0, NULL, NULL }; fz_stext_block *block; fz_stext_line *line; fz_stext_char *ch; diff --git a/source/fitz/trace-device.c b/source/fitz/trace-device.c index 2b7b24aa..65c91924 100644 --- a/source/fitz/trace-device.c +++ b/source/fitz/trace-device.c @@ -39,7 +39,7 @@ static void fz_trace_text_span(fz_context *ctx, fz_output *out, fz_text_span *span) { int i; - fz_write_printf(ctx, out, "font), span->wmode); + fz_write_printf(ctx, out, "font), span->wmode, span->bidi_level); fz_write_printf(ctx, out, " trm=\"%g %g %g %g\">\n", span->trm.a, span->trm.b, span->trm.c, span->trm.d); for (i = 0; i < span->len; i++) { -- cgit v1.2.3