[config] Add HB_NO_UNISCRIBE_BUG_COMPATIBLE

Part of https://github.com/harfbuzz/harfbuzz/issues/1652
This commit is contained in:
Behdad Esfahbod 2019-05-12 15:47:46 -07:00
parent dba1ac1b0e
commit a1394a28fc
2 changed files with 22 additions and 6 deletions

View File

@ -82,6 +82,10 @@
#define HB_NO_SUBSET_CFF #define HB_NO_SUBSET_CFF
#endif #endif
#ifdef HB_NO_GETENV
#define HB_NO_UNISCRIBE_BUG_COMPATIBLE
#endif
#ifdef HB_NO_LEGACY #ifdef HB_NO_LEGACY
#define HB_NO_OT_LAYOUT_BLACKLIST #define HB_NO_OT_LAYOUT_BLACKLIST
#define HB_NO_OT_SHAPE_FALLBACK #define HB_NO_OT_SHAPE_FALLBACK

View File

@ -274,7 +274,9 @@ struct indic_shape_plan_t
const indic_config_t *config; const indic_config_t *config;
bool is_old_spec; bool is_old_spec;
#ifndef HB_NO_UNISCRIBE_BUG_COMPATIBLE
bool uniscribe_bug_compatible; bool uniscribe_bug_compatible;
#endif
mutable hb_atomic_int_t virama_glyph; mutable hb_atomic_int_t virama_glyph;
would_substitute_feature_t rphf; would_substitute_feature_t rphf;
@ -300,7 +302,9 @@ data_create_indic (const hb_ot_shape_plan_t *plan)
} }
indic_plan->is_old_spec = indic_plan->config->has_old_spec && ((plan->map.chosen_script[0] & 0x000000FFu) != '2'); 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; indic_plan->uniscribe_bug_compatible = hb_options ().uniscribe_bug_compatible;
#endif
indic_plan->virama_glyph.set_relaxed (-1); indic_plan->virama_glyph.set_relaxed (-1);
/* Use zero-context would_substitute() matching for new-spec of the main /* Use zero-context would_substitute() matching for new-spec of the main
@ -918,11 +922,11 @@ initial_reordering_standalone_cluster (const hb_ot_shape_plan_t *plan,
hb_buffer_t *buffer, hb_buffer_t *buffer,
unsigned int start, unsigned int end) 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 /* We treat placeholder/dotted-circle as if they are consonants, so we
* should just chain. Only if not in compatibility mode that is... */ * 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) if (indic_plan->uniscribe_bug_compatible)
{ {
/* For dotted-circle, this is what Uniscribe does: /* For dotted-circle, this is what Uniscribe does:
@ -931,6 +935,7 @@ initial_reordering_standalone_cluster (const hb_ot_shape_plan_t *plan,
if (buffer->info[end - 1].indic_category() == OT_DOTTEDCIRCLE) if (buffer->info[end - 1].indic_category() == OT_DOTTEDCIRCLE)
return; return;
} }
#endif
initial_reordering_consonant_syllable (plan, face, buffer, start, end); initial_reordering_consonant_syllable (plan, face, buffer, start, end);
} }
@ -1370,14 +1375,18 @@ final_reordering_syllable (const hb_ot_shape_plan_t *plan,
* Uniscribe doesn't do this. * Uniscribe doesn't do this.
* TEST: U+0930,U+094D,U+0915,U+094B,U+094D * TEST: U+0930,U+094D,U+0915,U+094B,U+094D
*/ */
#ifndef HB_NO_UNISCRIBE_BUG_COMPATIBLE
if (!indic_plan->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++) for (unsigned int i = base + 1; i < new_reph_pos; i++)
if (info[i].indic_category() == OT_M) { if (info[i].indic_category() == OT_M) {
/* Ok, got it. */ /* Ok, got it. */
new_reph_pos--; new_reph_pos--;
} }
} }
#endif
goto reph_move; goto reph_move;
} }
@ -1476,6 +1485,7 @@ final_reordering_syllable (const hb_ot_shape_plan_t *plan,
/* /*
* Finish off the clusters and go home! * Finish off the clusters and go home!
*/ */
#ifndef HB_NO_UNISCRIBE_BUG_COMPATIBLE
if (indic_plan->uniscribe_bug_compatible) if (indic_plan->uniscribe_bug_compatible)
{ {
switch ((hb_tag_t) plan->props.script) switch ((hb_tag_t) plan->props.script)
@ -1493,6 +1503,7 @@ final_reordering_syllable (const hb_ot_shape_plan_t *plan,
break; break;
} }
} }
#endif
} }
@ -1590,11 +1601,11 @@ decompose_indic (const hb_ot_shape_normalize_context_t *c,
* https://docs.microsoft.com/en-us/typography/script-development/sinhala#shaping * 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; const indic_shape_plan_t *indic_plan = (const indic_shape_plan_t *) c->plan->data;
hb_codepoint_t glyph; hb_codepoint_t glyph;
if (indic_plan->uniscribe_bug_compatible ||
if (hb_options ().uniscribe_bug_compatible ||
(c->font->get_nominal_glyph (ab, &glyph) && (c->font->get_nominal_glyph (ab, &glyph) &&
indic_plan->pstf.would_substitute (&glyph, 1, c->font->face))) indic_plan->pstf.would_substitute (&glyph, 1, c->font->face)))
{ {
@ -1603,6 +1614,7 @@ decompose_indic (const hb_ot_shape_normalize_context_t *c,
*b = ab; *b = ab;
return true; return true;
} }
#endif
} }
return (bool) c->unicode->decompose (ab, a, b); return (bool) c->unicode->decompose (ab, a, b);