[GX] Add hb_ot_layout_feature_with_variations_get_lookups()

This commit is contained in:
Behdad Esfahbod 2016-09-10 03:53:11 -07:00
parent 30c42b644e
commit ec87ba9ba3
4 changed files with 74 additions and 5 deletions

View File

@ -1417,6 +1417,13 @@ struct ConditionSet
struct FeatureTableSubstitutionRecord
{
inline const Feature *find_substitute (unsigned int feature_index) const
{
if (featureIndex == feature_index)
return &(this+feature);
return NULL;
}
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
@ -1432,6 +1439,18 @@ struct FeatureTableSubstitutionRecord
struct FeatureTableSubstitution
{
inline const Feature *find_substitute (unsigned int feature_index) const
{
unsigned int count = substitutions.len;
for (unsigned int i = 0; i < count; i++)
{
const Feature *feature = (this+substitutions.array[i]).find_substitute (feature_index);
if (feature)
return feature;
}
return NULL;
}
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
@ -1470,6 +1489,8 @@ struct FeatureVariationRecord
struct FeatureVariations
{
static const unsigned int NOT_FOUND_INDEX = 0xFFFFFFFFu;
inline bool find_index (const int *coords, unsigned int coord_len,
unsigned int *index) const
{
@ -1483,10 +1504,17 @@ struct FeatureVariations
return true;
}
}
*index = 0xFFFFFFFF;
*index = NOT_FOUND_INDEX;
return false;
}
inline const Feature *find_substitute (unsigned int variations_index,
unsigned int feature_index) const
{
const FeatureVariationRecord &record = varRecords[variations_index];
return (this+record.substitutions).find_substitute (feature_index);
}
inline bool sanitize (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);

View File

@ -2275,6 +2275,18 @@ struct GSUBGPOS
unsigned int *index) const
{ return (version.to_int () >= 0x00010001u ? this+featureVars : Null(FeatureVariations))
.find_index (coords, num_coords, index); }
inline const Feature& get_feature_variation (unsigned int feature_index,
unsigned int variations_index) const
{
if (FeatureVariations::NOT_FOUND_INDEX != variations_index &&
version.to_int () >= 0x00010001u)
{
const Feature *feature = (this+featureVars).find_substitute (variations_index, feature_index);
if (feature)
return *feature;
}
return get_feature (feature_index);
}
inline bool sanitize (hb_sanitize_context_t *c) const
{

View File

@ -582,10 +582,13 @@ hb_ot_layout_feature_get_lookups (hb_face_t *face,
unsigned int *lookup_count /* IN/OUT */,
unsigned int *lookup_indexes /* OUT */)
{
const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
const OT::Feature &f = g.get_feature (feature_index);
return f.get_lookup_indexes (start_offset, lookup_count, lookup_indexes);
return hb_ot_layout_feature_with_variations_get_lookups (face,
table_tag,
feature_index,
HB_OT_LAYOUT_NO_VARIATIONS_INDEX,
start_offset,
lookup_count,
lookup_indexes);
}
/**
@ -850,6 +853,23 @@ hb_ot_layout_table_find_feature_variations (hb_face_t *face,
return g.find_variations_index (coords, num_coords, variations_index);
}
unsigned int
hb_ot_layout_feature_with_variations_get_lookups (hb_face_t *face,
hb_tag_t table_tag,
unsigned int feature_index,
unsigned int variations_index,
unsigned int start_offset,
unsigned int *lookup_count /* IN/OUT */,
unsigned int *lookup_indexes /* OUT */)
{
ASSERT_STATIC (OT::FeatureVariations::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_VARIATIONS_INDEX);
const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
const OT::Feature &f = g.get_feature_variation (feature_index, variations_index);
return f.get_lookup_indexes (start_offset, lookup_count, lookup_indexes);
}
/*
* OT::GSUB

View File

@ -246,6 +246,15 @@ hb_ot_layout_table_find_feature_variations (hb_face_t *face,
unsigned int num_coords,
unsigned int *variations_index /* out */);
HB_EXTERN unsigned int
hb_ot_layout_feature_with_variations_get_lookups (hb_face_t *face,
hb_tag_t table_tag,
unsigned int feature_index,
unsigned int variations_index,
unsigned int start_offset,
unsigned int *lookup_count /* IN/OUT */,
unsigned int *lookup_indexes /* OUT */);
/*
* GSUB