[subset] fix intersects () for Context/ChainContext tables

return true only when all values in array are intersected with input
This commit is contained in:
Qunxin Liu 2020-05-08 15:33:34 -07:00 committed by Garret Rieger
parent 42025680cb
commit 44d88cff95

View File

@ -791,15 +791,15 @@ static inline bool intersects_coverage (const hb_set_t *glyphs, const HBUINT16 &
return (data+coverage).intersects (glyphs);
}
static inline bool intersects_array (const hb_set_t *glyphs,
unsigned int count,
const HBUINT16 values[],
intersects_func_t intersects_func,
const void *intersects_data)
static inline bool array_is_subset_of (const hb_set_t *glyphs,
unsigned int count,
const HBUINT16 values[],
intersects_func_t intersects_func,
const void *intersects_data)
{
for (const HBUINT16 &_ : + hb_iter (values, count))
if (intersects_func (glyphs, _, intersects_data)) return true;
return false;
if (!intersects_func (glyphs, _, intersects_data)) return false;
return true;
}
@ -1325,9 +1325,9 @@ static inline bool context_intersects (const hb_set_t *glyphs,
const HBUINT16 input[], /* Array of input values--start with second glyph */
ContextClosureLookupContext &lookup_context)
{
return intersects_array (glyphs,
inputCount ? inputCount - 1 : 0, input,
lookup_context.funcs.intersects, lookup_context.intersects_data);
return array_is_subset_of (glyphs,
inputCount ? inputCount - 1 : 0, input,
lookup_context.funcs.intersects, lookup_context.intersects_data);
}
static inline void context_closure_lookup (hb_closure_context_t *c,
@ -1972,15 +1972,15 @@ static inline bool chain_context_intersects (const hb_set_t *glyphs,
const HBUINT16 lookahead[],
ChainContextClosureLookupContext &lookup_context)
{
return intersects_array (glyphs,
backtrackCount, backtrack,
lookup_context.funcs.intersects, lookup_context.intersects_data[0])
&& intersects_array (glyphs,
inputCount ? inputCount - 1 : 0, input,
lookup_context.funcs.intersects, lookup_context.intersects_data[1])
&& intersects_array (glyphs,
lookaheadCount, lookahead,
lookup_context.funcs.intersects, lookup_context.intersects_data[2]);
return array_is_subset_of (glyphs,
backtrackCount, backtrack,
lookup_context.funcs.intersects, lookup_context.intersects_data[0])
&& array_is_subset_of (glyphs,
inputCount ? inputCount - 1 : 0, input,
lookup_context.funcs.intersects, lookup_context.intersects_data[1])
&& array_is_subset_of (glyphs,
lookaheadCount, lookahead,
lookup_context.funcs.intersects, lookup_context.intersects_data[2]);
}
static inline void chain_context_closure_lookup (hb_closure_context_t *c,