Revert "[aat] Allow disable feature ranges"

This reverts commit 24a4d397ba.

This was broken.
This commit is contained in:
Behdad Esfahbod 2023-01-09 17:28:52 -07:00
parent 24a4d397ba
commit 82b3e8af69
8 changed files with 34 additions and 69 deletions

View File

@ -740,7 +740,7 @@ struct StateTableDriver
num_glyphs (face_->get_num_glyphs ()) {}
template <typename context_t>
void drive (context_t *c, hb_mask_t mask)
void drive (context_t *c)
{
if (!c->in_place)
buffer->clear_output ();
@ -753,7 +753,7 @@ struct StateTableDriver
(unsigned) StateTableT::CLASS_END_OF_TEXT;
DEBUG_MSG (APPLY, nullptr, "c%u at %u", klass, buffer->idx);
const EntryT &entry = machine.get_entry (state, klass);
int next_state = machine.new_state (entry.newState);
const int next_state = machine.new_state (entry.newState);
/* Conditions under which it's guaranteed safe-to-break before current glyph:
*
@ -822,10 +822,7 @@ struct StateTableDriver
if (!safe_to_break && buffer->backtrack_len () && buffer->idx < buffer->len)
buffer->unsafe_to_break_from_outbuffer (buffer->backtrack_len () - 1, buffer->idx + 1);
if (buffer->cur().mask & mask)
c->transition (this, entry);
else
next_state = StateTableT::STATE_START_OF_TEXT;
c->transition (this, entry);
state = next_state;
DEBUG_MSG (APPLY, nullptr, "s%d", state);
@ -867,11 +864,9 @@ struct hb_aat_apply_context_t :
const ankr *ankr_table;
const OT::GDEF *gdef_table;
hb_mask_t mask;
/* Unused. For debug tracing only. */
unsigned int lookup_index;
HB_INTERNAL hb_aat_apply_context_t (const hb_ot_shape_plan_t *plan_,
hb_font_t *font_,
hb_buffer_t *buffer_,
@ -882,7 +877,6 @@ struct hb_aat_apply_context_t :
HB_INTERNAL void set_ankr_table (const AAT::ankr *ankr_table_);
void set_lookup_index (unsigned int i) { lookup_index = i; }
void set_mask (hb_mask_t mask_) { mask = mask_; }
};

View File

@ -350,7 +350,7 @@ struct KerxSubTableFormat1
driver_context_t dc (this, c);
StateTableDriver<Types, EntryData> driver (machine, c->buffer, c->font->face);
driver.drive (&dc, c->mask);
driver.drive (&dc);
return_trace (true);
}
@ -594,7 +594,7 @@ struct KerxSubTableFormat4
driver_context_t dc (this, c);
StateTableDriver<Types, EntryData> driver (machine, c->buffer, c->font->face);
driver.drive (&dc, c->mask);
driver.drive (&dc);
return_trace (true);
}

View File

