summaryrefslogtreecommitdiff
path: root/source/xps
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-08-15 14:32:02 +0200
committerTor Andersson <tor.andersson@artifex.com>2016-08-24 14:09:06 +0200
commit7bb57105fad01e11c251f3b464d2719df2632c08 (patch)
treeb051c1fea7374a6ee179d9ddc2695cc8aa987f16 /source/xps
parent8fa9a79da6291aef74efab136f666047487cd526 (diff)
downloadmupdf-7bb57105fad01e11c251f3b464d2719df2632c08.tar.xz
Bug 696983 - Fix bidirectional XPS spacing.
Bidirectional setting was not accounted for when advance width was set in the XPS Indices Attribute.
Diffstat (limited to 'source/xps')
-rw-r--r--source/xps/xps-glyphs.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/source/xps/xps-glyphs.c b/source/xps/xps-glyphs.c
index de153dc2..a5d3f196 100644
--- a/source/xps/xps-glyphs.c
+++ b/source/xps/xps-glyphs.c
@@ -293,7 +293,7 @@ static inline int is_real_num_char(int c)
}
static char *
-xps_parse_real_num(char *s, float *number)
+xps_parse_real_num(char *s, float *number, int *override)
{
char buf[64];
char *p = buf;
@@ -301,7 +301,14 @@ xps_parse_real_num(char *s, float *number)
*p++ = *s++;
*p = 0;
if (buf[0])
+ {
+ *override = 1;
*number = fz_atof(buf);
+ }
+ else
+ {
+ *override = 0;
+ }
return s;
}
@@ -326,14 +333,19 @@ xps_parse_glyph_index(char *s, int *glyph_index)
}
static char *
-xps_parse_glyph_metrics(char *s, float *advance, float *uofs, float *vofs)
+xps_parse_glyph_metrics(char *s, float *advance, float *uofs, float *vofs, int bidi_level)
{
+ int override;
if (*s == ',')
- s = xps_parse_real_num(s + 1, advance);
+ {
+ s = xps_parse_real_num(s + 1, advance, &override);
+ if (override && (bidi_level & 1))
+ *advance = -*advance;
+ }
if (*s == ',')
- s = xps_parse_real_num(s + 1, uofs);
+ s = xps_parse_real_num(s + 1, uofs, &override);
if (*s == ',')
- s = xps_parse_real_num(s + 1, vofs);
+ s = xps_parse_real_num(s + 1, vofs, &override);
return s;
}
@@ -429,7 +441,7 @@ xps_parse_glyphs_imp(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
if (is && *is)
{
- is = xps_parse_glyph_metrics(is, &advance, &u_offset, &v_offset);
+ is = xps_parse_glyph_metrics(is, &advance, &u_offset, &v_offset, bidi_level);
if (*is == ';')
is ++;
}