struct feature_info_t {
hb_tag_t tag;
- unsigned int value;
- unsigned int seq;
- bool global;
+ unsigned int seq; /* sequence#, used for stable sorting only */
+ unsigned int max_value;
+ bool global; /* whether the feature applies value to every glyph in the buffer */
+ unsigned int default_value; /* for non-global features, what should the unset glyphs take */
static int cmp (const feature_info_t *a, const feature_info_t *b)
{ return (a->tag != b->tag) ? (a->tag < b->tag ? -1 : 1) : (a->seq < b->seq ? -1 : 1); }
{
feature_info_t *info = &feature_infos[feature_count++];
info->tag = tag;
- info->value = value;
info->seq = feature_count;
+ info->max_value = value;
info->global = global;
+ info->default_value = global ? value : 0;
}
inline void add_bool_feature (hb_tag_t tag, bool global = true)
feature_infos[j] = feature_infos[i];
else {
feature_infos[j].global = false;
- feature_infos[j].value = MAX (feature_infos[j].value, feature_infos[i].value);
+ feature_infos[j].max_value = MAX (feature_infos[j].max_value, feature_infos[i].max_value);
+ /* Inherit default_value from j */
}
}
feature_count = j + 1;
unsigned int bits_needed;
- if (info->global && info->value == 1)
+ if (info->global && info->max_value == 1)
/* Uses the global bit */
bits_needed = 0;
else
- bits_needed = _hb_bit_storage (info->value);
+ bits_needed = _hb_bit_storage (info->max_value);
- if (!info->value || next_bit + bits_needed > 8 * sizeof (hb_mask_t))
+ if (!info->max_value || next_bit + bits_needed > 8 * sizeof (hb_mask_t))
continue; /* Feature disabled, or not enough bits. */
map->tag = info->tag;
map->index[0] = feature_index[0];
map->index[1] = feature_index[1];
- if (info->global && info->value == 1) {
+ if (info->global && info->max_value == 1) {
/* Uses the global bit */
map->shift = 0;
map->mask = 1;
map->mask = (1 << (next_bit + bits_needed)) - (1 << next_bit);
next_bit += bits_needed;
if (info->global)
- global_mask |= map->mask;
+ global_mask |= ((info->default_value << map->shift) & map->mask);
}
}