@ -169,7 +169,7 @@ struct RearrangementSubtable
driver_context_t dc (this);
StateTableDriver<Types, EntryData> driver (machine, c->buffer, c->face);
driver.drive (&dc, c->mask);
driver.drive (&dc);
return_trace (dc.ret);
}
@ -325,7 +325,7 @@ struct ContextualSubtable
driver_context_t dc (this, c);
StateTableDriver<Types, EntryData> driver (machine, c->buffer, c->face);
driver.drive (&dc, c->mask);
driver.drive (&dc);
return_trace (dc.ret);
}
@ -577,7 +577,7 @@ struct LigatureSubtable
driver_context_t dc (this, c);
StateTableDriver<Types, EntryData> driver (machine, c->buffer, c->face);
driver.drive (&dc, c->mask);
driver.drive (&dc);
return_trace (dc.ret);
}
@ -820,7 +820,7 @@ struct InsertionSubtable
driver_context_t dc (this, c);
StateTableDriver<Types, EntryData> driver (machine, c->buffer, c->face);
driver.drive (&dc, c->mask);
driver.drive (&dc);
return_trace (dc.ret);
}
@ -954,11 +954,9 @@ struct Chain
{
typedef typename Types::HBUINT HBUINT;
hb_aat_map_t::chain_info_t compile_info (const hb_aat_map_builder_t *map,
const hb_ot_map_t *ot_map) const
hb_mask_t compile_flags (const hb_aat_map_builder_t *map) const
{
hb_mask_t flags = defaultFlags;
hb_mask_t mask = ot_map->get_global_mask ();
{
unsigned int count = featureCount;
for (unsigned i = 0; i < count; i++)
@ -969,11 +967,9 @@ struct Chain
retry:
// Check whether this type/setting pair was requested in the map, and if so, apply its flags.
// (The search here only looks at the type and setting fields of feature_info_t.)
hb_aat_map_builder_t::feature_info_t info = { HB_TAG_NONE, type, setting, false, 0 };
auto *found = map->features.bsearch (info);
if (found)
hb_aat_map_builder_t::feature_info_t info = { type, setting, false, 0 };
if (map->features.bsearch (info))
{
mask = ot_map->get_mask (found->tag);
flags &= feature.disableFlags;
flags |= feature.enableFlags;
}
@ -995,14 +991,11 @@ struct Chain
#endif
}
}
hb_aat_map_t::chain_info_t info;
info.flags = flags;
info.mask = mask;
return info;
return flags;
}
void apply (hb_aat_apply_context_t *c,
hb_aat_map_t::chain_info_t info) const
hb_mask_t flags) const
{
const ChainSubtable<Types> *subtable = &StructAfter<ChainSubtable<Types>> (featureZ.as_array (featureCount));
unsigned int count = subtableCount;
@ -1010,8 +1003,8 @@ struct Chain
{
bool reverse;
//if (!(subtable->subFeatureFlags & info.flags))
//goto skip;
if (!(subtable->subFeatureFlags & flags))
goto skip;
if (!(subtable->get_coverage() & ChainSubtable<Types>::AllDirections) &&
HB_DIRECTION_IS_VERTICAL (c->buffer->props.direction) !=
@ -1056,8 +1049,6 @@ struct Chain
if (reverse)
c->buffer->reverse ();
c->set_mask (info.mask);
subtable->apply (c);
if (reverse)
@ -1124,15 +1115,14 @@ struct mortmorx
bool has_data () const { return version != 0; }
void compile_info (const hb_aat_map_builder_t *mapper,
hb_aat_map_t *map,
const hb_ot_map_t *ot_map) const
void compile_flags (const hb_aat_map_builder_t *mapper,
hb_aat_map_t *map) const
{
const Chain<Types> *chain = &firstChain;
unsigned int count = chainCount;
for (unsigned int i = 0; i < count; i++)
{
map->chain_info.push (chain->compile_info (mapper, ot_map));
map->chain_flags.push (chain->compile_flags (mapper));
chain = &StructAfter<Chain<Types>> (*chain);
}
}
@ -1145,7 +1135,7 @@ struct mortmorx
unsigned int count = chainCount;
for (unsigned int i = 0; i < count; i++)
{
chain->apply (c, c->plan->aat_map.chain_info[i]);
chain->apply (c, c->plan->aat_map.chain_flags[i]);
if (unlikely (!c->buffer->successful)) return;
chain = &StructAfter<Chain<Types>> (*chain);
}

View File

@ -203,20 +203,19 @@ hb_aat_layout_find_feature_mapping (hb_tag_t tag)
void
hb_aat_layout_compile_map (const hb_aat_map_builder_t *mapper,
hb_aat_map_t *map,
const hb_ot_map_t *ot_map)
hb_aat_map_t *map)
{
const AAT::morx& morx = *mapper->face->table.morx;
if (morx.has_data ())
{
morx.compile_info (mapper, map, ot_map);
morx.compile_flags (mapper, map);
return;
}
const AAT::mort& mort = *mapper->face->table.mort;
if (mort.has_data ())
{
mort.compile_info (mapper, map, ot_map);
mort.compile_flags (mapper, map);
return;
}
}

View File

@ -48,8 +48,7 @@ hb_aat_layout_find_feature_mapping (hb_tag_t tag);
HB_INTERNAL void
hb_aat_layout_compile_map (const hb_aat_map_builder_t *mapper,
hb_aat_map_t *map,
const hb_ot_map_t *ot_map);
hb_aat_map_t *map);
HB_INTERNAL void
hb_aat_layout_substitute (const hb_ot_shape_plan_t *plan,

View File

@ -45,7 +45,6 @@ void hb_aat_map_builder_t::add_feature (hb_tag_t tag, unsigned value)
if (!face->table.feat->exposes_feature (HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_ALTERNATIVES))
return;
feature_info_t *info = features.push();
info->tag = tag;
info->type = HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_ALTERNATIVES;
info->setting = (hb_aat_layout_feature_selector_t) value;
info->seq = features.length;
@ -59,7 +58,7 @@ void hb_aat_map_builder_t::add_feature (hb_tag_t tag, unsigned value)
const AAT::FeatureName* feature = &face->table.feat->get_feature (mapping->aatFeatureType);
if (!feature->has_data ())
{
/* Special case: Chain::compile_info will fall back to the deprecated version of
/* Special case: Chain::compile_flags will fall back to the deprecated version of
* small-caps if necessary, so we need to check for that possibility.
* https://github.com/harfbuzz/harfbuzz/issues/2307 */
if (mapping->aatFeatureType == HB_AAT_LAYOUT_FEATURE_TYPE_LOWER_CASE &&
@ -72,7 +71,6 @@ void hb_aat_map_builder_t::add_feature (hb_tag_t tag, unsigned value)
}
feature_info_t *info = features.push();
info->tag = tag;
info->type = mapping->aatFeatureType;
info->setting = value ? mapping->selectorToEnable : mapping->selectorToDisable;
info->seq = features.length;
@ -80,7 +78,7 @@ void hb_aat_map_builder_t::add_feature (hb_tag_t tag, unsigned value)
}
void
hb_aat_map_builder_t::compile (hb_aat_map_t &m, const hb_ot_map_t &ot_m)
hb_aat_map_builder_t::compile (hb_aat_map_t &m)
{
/* Sort features and merge duplicates */
if (features.length)
@ -97,7 +95,7 @@ hb_aat_map_builder_t::compile (hb_aat_map_t &m, const hb_ot_map_t &ot_m)
features.shrink (j + 1);
}
hb_aat_layout_compile_map (this, &m, &ot_m);
hb_aat_layout_compile_map (this, &m);
}

View File

@ -29,8 +29,6 @@
#include "hb.hh"
#include "hb-ot-map.hh"
struct hb_aat_map_t
{
@ -38,21 +36,15 @@ struct hb_aat_map_t
public:
struct chain_info_t
{
hb_mask_t flags;
hb_mask_t mask;
};
void init ()
{
hb_memset (this, 0, sizeof (*this));
chain_info.init ();
chain_flags.init ();
}
void fini () { chain_info.fini (); }
void fini () { chain_flags.fini (); }
public:
hb_vector_t<chain_info_t> chain_info;
hb_vector_t<hb_mask_t> chain_flags;
};
struct hb_aat_map_builder_t
@ -66,12 +58,11 @@ struct hb_aat_map_builder_t
HB_INTERNAL void add_feature (hb_tag_t tag, unsigned int value=1);
HB_INTERNAL void compile (hb_aat_map_t &m, const hb_ot_map_t &ot_m);
HB_INTERNAL void compile (hb_aat_map_t &m);
public:
struct feature_info_t
{
hb_tag_t tag;
hb_aat_layout_feature_type_t type;
hb_aat_layout_feature_selector_t setting;
bool is_exclusive;

View File

@ -107,7 +107,7 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan,
map.compile (plan.map, key);
#ifndef HB_NO_AAT_SHAPE
if (apply_morx)
aat_map.compile (plan.aat_map, plan.map);
aat_map.compile (plan.aat_map);
#endif
#ifndef HB_NO_OT_SHAPE_FRACTIONS
@ -397,18 +397,12 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner,
map->enable_feature (HB_TAG ('v','e','r','t'), F_GLOBAL_SEARCH);
}
hb_ot_map_feature_flags_t flags = F_NONE;
#ifndef HB_NO_AAT_SHAPE
if (planner->apply_morx)
flags |= F_HAS_FALLBACK; // Allocate bits for all user features so AAT planner can use
#endif
for (unsigned int i = 0; i < num_user_features; i++)
{
const hb_feature_t *feature = &user_features[i];
map->add_feature (feature->tag,
((feature->start == HB_FEATURE_GLOBAL_START &&
feature->end == HB_FEATURE_GLOBAL_END) ? F_GLOBAL : F_NONE) | flags,
(feature->start == HB_FEATURE_GLOBAL_START &&
feature->end == HB_FEATURE_GLOBAL_END) ? F_GLOBAL : F_NONE,
feature->value);
}