[Indic-like] Disable automatic joiner handling for basic shaping features
Not for Arabic, but for Indic-like scripts. ZWJ/ZWNJ have special
meanings in those scripts, so let font lookups take full control.
This undoes the regression caused by automatic-joiners handling
introduced two commits ago.
We only disable automatic joiner handling for the "basic shaping
features" of Indic, Myanmar, and SEAsian shapers. The "presentation
forms" and other features are still applied with automatic-joiner
handling.
This change also changes the test suite failure statistics, such that
a few scripts show more "failures". The most affected is Kannada.
However, upon inspection, we believe that in most, if not all, of the
new failures, we are producing results superior to Uniscribe. Hard to
count those!
Here's an example of what is fixed by the recent joiner-handling
changes:
https://bugs.freedesktop.org/show_bug.cgi?id=58714
New numbers, for future reference:
BENGALI: 353892 out of 354188 tests passed. 296 failed (0.0835714%)
DEVANAGARI: 707336 out of 707394 tests passed. 58 failed (0.00819911%)
GUJARATI: 366262 out of 366457 tests passed. 195 failed (0.0532122%)
GURMUKHI: 60706 out of 60747 tests passed. 41 failed (0.067493%)
KANNADA: 950680 out of 951913 tests passed. 1233 failed (0.129529%)
KHMER: 299074 out of 299124 tests passed. 50 failed (0.0167155%)
LAO: 53611 out of 53644 tests passed. 33 failed (0.0615167%)
MALAYALAM: 1047983 out of 1048334 tests passed. 351 failed (0.0334817%)
ORIYA: 42320 out of 42329 tests passed. 9 failed (0.021262%)
SINHALA: 271539 out of 271847 tests passed. 308 failed (0.113299%)
TAMIL: 1091753 out of 1091754 tests passed. 1 failed (9.15957e-05%)
TELUGU: 970555 out of 970573 tests passed. 18 failed (0.00185457%)
TIBETAN: 208469 out of 208469 tests passed. 0 failed (0%)
diff --git a/src/hb-ot-map.cc b/src/hb-ot-map.cc
index 7848186..2fbb6ce 100644
--- a/src/hb-ot-map.cc
+++ b/src/hb-ot-map.cc
@@ -33,7 +33,8 @@
hb_ot_map_t::add_lookups (hb_face_t *face,
unsigned int table_index,
unsigned int feature_index,
- hb_mask_t mask)
+ hb_mask_t mask,
+ bool auto_joiners)
{
unsigned int lookup_indices[32];
unsigned int offset, len;
@@ -53,6 +54,7 @@
return;
lookup->mask = mask;
lookup->index = lookup_indices[i];
+ lookup->auto_joiners = auto_joiners;
}
offset += len;
@@ -108,7 +110,10 @@
for (unsigned int pause_index = 0; pause_index < pauses[table_index].len; pause_index++) {
const pause_map_t *pause = &pauses[table_index][pause_index];
for (; i < pause->num_lookups; i++)
- hb_ot_layout_substitute_lookup (font, buffer, lookups[table_index][i].index, lookups[table_index][i].mask);
+ hb_ot_layout_substitute_lookup (font, buffer,
+ lookups[table_index][i].index,
+ lookups[table_index][i].mask,
+ lookups[table_index][i].auto_joiners);
buffer->clear_output ();
@@ -117,7 +122,9 @@
}
for (; i < lookups[table_index].len; i++)
- hb_ot_layout_substitute_lookup (font, buffer, lookups[table_index][i].index, lookups[table_index][i].mask);
+ hb_ot_layout_substitute_lookup (font, buffer, lookups[table_index][i].index,
+ lookups[table_index][i].mask,
+ lookups[table_index][i].auto_joiners);
}
void hb_ot_map_t::position (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) const
@@ -128,14 +135,18 @@
for (unsigned int pause_index = 0; pause_index < pauses[table_index].len; pause_index++) {
const pause_map_t *pause = &pauses[table_index][pause_index];
for (; i < pause->num_lookups; i++)
- hb_ot_layout_position_lookup (font, buffer, lookups[table_index][i].index, lookups[table_index][i].mask);
+ hb_ot_layout_position_lookup (font, buffer, lookups[table_index][i].index,
+ lookups[table_index][i].mask,
+ lookups[table_index][i].auto_joiners);
if (pause->callback)
pause->callback (plan, font, buffer);
}
for (; i < lookups[table_index].len; i++)
- hb_ot_layout_position_lookup (font, buffer, lookups[table_index][i].index, lookups[table_index][i].mask);
+ hb_ot_layout_position_lookup (font, buffer, lookups[table_index][i].index,
+ lookups[table_index][i].mask,
+ lookups[table_index][i].auto_joiners);
}
void hb_ot_map_t::collect_lookups (unsigned int table_index, hb_set_t *lookups_out) const
@@ -232,6 +243,7 @@
map->index[1] = feature_index[1];
map->stage[0] = info->stage[0];
map->stage[1] = info->stage[1];
+ map->auto_joiners = !(info->flags & F_MANUAL_JOINERS);
if ((info->flags & F_GLOBAL) && info->max_value == 1) {
/* Uses the global bit */
map->shift = 0;
@@ -264,7 +276,7 @@
script_index[table_index],
language_index[table_index],
&required_feature_index))
- m.add_lookups (face, table_index, required_feature_index, 1);
+ m.add_lookups (face, table_index, required_feature_index, 1, true);
unsigned int pause_index = 0;
unsigned int last_num_lookups = 0;
@@ -272,7 +284,10 @@
{
for (unsigned i = 0; i < m.features.len; i++)
if (m.features[i].stage[table_index] == stage)
- m.add_lookups (face, table_index, m.features[i].index[table_index], m.features[i].mask);
+ m.add_lookups (face, table_index,
+ m.features[i].index[table_index],
+ m.features[i].mask,
+ m.features[i].auto_joiners);
/* Sort lookups and merge duplicates */
if (last_num_lookups < m.lookups[table_index].len)
@@ -284,7 +299,10 @@
if (m.lookups[table_index][i].index != m.lookups[table_index][j].index)
m.lookups[table_index][++j] = m.lookups[table_index][i];
else
+ {
m.lookups[table_index][j].mask |= m.lookups[table_index][i].mask;
+ m.lookups[table_index][j].auto_joiners &= m.lookups[table_index][i].auto_joiners;
+ }
m.lookups[table_index].shrink (j + 1);
}