[config] Add HB_NO_UNISCRIBE_BUG_COMPATIBLE
Part of https://github.com/harfbuzz/harfbuzz/issues/1652
diff --git a/src/hb-config.hh b/src/hb-config.hh
index 2eab7d8..f6dc4fb 100644
--- a/src/hb-config.hh
+++ b/src/hb-config.hh
@@ -82,6 +82,10 @@
#define HB_NO_SUBSET_CFF
#endif
+#ifdef HB_NO_GETENV
+#define HB_NO_UNISCRIBE_BUG_COMPATIBLE
+#endif
+
#ifdef HB_NO_LEGACY
#define HB_NO_OT_LAYOUT_BLACKLIST
#define HB_NO_OT_SHAPE_FALLBACK
diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index 7befbf6..45351b8 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -274,7 +274,9 @@
const indic_config_t *config;
bool is_old_spec;
+#ifndef HB_NO_UNISCRIBE_BUG_COMPATIBLE
bool uniscribe_bug_compatible;
+#endif
mutable hb_atomic_int_t virama_glyph;
would_substitute_feature_t rphf;
@@ -300,7 +302,9 @@
}
indic_plan->is_old_spec = indic_plan->config->has_old_spec && ((plan->map.chosen_script[0] & 0x000000FFu) != '2');
+#ifndef HB_NO_UNISCRIBE_BUG_COMPATIBLE
indic_plan->uniscribe_bug_compatible = hb_options ().uniscribe_bug_compatible;
+#endif
indic_plan->virama_glyph.set_relaxed (-1);
/* Use zero-context would_substitute() matching for new-spec of the main
@@ -918,11 +922,11 @@
hb_buffer_t *buffer,
unsigned int start, unsigned int end)
{
- const indic_shape_plan_t *indic_plan = (const indic_shape_plan_t *) plan->data;
-
/* We treat placeholder/dotted-circle as if they are consonants, so we
* should just chain. Only if not in compatibility mode that is... */
+#ifndef HB_NO_UNISCRIBE_BUG_COMPATIBLE
+ const HB_UNUSED indic_shape_plan_t *indic_plan = (const indic_shape_plan_t *) plan->data;
if (indic_plan->uniscribe_bug_compatible)
{
/* For dotted-circle, this is what Uniscribe does:
@@ -931,6 +935,7 @@
if (buffer->info[end - 1].indic_category() == OT_DOTTEDCIRCLE)
return;
}
+#endif
initial_reordering_consonant_syllable (plan, face, buffer, start, end);
}
@@ -1370,14 +1375,18 @@
* Uniscribe doesn't do this.
* TEST: U+0930,U+094D,U+0915,U+094B,U+094D
*/
+#ifndef HB_NO_UNISCRIBE_BUG_COMPATIBLE
if (!indic_plan->uniscribe_bug_compatible &&
- unlikely (is_halant (info[new_reph_pos]))) {
+ unlikely (is_halant (info[new_reph_pos])))
+ {
for (unsigned int i = base + 1; i < new_reph_pos; i++)
if (info[i].indic_category() == OT_M) {
/* Ok, got it. */
new_reph_pos--;
}
}
+#endif
+
goto reph_move;
}
@@ -1476,6 +1485,7 @@
/*
* Finish off the clusters and go home!
*/
+#ifndef HB_NO_UNISCRIBE_BUG_COMPATIBLE
if (indic_plan->uniscribe_bug_compatible)
{
switch ((hb_tag_t) plan->props.script)
@@ -1493,6 +1503,7 @@
break;
}
}
+#endif
}
@@ -1590,11 +1601,11 @@
* https://docs.microsoft.com/en-us/typography/script-development/sinhala#shaping
*/
+
+#ifndef HB_NO_UNISCRIBE_BUG_COMPATIBLE
const indic_shape_plan_t *indic_plan = (const indic_shape_plan_t *) c->plan->data;
-
hb_codepoint_t glyph;
-
- if (hb_options ().uniscribe_bug_compatible ||
+ if (indic_plan->uniscribe_bug_compatible ||
(c->font->get_nominal_glyph (ab, &glyph) &&
indic_plan->pstf.would_substitute (&glyph, 1, c->font->face)))
{
@@ -1603,6 +1614,7 @@
*b = ab;
return true;
}
+#endif
}
return (bool) c->unicode->decompose (ab, a, b);