summaryrefslogtreecommitdiff
path: root/source/html
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-01-18 19:59:05 +0000
committerRobin Watts <robin.watts@artifex.com>2016-01-18 19:59:05 +0000
commitf0b5caf942091d7b43bfc987689b5fd3302f5c80 (patch)
tree34ce3cfe79796896c8ef3d3631c81d95abcfe0b7 /source/html
parent61e63f3a680f8cfe4df040b4de5f0c5805610c29 (diff)
downloadmupdf-f0b5caf942091d7b43bfc987689b5fd3302f5c80.tar.xz
Implement R2L characterwise plotting in the html layout.
Diffstat (limited to 'source/html')
-rw-r--r--source/html/html-layout.c86
1 files changed, 74 insertions, 12 deletions
diff --git a/source/html/html-layout.c b/source/html/html-layout.c
index f714c219..dc37541c 100644
--- a/source/html/html-layout.c
+++ b/source/html/html-layout.c
@@ -930,32 +930,94 @@ static void draw_flow_box(fz_context *ctx, fz_html *box, float page_top, float p
trm.e = node->x;
trm.f = node->y;
s = node->text;
- while (*s)
+ if (node->char_r2l)
{
- s += fz_chartorune(&c, s);
- g = fz_encode_character(ctx, node->style->font, c);
- if (g)
+ float w = 0;
+ const char *t = s;
+
+ while (*t)
{
- if (node->style->visibility == V_VISIBLE)
- fz_add_text(ctx, text, node->style->font, 0, &trm, g, c);
- trm.e += fz_advance_glyph(ctx, node->style->font, g) * node->em;
+ t += fz_chartorune(&c, t);
+ g = fz_encode_character(ctx, node->style->font, c);
+ if (g)
+ {
+ w += fz_advance_glyph(ctx, node->style->font, g) * node->em;
+ }
+ else
+ {
+ g = fz_encode_character(ctx, node->style->fallback, c);
+ if (g)
+ {
+ w += fz_advance_glyph(ctx, node->style->fallback, g) * node->em;
+ }
+ else
+ {
+ g = fz_encode_character(ctx, node->style->font, 0x25CF); /* bullet */
+ w += fz_advance_glyph(ctx, node->style->font, g) * node->em;
+ }
+ }
}
- else
+
+ trm.e += w;
+ while (*s)
{
- g = fz_encode_character(ctx, node->style->fallback, c);
+ s += fz_chartorune(&c, s);
+ g = fz_encode_character(ctx, node->style->font, c);
if (g)
{
+ trm.e -= fz_advance_glyph(ctx, node->style->font, g) * node->em;
if (node->style->visibility == V_VISIBLE)
- fz_add_text(ctx, text, node->style->fallback, 0, &trm, g, c);
- trm.e += fz_advance_glyph(ctx, node->style->fallback, g) * node->em;
+ fz_add_text(ctx, text, node->style->font, 0, &trm, g, c);
}
else
{
- g = fz_encode_character(ctx, node->style->font, 0x25CF); /* bullet */
+ g = fz_encode_character(ctx, node->style->fallback, c);
+ if (g)
+ {
+ trm.e -= fz_advance_glyph(ctx, node->style->fallback, g) * node->em;
+ if (node->style->visibility == V_VISIBLE)
+ fz_add_text(ctx, text, node->style->fallback, 0, &trm, g, c);
+ }
+ else
+ {
+ trm.e -= fz_advance_glyph(ctx, node->style->font, g) * node->em;
+ g = fz_encode_character(ctx, node->style->font, 0x25CF); /* bullet */
+ if (node->style->visibility == V_VISIBLE)
+ fz_add_text(ctx, text, node->style->font, 0, &trm, g, c);
+ }
+ }
+ }
+ trm.e += w;
+ }
+ else
+ {
+ while (*s)
+ {
+ s += fz_chartorune(&c, s);
+ g = fz_encode_character(ctx, node->style->font, c);
+ if (g)
+ {
if (node->style->visibility == V_VISIBLE)
fz_add_text(ctx, text, node->style->font, 0, &trm, g, c);
trm.e += fz_advance_glyph(ctx, node->style->font, g) * node->em;
}
+ else
+ {
+ g = fz_encode_character(ctx, node->style->fallback, c);
+ if (g)
+ {
+ if (node->style->visibility == V_VISIBLE)
+ fz_add_text(ctx, text, node->style->fallback, 0, &trm, g, c);
+ trm.e += fz_advance_glyph(ctx, node->style->fallback, g) * node->em;
+ }
+ else
+ {
+ g = fz_encode_character(ctx, node->style->font, 0x25CF); /* bullet */
+ if (node->style->visibility == V_VISIBLE)
+ fz_add_text(ctx, text, node->style->font, 0, &trm, g, c);
+ trm.e += fz_advance_glyph(ctx, node->style->font, g) * node->em;
+ }
+ }
}
}