[subset] (Chain)ContextSubst glyph_closure fix

- When pos_glyphs is empty, use current full glyphs set as input for
subsequent recursive closure process
- Also increase max_lookup_visit_count to 35000 cause a real font file hit
previous limit 20000 and some lookups are dropped unexpectedly
This commit is contained in:
Qunxin Liu 2021-12-01 20:20:12 -08:00 committed by Behdad Esfahbod
parent 441877f56a
commit 706014f69d
16 changed files with 19 additions and 12 deletions

View File

@ -68,8 +68,8 @@
#define HB_MAX_FEATURE_INDICES 1500
#endif
#ifndef HB_MAX_LOOKUP_INDICES
#define HB_MAX_LOOKUP_INDICES 20000
#ifndef HB_MAX_LOOKUP_VISIT_COUNT
#define HB_MAX_LOOKUP_VISIT_COUNT 35000
#endif
@ -173,7 +173,7 @@ struct hb_subset_layout_context_t :
bool visitLookupIndex()
{
lookup_index_count++;
return lookup_index_count < HB_MAX_LOOKUP_INDICES;
return lookup_index_count < HB_MAX_LOOKUP_VISIT_COUNT;
}
hb_subset_context_t *subset_context;

View File

@ -82,11 +82,11 @@ struct hb_closure_context_t :
}
bool lookup_limit_exceeded ()
{ return lookup_count > HB_MAX_LOOKUP_INDICES; }
{ return lookup_count > HB_MAX_LOOKUP_VISIT_COUNT; }
bool should_visit_lookup (unsigned int lookup_index)
{
if (lookup_count++ > HB_MAX_LOOKUP_INDICES)
if (lookup_count++ > HB_MAX_LOOKUP_VISIT_COUNT)
return false;
if (is_lookup_done (lookup_index))
@ -226,12 +226,20 @@ struct hb_closure_lookups_context_t :
{ inactive_lookups->add (lookup_index); }
bool lookup_limit_exceeded ()
{ return lookup_count > HB_MAX_LOOKUP_INDICES; }
{
bool ret = lookup_count > HB_MAX_LOOKUP_VISIT_COUNT;
if (ret)
DEBUG_MSG (SUBSET, nullptr, "lookup visit count limit exceeded in lookup closure!");
return ret; }
bool is_lookup_visited (unsigned lookup_index)
{
if (unlikely (lookup_count++ > HB_MAX_LOOKUP_INDICES))
if (unlikely (lookup_count++ > HB_MAX_LOOKUP_VISIT_COUNT))
{
DEBUG_MSG (SUBSET, nullptr, "total visited lookup count %u exceeds max limit, lookup %u is dropped.",
lookup_count, lookup_index);
return true;
}
if (unlikely (visited_lookups->in_error ()))
return true;
@ -1303,8 +1311,7 @@ static void context_closure_recurse_lookups (hb_closure_context_t *c,
}
hb_set_add (covered_seq_indicies, seqIndex);
if (pos_glyphs)
c->push_cur_active_glyphs (pos_glyphs);
c->push_cur_active_glyphs (pos_glyphs ? pos_glyphs : c->glyphs);
unsigned endIndex = inputCount;
if (context_format == ContextFormat::CoverageBasedContext)
@ -1312,10 +1319,9 @@ static void context_closure_recurse_lookups (hb_closure_context_t *c,
c->recurse (lookupRecord[i].lookupListIndex, covered_seq_indicies, seqIndex, endIndex);
if (pos_glyphs) {
c->pop_cur_done_glyphs ();
c->pop_cur_done_glyphs ();
if (pos_glyphs)
hb_set_destroy (pos_glyphs);
}
}
hb_set_destroy (covered_seq_indicies);

View File

@ -11,3 +11,4 @@ SUBSETS:
غير
سماء لا
الحب
*