提交 30c42b64 编写于 作者: B Behdad Esfahbod

[GX] Add hb_ot_layout_table_find_feature_variations()

上级 7ceadbe9
......@@ -1342,7 +1342,7 @@ struct ConditionFormat1
friend struct Condition;
private:
inline bool evaluate (int *coords, unsigned int coord_len) const
inline bool evaluate (const int *coords, unsigned int coord_len) const
{
int coord = axisIndex < coord_len ? coords[axisIndex] : 0;
return filterRangeMinValue <= coord && coord <= filterRangeMaxValue;
......@@ -1365,7 +1365,7 @@ struct ConditionFormat1
struct Condition
{
inline bool evaluate (int *coords, unsigned int coord_len) const
inline bool evaluate (const int *coords, unsigned int coord_len) const
{
switch (u.format) {
case 1: return u.format1.evaluate (coords, coord_len);
......@@ -1394,7 +1394,7 @@ struct Condition
struct ConditionSet
{
inline bool evaluate (int *coords, unsigned int coord_len) const
inline bool evaluate (const int *coords, unsigned int coord_len) const
{
unsigned int count = conditions.len;
for (unsigned int i = 0; i < count; i++)
......@@ -1470,17 +1470,21 @@ struct FeatureVariationRecord
struct FeatureVariations
{
inline const FeatureTableSubstitution &
get_substitutions (int *coords, unsigned int coord_len) const
inline bool find_index (const int *coords, unsigned int coord_len,
unsigned int *index) const
{
unsigned int count = varRecords.len;
for (unsigned int i = 0; i < count; i++)
{
const FeatureVariationRecord &record = varRecords.array[i];
if ((this+record.conditions).evaluate (coords, coord_len))
return (this+record.substitutions);
{
*index = i;
return true;
}
}
return Null(FeatureTableSubstitution);
*index = 0xFFFFFFFF;
return false;
}
inline bool sanitize (hb_sanitize_context_t *c) const
......
......@@ -2271,10 +2271,10 @@ struct GSUBGPOS
inline const Lookup& get_lookup (unsigned int i) const
{ return (this+lookupList)[i]; }
inline const FeatureTableSubstitution &
get_feature_substitutions (int *coords, unsigned int coord_len) const
inline bool find_variations_index (const int *coords, unsigned int num_coords,
unsigned int *index) const
{ return (version.to_int () >= 0x00010001u ? this+featureVars : Null(FeatureVariations))
.get_substitutions (coords, coord_len); }
.find_index (coords, num_coords, index); }
inline bool sanitize (hb_sanitize_context_t *c) const
{
......
......@@ -836,6 +836,21 @@ hb_ot_layout_lookup_collect_glyphs (hb_face_t *face,
}
/* Variations support */
hb_bool_t
hb_ot_layout_table_find_feature_variations (hb_face_t *face,
hb_tag_t table_tag,
const int *coords,
unsigned int num_coords,
unsigned int *variations_index /* out */)
{
const OT::GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
return g.find_variations_index (coords, num_coords, variations_index);
}
/*
* OT::GSUB
*/
......
......@@ -95,6 +95,7 @@ hb_ot_layout_get_ligature_carets (hb_font_t *font,
#define HB_OT_LAYOUT_NO_SCRIPT_INDEX 0xFFFFu
#define HB_OT_LAYOUT_NO_FEATURE_INDEX 0xFFFFu
#define HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX 0xFFFFu
#define HB_OT_LAYOUT_NO_VARIATIONS_INDEX 0xFFFFFFFFu
HB_EXTERN unsigned int
hb_ot_layout_table_get_script_tags (hb_face_t *face,
......@@ -236,6 +237,15 @@ Xhb_ot_layout_lookup_enumerate_sequences (hb_face_t *face,
void *user_data);
#endif
/* Variations support */
HB_EXTERN hb_bool_t
hb_ot_layout_table_find_feature_variations (hb_face_t *face,
hb_tag_t table_tag,
const int *coords,
unsigned int num_coords,
unsigned int *variations_index /* out */);
/*
* GSUB
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册