[GX] Add hb_ot_layout_feature_with_variations_get_lookups()

pull/279/head
Behdad Esfahbod 8 years ago
parent 30c42b644e
commit ec87ba9ba3
  1. 30
      src/hb-ot-layout-common-private.hh
  2. 12
      src/hb-ot-layout-gsubgpos-private.hh
  3. 28
      src/hb-ot-layout.cc
  4. 9
      src/hb-ot-layout.h

@ -1417,6 +1417,13 @@ struct ConditionSet
struct FeatureTableSubstitutionRecord 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 inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
@ -1432,6 +1439,18 @@ struct FeatureTableSubstitutionRecord
struct FeatureTableSubstitution 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 inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
@ -1470,6 +1489,8 @@ struct FeatureVariationRecord
struct FeatureVariations struct FeatureVariations
{ {
static const unsigned int NOT_FOUND_INDEX = 0xFFFFFFFFu;
inline bool find_index (const int *coords, unsigned int coord_len, inline bool find_index (const int *coords, unsigned int coord_len,
unsigned int *index) const unsigned int *index) const
{ {
@ -1483,10 +1504,17 @@ struct FeatureVariations
return true; return true;
} }
} }
*index = 0xFFFFFFFF; *index = NOT_FOUND_INDEX;
return false; 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 inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);

@ -2275,6 +2275,18 @@ struct GSUBGPOS
unsigned int *index) const unsigned int *index) const
{ return (version.to_int () >= 0x00010001u ? this+featureVars : Null(FeatureVariations)) { return (version.to_int () >= 0x00010001u ? this+featureVars : Null(FeatureVariations))
.find_index (coords, num_coords, index); } .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 inline bool sanitize (hb_sanitize_context_t *c) const
{ {

@ -582,10 +582,13 @@ hb_ot_layout_feature_get_lookups (hb_face_t *face,
unsigned int *lookup_count /* IN/OUT */, unsigned int *lookup_count /* IN/OUT */,
unsigned int *lookup_indexes /* OUT */) unsigned int *lookup_indexes /* OUT */)
{ {
const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag); return hb_ot_layout_feature_with_variations_get_lookups (face,
const OT::Feature &f = g.get_feature (feature_index); table_tag,
feature_index,
return f.get_lookup_indexes (start_offset, lookup_count, lookup_indexes); 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); 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 * OT::GSUB

@ -246,6 +246,15 @@ hb_ot_layout_table_find_feature_variations (hb_face_t *face,
unsigned int num_coords, unsigned int num_coords,
unsigned int *variations_index /* out */); 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 * GSUB

Loading…
Cancel
Save