diff options
Diffstat (limited to 'src/3rdparty/harfbuzz-ng/src/hb-ot-layout-common.hh')
-rw-r--r-- | src/3rdparty/harfbuzz-ng/src/hb-ot-layout-common.hh | 104 |
1 files changed, 47 insertions, 57 deletions
diff --git a/src/3rdparty/harfbuzz-ng/src/hb-ot-layout-common.hh b/src/3rdparty/harfbuzz-ng/src/hb-ot-layout-common.hh index 0f424f5aa6..b53f2e9276 100644 --- a/src/3rdparty/harfbuzz-ng/src/hb-ot-layout-common.hh +++ b/src/3rdparty/harfbuzz-ng/src/hb-ot-layout-common.hh @@ -44,42 +44,6 @@ using OT::Layout::Common::RangeRecord; using OT::Layout::SmallTypes; using OT::Layout::MediumTypes; -#ifndef HB_MAX_NESTING_LEVEL -#define HB_MAX_NESTING_LEVEL 64 -#endif -#ifndef HB_MAX_CONTEXT_LENGTH -#define HB_MAX_CONTEXT_LENGTH 64 -#endif -#ifndef HB_CLOSURE_MAX_STAGES -/* - * The maximum number of times a lookup can be applied during shaping. - * Used to limit the number of iterations of the closure algorithm. - * This must be larger than the number of times add_gsub_pause() is - * called in a collect_features call of any shaper. - */ -#define HB_CLOSURE_MAX_STAGES 12 -#endif - -#ifndef HB_MAX_SCRIPTS -#define HB_MAX_SCRIPTS 500 -#endif - -#ifndef HB_MAX_LANGSYS -#define HB_MAX_LANGSYS 2000 -#endif - -#ifndef HB_MAX_LANGSYS_FEATURE_COUNT -#define HB_MAX_LANGSYS_FEATURE_COUNT 50000 -#endif - -#ifndef HB_MAX_FEATURE_INDICES -#define HB_MAX_FEATURE_INDICES 1500 -#endif - -#ifndef HB_MAX_LOOKUP_VISIT_COUNT -#define HB_MAX_LOOKUP_VISIT_COUNT 35000 -#endif - namespace OT { @@ -192,19 +156,19 @@ struct hb_subset_layout_context_t : { if (tag_ == HB_OT_TAG_GSUB) { - lookup_index_map = c_->plan->gsub_lookups; - script_langsys_map = c_->plan->gsub_langsys; - feature_index_map = c_->plan->gsub_features; - feature_substitutes_map = c_->plan->gsub_feature_substitutes_map; - feature_record_cond_idx_map = c_->plan->user_axes_location->is_empty () ? nullptr : c_->plan->gsub_feature_record_cond_idx_map; + lookup_index_map = &c_->plan->gsub_lookups; + script_langsys_map = &c_->plan->gsub_langsys; + feature_index_map = &c_->plan->gsub_features; + feature_substitutes_map = &c_->plan->gsub_feature_substitutes_map; + feature_record_cond_idx_map = c_->plan->user_axes_location.is_empty () ? nullptr : &c_->plan->gsub_feature_record_cond_idx_map; } else { - lookup_index_map = c_->plan->gpos_lookups; - script_langsys_map = c_->plan->gpos_langsys; - feature_index_map = c_->plan->gpos_features; - feature_substitutes_map = c_->plan->gpos_feature_substitutes_map; - feature_record_cond_idx_map = c_->plan->user_axes_location->is_empty () ? nullptr : c_->plan->gpos_feature_record_cond_idx_map; + lookup_index_map = &c_->plan->gpos_lookups; + script_langsys_map = &c_->plan->gpos_langsys; + feature_index_map = &c_->plan->gpos_features; + feature_substitutes_map = &c_->plan->gpos_feature_substitutes_map; + feature_record_cond_idx_map = c_->plan->user_axes_location.is_empty () ? nullptr : &c_->plan->gpos_feature_record_cond_idx_map; } } @@ -1181,7 +1145,7 @@ struct Script { TRACE_SUBSET (this); if (!l->visitScript ()) return_trace (false); - if (tag && !c->plan->layout_scripts->has (*tag)) + if (tag && !c->plan->layout_scripts.has (*tag)) return false; auto *out = c->serializer->start_embed (*this); @@ -1389,7 +1353,7 @@ struct Lookup // Generally we shouldn't end up with an empty lookup as we pre-prune them during the planning // phase, but it can happen in rare cases such as when during closure subtable is considered // degenerate (see: https://github.com/harfbuzz/harfbuzz/issues/3853) - return true; + return_trace (true); } template <typename TSubTable> @@ -1568,7 +1532,7 @@ struct ClassDefFormat1_3 const Coverage* glyph_filter = nullptr) const { TRACE_SUBSET (this); - const hb_map_t &glyph_map = *c->plan->glyph_map_gsub; + const hb_map_t &glyph_map = c->plan->glyph_map_gsub; hb_sorted_vector_t<hb_pair_t<hb_codepoint_t, hb_codepoint_t>> glyph_and_klass; hb_set_t orig_klasses; @@ -1813,7 +1777,7 @@ struct ClassDefFormat2_4 const Coverage* glyph_filter = nullptr) const { TRACE_SUBSET (this); - const hb_map_t &glyph_map = *c->plan->glyph_map_gsub; + const hb_map_t &glyph_map = c->plan->glyph_map_gsub; const hb_set_t &glyph_set = *c->plan->glyphset_gsub (); hb_sorted_vector_t<hb_pair_t<hb_codepoint_t, hb_codepoint_t>> glyph_and_klass; @@ -2269,7 +2233,7 @@ struct VarRegionAxis { float evaluate (int coord) const { - int start = startCoord, peak = peakCoord, end = endCoord; + int start = startCoord.to_int (), peak = peakCoord.to_int (), end = endCoord.to_int (); /* TODO Move these to sanitize(). */ if (unlikely (start > peak || peak > end)) @@ -2389,6 +2353,9 @@ struct VarRegionList struct VarData { + unsigned int get_item_count () const + { return itemCount; } + unsigned int get_region_index_count () const { return regionIndices.len; } @@ -2794,6 +2761,29 @@ struct VariationStore return_trace (true); } + VariationStore *copy (hb_serialize_context_t *c) const + { + TRACE_SERIALIZE (this); + auto *out = c->start_embed (this); + if (unlikely (!out)) return_trace (nullptr); + + hb_vector_t <hb_inc_bimap_t> inner_maps; + unsigned count = dataSets.len; + for (unsigned i = 0; i < count; i++) + { + hb_inc_bimap_t *map = inner_maps.push (); + auto &data = this+dataSets[i]; + + unsigned itemCount = data.get_item_count (); + for (unsigned j = 0; j < itemCount; j++) + map->add (j); + } + + if (unlikely (!out->serialize (c, this, inner_maps))) return_trace (nullptr); + + return_trace (out); + } + bool subset (hb_subset_context_t *c, const hb_array_t<const hb_inc_bimap_t> &inner_maps) const { TRACE_SUBSET (this); @@ -2874,7 +2864,7 @@ struct ConditionFormat1 auto *out = c->serializer->embed (this); if (unlikely (!out)) return_trace (false); - const hb_map_t *index_map = c->plan->axes_index_map; + const hb_map_t *index_map = &c->plan->axes_index_map; if (index_map->is_empty ()) return_trace (true); if (!index_map->has (axisIndex)) @@ -2899,8 +2889,8 @@ struct ConditionFormat1 { // add axisIndex->value into the hashmap so we can check if the record is // unique with variations - int16_t min_val = filterRangeMinValue; - int16_t max_val = filterRangeMaxValue; + int16_t min_val = filterRangeMinValue.to_int (); + int16_t max_val = filterRangeMaxValue.to_int (); hb_codepoint_t val = (max_val << 16) + min_val; condition_map->set (axisIndex, val); @@ -2912,7 +2902,7 @@ struct ConditionFormat1 int v = c->axes_location->get (axis_tag); //condition not met, drop the entire record - if (v < filterRangeMinValue || v > filterRangeMaxValue) + if (v < filterRangeMinValue.to_int () || v > filterRangeMaxValue.to_int ()) return DROP_RECORD_WITH_VAR; //axis pinned and condition met, drop the condition @@ -2922,7 +2912,7 @@ struct ConditionFormat1 bool evaluate (const int *coords, unsigned int coord_len) const { int coord = axisIndex < coord_len ? coords[axisIndex] : 0; - return filterRangeMinValue <= coord && coord <= filterRangeMaxValue; + return filterRangeMinValue.to_int () <= coord && coord <= filterRangeMaxValue.to_int (); } bool sanitize (hb_sanitize_context_t *c) const @@ -2962,8 +2952,8 @@ struct Condition template <typename context_t, typename ...Ts> typename context_t::return_t dispatch (context_t *c, Ts&&... ds) const { + if (unlikely (!c->may_dispatch (this, &u.format))) return c->no_dispatch_return_value (); TRACE_DISPATCH (this, u.format); - if (unlikely (!c->may_dispatch (this, &u.format))) return_trace (c->no_dispatch_return_value ()); switch (u.format) { case 1: return_trace (c->dispatch (u.format1, std::forward<Ts> (ds)...)); default:return_trace (c->default_return_value ()); |