[hebrew] Implement Jerusalem mark reordering

Fixes https://github.com/harfbuzz/harfbuzz/issues/2947
This commit is contained in:
Behdad Esfahbod 2022-07-20 10:24:54 -06:00
parent 605bb1ee3d
commit c60d810d50
1 changed files with 26 additions and 1 deletions

View File

@ -162,6 +162,31 @@ compose_hebrew (const hb_ot_shape_normalize_context_t *c,
return found;
}
static void
reorder_marks_hebrew (const hb_ot_shape_plan_t *plan HB_UNUSED,
hb_buffer_t *buffer,
unsigned int start,
unsigned int end)
{
hb_glyph_info_t *info = buffer->info;
for (unsigned i = start + 2; i < end; i++)
{
unsigned c0 = info_cc (info[i - 2]);
unsigned c1 = info_cc (info[i - 1]);
unsigned c2 = info_cc (info[i - 0]);
if ((c0 == HB_MODIFIED_COMBINING_CLASS_CCC17 || c0 == HB_MODIFIED_COMBINING_CLASS_CCC18) /* patach or qamats */ &&
(c1 == HB_MODIFIED_COMBINING_CLASS_CCC10 || c1 == HB_MODIFIED_COMBINING_CLASS_CCC14) /* sheva or hiriq */ &&
(c2 == HB_MODIFIED_COMBINING_CLASS_CCC22 || c2 == HB_UNICODE_COMBINING_CLASS_BELOW) /* meteg or below */)
{
buffer->merge_clusters (i - 1, i + 1);
hb_swap (info[i - 1], info[i]);
}
}
}
const hb_ot_shaper_t _hb_ot_shaper_hebrew =
{
@ -174,7 +199,7 @@ const hb_ot_shaper_t _hb_ot_shaper_hebrew =
nullptr, /* decompose */
compose_hebrew,
nullptr, /* setup_masks */
nullptr, /* reorder_marks */
reorder_marks_hebrew,
HB_TAG ('h','e','b','r'), /* gpos_tag. https://github.com/harfbuzz/harfbuzz/issues/347#issuecomment-267838368 */
HB_OT_SHAPE_NORMALIZATION_MODE_DEFAULT,
HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_GDEF_LATE,