[GSUB] Allow non-zero-context matching in would_apply()
To be used in the next patch.
This commit is contained in:
parent
1f2bb172fe
commit
d9b204d3d2
@ -76,17 +76,20 @@ struct hb_would_apply_context_t
|
|||||||
hb_face_t *face;
|
hb_face_t *face;
|
||||||
const hb_codepoint_t *glyphs;
|
const hb_codepoint_t *glyphs;
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
|
bool zero_context;
|
||||||
const hb_set_digest_t digest;
|
const hb_set_digest_t digest;
|
||||||
unsigned int debug_depth;
|
unsigned int debug_depth;
|
||||||
|
|
||||||
hb_would_apply_context_t (hb_face_t *face_,
|
hb_would_apply_context_t (hb_face_t *face_,
|
||||||
const hb_codepoint_t *glyphs_,
|
const hb_codepoint_t *glyphs_,
|
||||||
unsigned int len_,
|
unsigned int len_,
|
||||||
|
bool zero_context_,
|
||||||
const hb_set_digest_t *digest_
|
const hb_set_digest_t *digest_
|
||||||
) :
|
) :
|
||||||
face (face_),
|
face (face_),
|
||||||
glyphs (glyphs_),
|
glyphs (glyphs_),
|
||||||
len (len_),
|
len (len_),
|
||||||
|
zero_context (zero_context_),
|
||||||
digest (*digest_),
|
digest (*digest_),
|
||||||
debug_depth (0) {};
|
debug_depth (0) {};
|
||||||
};
|
};
|
||||||
@ -1066,8 +1069,7 @@ static inline bool chain_context_would_apply_lookup (hb_would_apply_context_t *c
|
|||||||
const LookupRecord lookupRecord[],
|
const LookupRecord lookupRecord[],
|
||||||
ChainContextApplyLookupContext &lookup_context)
|
ChainContextApplyLookupContext &lookup_context)
|
||||||
{
|
{
|
||||||
return !backtrackCount
|
return (c->zero_context ? !backtrackCount && !lookaheadCount : true)
|
||||||
&& !lookaheadCount
|
|
||||||
&& would_match_input (c,
|
&& would_match_input (c,
|
||||||
inputCount, input,
|
inputCount, input,
|
||||||
lookup_context.funcs.match, lookup_context.match_data[1]);
|
lookup_context.funcs.match, lookup_context.match_data[1]);
|
||||||
|
@ -139,9 +139,10 @@ static inline uint8_t allocate_lig_id (hb_buffer_t *buffer) {
|
|||||||
|
|
||||||
HB_INTERNAL hb_bool_t
|
HB_INTERNAL hb_bool_t
|
||||||
hb_ot_layout_would_substitute_lookup_fast (hb_face_t *face,
|
hb_ot_layout_would_substitute_lookup_fast (hb_face_t *face,
|
||||||
|
unsigned int lookup_index,
|
||||||
const hb_codepoint_t *glyphs,
|
const hb_codepoint_t *glyphs,
|
||||||
unsigned int glyphs_length,
|
unsigned int glyphs_length,
|
||||||
unsigned int lookup_index);
|
hb_bool_t zero_context);
|
||||||
|
|
||||||
|
|
||||||
/* Should be called before all the substitute_lookup's are done. */
|
/* Should be called before all the substitute_lookup's are done. */
|
||||||
|
@ -401,22 +401,24 @@ hb_ot_layout_has_substitution (hb_face_t *face)
|
|||||||
|
|
||||||
hb_bool_t
|
hb_bool_t
|
||||||
hb_ot_layout_would_substitute_lookup (hb_face_t *face,
|
hb_ot_layout_would_substitute_lookup (hb_face_t *face,
|
||||||
|
unsigned int lookup_index,
|
||||||
const hb_codepoint_t *glyphs,
|
const hb_codepoint_t *glyphs,
|
||||||
unsigned int glyphs_length,
|
unsigned int glyphs_length,
|
||||||
unsigned int lookup_index)
|
hb_bool_t zero_context)
|
||||||
{
|
{
|
||||||
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return false;
|
if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return false;
|
||||||
return hb_ot_layout_would_substitute_lookup_fast (face, glyphs, glyphs_length, lookup_index);
|
return hb_ot_layout_would_substitute_lookup_fast (face, lookup_index, glyphs, glyphs_length, zero_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
hb_bool_t
|
hb_bool_t
|
||||||
hb_ot_layout_would_substitute_lookup_fast (hb_face_t *face,
|
hb_ot_layout_would_substitute_lookup_fast (hb_face_t *face,
|
||||||
|
unsigned int lookup_index,
|
||||||
const hb_codepoint_t *glyphs,
|
const hb_codepoint_t *glyphs,
|
||||||
unsigned int glyphs_length,
|
unsigned int glyphs_length,
|
||||||
unsigned int lookup_index)
|
hb_bool_t zero_context)
|
||||||
{
|
{
|
||||||
if (unlikely (lookup_index >= hb_ot_layout_from_face (face)->gsub_lookup_count)) return false;
|
if (unlikely (lookup_index >= hb_ot_layout_from_face (face)->gsub_lookup_count)) return false;
|
||||||
hb_would_apply_context_t c (face, glyphs, glyphs_length, &hb_ot_layout_from_face (face)->gsub_digests[lookup_index]);
|
hb_would_apply_context_t c (face, glyphs, glyphs_length, zero_context, &hb_ot_layout_from_face (face)->gsub_digests[lookup_index]);
|
||||||
return hb_ot_layout_from_face (face)->gsub->would_substitute_lookup (&c, lookup_index);
|
return hb_ot_layout_from_face (face)->gsub->would_substitute_lookup (&c, lookup_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,8 +447,8 @@ hb_ot_layout_substitute_finish (hb_font_t *font, hb_buffer_t *buffer)
|
|||||||
|
|
||||||
void
|
void
|
||||||
hb_ot_layout_substitute_closure_lookup (hb_face_t *face,
|
hb_ot_layout_substitute_closure_lookup (hb_face_t *face,
|
||||||
hb_set_t *glyphs,
|
unsigned int lookup_index,
|
||||||
unsigned int lookup_index)
|
hb_set_t *glyphs)
|
||||||
{
|
{
|
||||||
hb_closure_context_t c (face, glyphs);
|
hb_closure_context_t c (face, glyphs);
|
||||||
_get_gsub (face).closure_lookup (&c, lookup_index);
|
_get_gsub (face).closure_lookup (&c, lookup_index);
|
||||||
|
@ -171,14 +171,15 @@ hb_ot_layout_has_substitution (hb_face_t *face);
|
|||||||
|
|
||||||
hb_bool_t
|
hb_bool_t
|
||||||
hb_ot_layout_would_substitute_lookup (hb_face_t *face,
|
hb_ot_layout_would_substitute_lookup (hb_face_t *face,
|
||||||
|
unsigned int lookup_index,
|
||||||
const hb_codepoint_t *glyphs,
|
const hb_codepoint_t *glyphs,
|
||||||
unsigned int glyphs_length,
|
unsigned int glyphs_length,
|
||||||
unsigned int lookup_index);
|
hb_bool_t zero_context);
|
||||||
|
|
||||||
void
|
void
|
||||||
hb_ot_layout_substitute_closure_lookup (hb_face_t *face,
|
hb_ot_layout_substitute_closure_lookup (hb_face_t *face,
|
||||||
hb_set_t *glyphs,
|
unsigned int lookup_index,
|
||||||
unsigned int lookup_index);
|
hb_set_t *glyphs);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GPOS
|
* GPOS
|
||||||
|
@ -116,16 +116,8 @@ void hb_ot_map_t::position (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_
|
|||||||
void hb_ot_map_t::substitute_closure (const hb_ot_shape_plan_t *plan, hb_face_t *face, hb_set_t *glyphs) const
|
void hb_ot_map_t::substitute_closure (const hb_ot_shape_plan_t *plan, hb_face_t *face, hb_set_t *glyphs) const
|
||||||
{
|
{
|
||||||
unsigned int table_index = 0;
|
unsigned int table_index = 0;
|
||||||
unsigned int i = 0;
|
for (unsigned int i = 0; i < lookups[table_index].len; i++)
|
||||||
|
hb_ot_layout_substitute_closure_lookup (face, lookups[table_index][i].index, glyphs);
|
||||||
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_closure_lookup (face, glyphs, lookups[table_index][i].index);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (; i < lookups[table_index].len; i++)
|
|
||||||
hb_ot_layout_substitute_closure_lookup (face, glyphs, lookups[table_index][i].index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void hb_ot_map_builder_t::add_pause (unsigned int table_index, hb_ot_map_t::pause_func_t pause_func)
|
void hb_ot_map_builder_t::add_pause (unsigned int table_index, hb_ot_map_t::pause_func_t pause_func)
|
||||||
|
@ -257,7 +257,7 @@ struct would_substitute_feature_t
|
|||||||
hb_face_t *face) const
|
hb_face_t *face) const
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
if (hb_ot_layout_would_substitute_lookup_fast (face, glyphs, glyphs_count, lookups[i].index))
|
if (hb_ot_layout_would_substitute_lookup_fast (face, lookups[i].index, glyphs, glyphs_count, true))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -99,5 +99,5 @@ main (int argc, char **argv)
|
|||||||
(argc > 4 &&
|
(argc > 4 &&
|
||||||
!hb_font_glyph_from_string (font, argv[4], -1, &glyphs[1])))
|
!hb_font_glyph_from_string (font, argv[4], -1, &glyphs[1])))
|
||||||
return 2;
|
return 2;
|
||||||
return !hb_ot_layout_would_substitute_lookup (face, glyphs, len, strtol (argv[2], NULL, 0));
|
return !hb_ot_layout_would_substitute_lookup (face, strtol (argv[2], NULL, 0), glyphs, len, false);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user