From ac27f6c40787c34830b5273ca51fb915d341c697 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Mon, 18 Jan 2016 20:17:00 +0000 Subject: Add support for bidirectional mirror characters --- include/mupdf/html.h | 1 + source/html/html-layout.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/mupdf/html.h b/include/mupdf/html.h index fd42ec08..546a4fbb 100644 --- a/include/mupdf/html.h +++ b/include/mupdf/html.h @@ -213,6 +213,7 @@ struct fz_html_flow_s unsigned int expand : 1; unsigned int char_r2l : 1; unsigned int block_r2l : 1; + unsigned int mirror : 1; float x, y, w, h, em; fz_css_style *style; union { diff --git a/source/html/html-layout.c b/source/html/html-layout.c index 4f7091fa..af480cbc 100644 --- a/source/html/html-layout.c +++ b/source/html/html-layout.c @@ -80,6 +80,7 @@ static fz_html_flow *add_flow(fz_context *ctx, fz_pool *pool, fz_html *top, fz_c flow->expand = 0; flow->char_r2l = 0; flow->block_r2l = 0; + flow->mirror = 0; flow->style = style; *top->flow_tail = flow; top->flow_tail = &flow->next; @@ -938,6 +939,10 @@ static void draw_flow_box(fz_context *ctx, fz_html *box, float page_top, float p while (*t) { t += fz_chartorune(&c, t); + if (node->mirror) + { + c = Bidi_mirrorChar(c); + } g = fz_encode_character(ctx, node->style->font, c); if (g) { @@ -962,6 +967,10 @@ static void draw_flow_box(fz_context *ctx, fz_html *box, float page_top, float p while (*s) { s += fz_chartorune(&c, s); + if (node->mirror) + { + c = Bidi_mirrorChar(c); + } g = fz_encode_character(ctx, node->style->font, c); if (g) { @@ -1537,6 +1546,8 @@ static void newFragCb(const uint16_t *fragment, /* This flow box is entirely contained within this fragment. */ data->flow->block_r2l = rightToLeft; data->flow->char_r2l = charDirR2L; + if (mirror != 0) + data->flow->mirror = 1; data->flow = data->flow->next; fragmentOffset += len; fragmentLen -= len; -- cgit v1.2.3