diff --git a/TODO b/TODO index efd0a31d71571a792598012d06690f837cf2452b..0345d4c99526b90b005d33ea425d9b1b98fb48f0 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,6 @@ General fixes: ============= -- Fix feature mask bugs - - Fix tt kern on/off - Remove hb_internal_glyph_info_t, etc diff --git a/src/hb-ot-map-private.hh b/src/hb-ot-map-private.hh index 8e65f49ead1d8286f236bc3389a14158384556f6..65f57eaff82de87e15bd4f85937e55a8f65917a5 100644 --- a/src/hb-ot-map-private.hh +++ b/src/hb-ot-map-private.hh @@ -47,9 +47,10 @@ struct hb_ot_map_t { 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); } @@ -87,9 +88,10 @@ struct hb_ot_map_t { { 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) diff --git a/src/hb-ot-map.cc b/src/hb-ot-map.cc index 94be14f6e631884757172589e2d21894bc7544be..8c696f81476383c3fe9802c246d541d59e8514a3 100644 --- a/src/hb-ot-map.cc +++ b/src/hb-ot-map.cc @@ -98,7 +98,8 @@ hb_ot_map_t::compile (hb_face_t *face, 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; @@ -112,13 +113,13 @@ hb_ot_map_t::compile (hb_face_t *face, 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. */ @@ -140,7 +141,7 @@ hb_ot_map_t::compile (hb_face_t *face, 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; @@ -149,7 +150,7 @@ hb_ot_map_t::compile (hb_face_t *face, 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); } }