[OT] Allow adding features with fallback implementation
This commit is contained in:
parent
1d3947a6bd
commit
87b75d0a4a
|
@ -147,10 +147,10 @@ struct hb_ot_map_builder_t
|
||||||
|
|
||||||
hb_ot_map_builder_t (void) { memset (this, 0, sizeof (*this)); }
|
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)
|
inline void add_bool_feature (hb_tag_t tag, bool global = true, bool has_fallback = false)
|
||||||
{ add_feature (tag, 1, global); }
|
{ add_feature (tag, 1, global, has_fallback); }
|
||||||
|
|
||||||
inline void add_gsub_pause (hb_ot_map_t::pause_func_t pause_func)
|
inline void add_gsub_pause (hb_ot_map_t::pause_func_t pause_func)
|
||||||
{ add_pause (0, 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 seq; /* sequence#, used for stable sorting only */
|
||||||
unsigned int max_value;
|
unsigned int max_value;
|
||||||
bool global; /* whether the feature applies value to every glyph in the buffer */
|
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 default_value; /* for non-global features, what should the unset glyphs take */
|
||||||
unsigned int stage[2]; /* GSUB/GPOS */
|
unsigned int stage[2]; /* GSUB/GPOS */
|
||||||
|
|
||||||
|
|
|
@ -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();
|
feature_info_t *info = feature_infos.push();
|
||||||
if (unlikely (!info)) return;
|
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->seq = feature_infos.len;
|
||||||
info->max_value = value;
|
info->max_value = value;
|
||||||
info->global = global;
|
info->global = global;
|
||||||
|
info->has_fallback = has_fallback;
|
||||||
info->default_value = global ? value : 0;
|
info->default_value = global ? value : 0;
|
||||||
info->stage[0] = current_stage[0];
|
info->stage[0] = current_stage[0];
|
||||||
info->stage[1] = current_stage[1];
|
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].global = false;
|
||||||
feature_infos[j].max_value = MAX (feature_infos[j].max_value, feature_infos[i].max_value);
|
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[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]);
|
feature_infos[j].stage[1] = MIN (feature_infos[j].stage[1], feature_infos[i].stage[1]);
|
||||||
/* Inherit default_value from j */
|
/* Inherit default_value from j */
|
||||||
|
@ -209,7 +211,7 @@ hb_ot_map_builder_t::compile (hb_face_t *face,
|
||||||
language_index[table_index],
|
language_index[table_index],
|
||||||
info->tag,
|
info->tag,
|
||||||
&feature_index[table_index]);
|
&feature_index[table_index]);
|
||||||
if (!found)
|
if (!found && !info->has_fallback)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue