From 87b75d0a4aa03fe7a03e3bf7baf8ece131aec1bb Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 4 Sep 2012 23:06:38 -0400 Subject: [PATCH] [OT] Allow adding features with fallback implementation --- src/hb-ot-map-private.hh | 7 ++++--- src/hb-ot-map.cc | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/hb-ot-map-private.hh b/src/hb-ot-map-private.hh index b9c67362a..22ea8ba01 100644 --- a/src/hb-ot-map-private.hh +++ b/src/hb-ot-map-private.hh @@ -147,10 +147,10 @@ struct hb_ot_map_builder_t hb_ot_map_builder_t (void) { memset (this, 0, sizeof (*this)); } - HB_INTERNAL void add_feature (hb_tag_t tag, unsigned int value, bool global); + HB_INTERNAL void add_feature (hb_tag_t tag, unsigned int value, bool global, bool has_fallback = false); - inline void add_bool_feature (hb_tag_t tag, bool global = true) - { add_feature (tag, 1, global); } + inline void add_bool_feature (hb_tag_t tag, bool global = true, bool has_fallback = false) + { add_feature (tag, 1, global, has_fallback); } inline void add_gsub_pause (hb_ot_map_t::pause_func_t pause_func) { add_pause (0, pause_func); } @@ -174,6 +174,7 @@ struct hb_ot_map_builder_t 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 */ + bool has_fallback; /* whether to allocate bits even if feature not found */ unsigned int default_value; /* for non-global features, what should the unset glyphs take */ unsigned int stage[2]; /* GSUB/GPOS */ diff --git a/src/hb-ot-map.cc b/src/hb-ot-map.cc index b8b2dbedc..aae4d0399 100644 --- a/src/hb-ot-map.cc +++ b/src/hb-ot-map.cc @@ -60,7 +60,7 @@ hb_ot_map_t::add_lookups (hb_face_t *face, } -void hb_ot_map_builder_t::add_feature (hb_tag_t tag, unsigned int value, bool global) +void hb_ot_map_builder_t::add_feature (hb_tag_t tag, unsigned int value, bool global, bool has_fallback) { feature_info_t *info = feature_infos.push(); if (unlikely (!info)) return; @@ -68,6 +68,7 @@ void hb_ot_map_builder_t::add_feature (hb_tag_t tag, unsigned int value, bool gl info->seq = feature_infos.len; info->max_value = value; info->global = global; + info->has_fallback = has_fallback; info->default_value = global ? value : 0; info->stage[0] = current_stage[0]; info->stage[1] = current_stage[1]; @@ -175,6 +176,7 @@ hb_ot_map_builder_t::compile (hb_face_t *face, feature_infos[j].global = false; feature_infos[j].max_value = MAX (feature_infos[j].max_value, feature_infos[i].max_value); } + feature_infos[j].has_fallback = feature_infos[j].has_fallback || feature_infos[i].has_fallback; feature_infos[j].stage[0] = MIN (feature_infos[j].stage[0], feature_infos[i].stage[0]); feature_infos[j].stage[1] = MIN (feature_infos[j].stage[1], feature_infos[i].stage[1]); /* Inherit default_value from j */ @@ -209,7 +211,7 @@ hb_ot_map_builder_t::compile (hb_face_t *face, language_index[table_index], info->tag, &feature_index[table_index]); - if (!found) + if (!found && !info->has_fallback) continue;