提交 2f02fc79 编写于 作者: B Behdad Esfahbod

Improve ligature-component handling

We use three bits for lig_id these days, so we finally got a report of
two separate ligatures with the same lig_id happening adjacent to each
other, and then the component-handling code was breaking things.
Protect against that by ignoring same-lig-id but lig-comp=0 glyphs after
a new ligature.

Fixes https://github.com/behdad/harfbuzz/issues/198
上级 2ab0de9f
......@@ -845,9 +845,12 @@ static inline bool ligate_input (hb_apply_context_t *c,
while (buffer->idx < match_positions[i] && !buffer->in_error)
{
if (!is_mark_ligature) {
unsigned int this_comp = _hb_glyph_info_get_lig_comp (&buffer->cur());
if (this_comp == 0)
this_comp = 1;
unsigned int new_lig_comp = components_so_far - last_num_components +
MIN (MAX (_hb_glyph_info_get_lig_comp (&buffer->cur()), 1u), last_num_components);
_hb_glyph_info_set_lig_props_for_mark (&buffer->cur(), lig_id, new_lig_comp);
MIN (this_comp, last_num_components);
_hb_glyph_info_set_lig_props_for_mark (&buffer->cur(), lig_id, new_lig_comp);
}
buffer->next_glyph ();
}
......@@ -864,8 +867,11 @@ static inline bool ligate_input (hb_apply_context_t *c,
/* Re-adjust components for any marks following. */
for (unsigned int i = buffer->idx; i < buffer->len; i++) {
if (last_lig_id == _hb_glyph_info_get_lig_id (&buffer->info[i])) {
unsigned int this_comp = _hb_glyph_info_get_lig_comp (&buffer->info[i]);
if (!this_comp)
break;
unsigned int new_lig_comp = components_so_far - last_num_components +
MIN (MAX (_hb_glyph_info_get_lig_comp (&buffer->info[i]), 1u), last_num_components);
MIN (this_comp, last_num_components);
_hb_glyph_info_set_lig_props_for_mark (&buffer->info[i], lig_id, new_lig_comp);
} else
break;
......
......@@ -52,6 +52,7 @@ TESTS = \
tests/indic-joiner-candrabindu.tests \
tests/indic-old-spec.tests \
tests/indic-pref-blocking.tests \
tests/ligature-id.tests \
tests/mongolian-variation-selector.tests \
tests/spaces.tests \
tests/simple.tests \
......
......@@ -30,6 +30,7 @@ b9e2aaa0d75fcef6971ec3a96d806ba4a6b31fe2.ttf
bb29ce50df2bdba2d10726427c6b7609bf460e04.ttf
bb9473d2403488714043bcfb946c9f78b86ad627.ttf
c4e48b0886ef460f532fb49f00047ec92c432ec0.ttf
c78d1f25ea1df1210414f2fe2e0e1e53082bba76.ttf
d629e7fedc0b350222d7987345fe61613fa3929a.ttf
df768b9c257e0c9c35786c47cae15c46571d56be.ttf
e207635780b42f898d58654b65098763e340f5c7.ttf
......
......@@ -10,6 +10,7 @@ hyphens.tests
indic-joiner-candrabindu.tests
indic-old-spec.tests
indic-pref-blocking.tests
ligature-id.tests
mongolian-variation-selector.tests
simple.tests
spaces.tests
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册