[ot] Fix automatic fraction for RTL scripts (#405)

The numbers for right-to-left scripts are processed also from right to
left, so the order of applying “numr” and “dnom” features should be
reversed in such case.

Fixes https://github.com/behdad/harfbuzz/issues/395
This commit is contained in:
Khaled Hosny 2017-01-18 22:48:13 +02:00 committed by Behdad Esfahbod
parent 1337428e4f
commit 2452543fdd
4 changed files with 18 additions and 2 deletions

View File

@ -362,6 +362,18 @@ hb_ot_shape_setup_masks_fraction (hb_ot_shape_context_t *c)
hb_buffer_t *buffer = c->buffer;
hb_mask_t pre_mask, post_mask;
if (HB_DIRECTION_IS_FORWARD (buffer->props.direction))
{
pre_mask = c->plan->numr_mask | c->plan->frac_mask;
post_mask = c->plan->frac_mask | c->plan->dnom_mask;
}
else
{
pre_mask = c->plan->frac_mask | c->plan->dnom_mask;
post_mask = c->plan->numr_mask | c->plan->frac_mask;
}
/* TODO look in pre/post context text also. */
unsigned int count = buffer->len;
hb_glyph_info_t *info = buffer->info;
@ -380,10 +392,10 @@ hb_ot_shape_setup_masks_fraction (hb_ot_shape_context_t *c)
end++;
for (unsigned int j = start; j < i; j++)
info[j].mask |= c->plan->numr_mask | c->plan->frac_mask;
info[j].mask |= pre_mask;
info[i].mask |= c->plan->frac_mask;
for (unsigned int j = i + 1; j < end; j++)
info[j].mask |= c->plan->frac_mask | c->plan->dnom_mask;
info[j].mask |= post_mask;
i = end - 1;
}

View File

@ -43,6 +43,7 @@ CLEANFILES += \
TESTS = \
tests/arabic-fallback-shaping.tests \
tests/arabic-feature-order.tests \
tests/automatic-fractions.tests \
tests/cluster.tests \
tests/color-fonts.tests \
tests/context-matching.tests \

View File

@ -0,0 +1,3 @@
fonts/sha1sum/15dfc433a135a658b9f4b1a861b5cdd9658ccbb9.ttf::U+0031,U+0032,U+0033,U+2044,U+0034,U+0035,U+0036:[one.numr=0+600|two.numr=1+600|three.numr=2+600|fraction=3+252|four.small=4+600|five.small=5+600|six.small=6+600]
fonts/sha1sum/15dfc433a135a658b9f4b1a861b5cdd9658ccbb9.ttf:--direction=l --script=arab:U+0031,U+0032,U+0033,U+2044,U+0034,U+0035,U+0036:[one.numr=0+600|two.numr=1+600|three.numr=2+600|fraction=3+252|four.small=4+600|five.small=5+600|six.small=6+600]
fonts/sha1sum/15dfc433a135a658b9f4b1a861b5cdd9658ccbb9.ttf:--direction=l:U+0661,U+0662,U+0663,U+2044,U+0664,U+0665,U+0666:[uni0661.numr=0+600|uni0662.numr=1+600|uni0663.numr=2+600|fraction=3+252|uni0664.small=4+600|uni0665.small=5+600|uni0666.small=6+600]