[GX] Add hb_ot_layout_feature_with_variations_get_lookups()
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh index e67a514..cdf43bf 100644 --- a/src/hb-ot-layout-common-private.hh +++ b/src/hb-ot-layout-common-private.hh
@@ -1417,6 +1417,13 @@ 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 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 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 @@ 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);
diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh index e20777a..adea32f 100644 --- a/src/hb-ot-layout-gsubgpos-private.hh +++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -2275,6 +2275,18 @@ 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 {
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index b352cdb..345d5e6 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc
@@ -582,10 +582,13 @@ 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 @@ 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
diff --git a/src/hb-ot-layout.h b/src/hb-ot-layout.h index 2e3db8c..9861f0f 100644 --- a/src/hb-ot-layout.h +++ b/src/hb-ot-layout.h
@@ -246,6 +246,15 @@ 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