summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-01-18 20:17:00 +0000
committerRobin Watts <robin.watts@artifex.com>2016-01-18 20:17:48 +0000
commitac27f6c40787c34830b5273ca51fb915d341c697 (patch)
tree7da7db02e9e343835419cbec22f7093a5320d5c2
parent0455fb54f5c7291c43ec782c11499ef074284cbc (diff)
downloadmupdf-ac27f6c40787c34830b5273ca51fb915d341c697.tar.xz
Add support for bidirectional mirror characters
-rw-r--r--include/mupdf/html.h1
-rw-r--r--source/html/html-layout.c11
2 files changed, 12 insertions, 0 deletions
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;