From c221dc0ba70fd4af94d8f735a9cef1ab92cc6ede Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 14 Nov 2018 14:49:34 -0500 Subject: [PATCH 1/3] [ot-shape] Move code around --- src/hb-aat-layout-common.hh | 4 ++-- src/hb-aat-layout.cc | 8 +++---- src/hb-aat-layout.hh | 6 ++--- src/hb-ot-layout.cc | 2 +- src/hb-ot-layout.hh | 2 +- src/hb-ot-shape.cc | 44 ++++++++++++++++++++++++------------- src/hb-ot-shape.hh | 6 ++--- 7 files changed, 43 insertions(+), 29 deletions(-) diff --git a/src/hb-aat-layout-common.hh b/src/hb-aat-layout-common.hh index adc7538c9..6572b26d8 100644 --- a/src/hb-aat-layout-common.hh +++ b/src/hb-aat-layout-common.hh @@ -801,7 +801,7 @@ struct hb_aat_apply_context_t : static return_t default_return_value (void) { return false; } bool stop_sublookup_iteration (return_t r) const { return r; } - hb_ot_shape_plan_t *plan; + const hb_ot_shape_plan_t *plan; hb_font_t *font; hb_face_t *face; hb_buffer_t *buffer; @@ -813,7 +813,7 @@ struct hb_aat_apply_context_t : unsigned int lookup_index; unsigned int debug_depth; - HB_INTERNAL hb_aat_apply_context_t (hb_ot_shape_plan_t *plan_, + HB_INTERNAL hb_aat_apply_context_t (const hb_ot_shape_plan_t *plan_, hb_font_t *font_, hb_buffer_t *buffer_, hb_blob_t *blob = const_cast (&Null(hb_blob_t))); diff --git a/src/hb-aat-layout.cc b/src/hb-aat-layout.cc index 2e655ec16..da6908a44 100644 --- a/src/hb-aat-layout.cc +++ b/src/hb-aat-layout.cc @@ -135,7 +135,7 @@ hb_aat_layout_find_feature_mapping (hb_tag_t tag) * hb_aat_apply_context_t */ -AAT::hb_aat_apply_context_t::hb_aat_apply_context_t (hb_ot_shape_plan_t *plan_, +AAT::hb_aat_apply_context_t::hb_aat_apply_context_t (const hb_ot_shape_plan_t *plan_, hb_font_t *font_, hb_buffer_t *buffer_, hb_blob_t *blob) : @@ -202,7 +202,7 @@ hb_aat_layout_has_substitution (hb_face_t *face) } void -hb_aat_layout_substitute (hb_ot_shape_plan_t *plan, +hb_aat_layout_substitute (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) { @@ -257,7 +257,7 @@ hb_aat_layout_has_positioning (hb_face_t *face) } void -hb_aat_layout_position (hb_ot_shape_plan_t *plan, +hb_aat_layout_position (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) { @@ -280,7 +280,7 @@ hb_aat_layout_has_tracking (hb_face_t *face) } void -hb_aat_layout_track (hb_ot_shape_plan_t *plan, +hb_aat_layout_track (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) { diff --git a/src/hb-aat-layout.hh b/src/hb-aat-layout.hh index 97935a02f..1d3407971 100644 --- a/src/hb-aat-layout.hh +++ b/src/hb-aat-layout.hh @@ -60,7 +60,7 @@ HB_INTERNAL bool hb_aat_layout_has_substitution (hb_face_t *face); HB_INTERNAL void -hb_aat_layout_substitute (hb_ot_shape_plan_t *plan, +hb_aat_layout_substitute (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer); @@ -74,7 +74,7 @@ HB_INTERNAL bool hb_aat_layout_has_positioning (hb_face_t *face); HB_INTERNAL void -hb_aat_layout_position (hb_ot_shape_plan_t *plan, +hb_aat_layout_position (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer); @@ -82,7 +82,7 @@ HB_INTERNAL bool hb_aat_layout_has_tracking (hb_face_t *face); HB_INTERNAL void -hb_aat_layout_track (hb_ot_shape_plan_t *plan, +hb_aat_layout_track (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer); diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index ec2421e3f..092633c5d 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -72,7 +72,7 @@ hb_ot_layout_has_cross_kerning (hb_face_t *face) } void -hb_ot_layout_kern (hb_ot_shape_plan_t *plan, +hb_ot_layout_kern (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) { diff --git a/src/hb-ot-layout.hh b/src/hb-ot-layout.hh index b21825316..db85508d2 100644 --- a/src/hb-ot-layout.hh +++ b/src/hb-ot-layout.hh @@ -52,7 +52,7 @@ HB_INTERNAL bool hb_ot_layout_has_cross_kerning (hb_face_t *face); HB_INTERNAL void -hb_ot_layout_kern (hb_ot_shape_plan_t *plan, +hb_ot_layout_kern (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer); diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index a383b7823..ba65e7618 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -181,6 +181,33 @@ hb_ot_shape_plan_t::fini (void) aat_map.fini (); } +void +hb_ot_shape_plan_t::substitute (hb_font_t *font, + hb_buffer_t *buffer) const +{ + if (unlikely (apply_morx)) + hb_aat_layout_substitute (this, font, buffer); + else + map.substitute (this, font, buffer); +} + +void +hb_ot_shape_plan_t::position (hb_font_t *font, + hb_buffer_t *buffer) const +{ + if (this->apply_gpos) + map.position (this, font, buffer); + else if (this->apply_kerx) + hb_aat_layout_position (this, font, buffer); + else if (this->apply_kern) + hb_ot_layout_kern (this, font, buffer); + else + _hb_ot_shape_fallback_kern (this, font, buffer); + + if (this->apply_trak) + hb_aat_layout_track (this, font, buffer); +} + static const hb_ot_map_feature_t common_features[] = @@ -687,10 +714,7 @@ hb_ot_substitute_complex (const hb_ot_shape_context_t *c) if (c->plan->fallback_glyph_classes) hb_synthesize_glyph_classes (c->buffer); - if (unlikely (c->plan->apply_morx)) - hb_aat_layout_substitute (c->plan, c->font, c->buffer); - else - c->plan->substitute (c->font, buffer); + c->plan->substitute (c->font, buffer); } static inline void @@ -825,17 +849,7 @@ hb_ot_position_complex (const hb_ot_shape_context_t *c) break; } - if (c->plan->apply_gpos) - c->plan->position (c->font, c->buffer); - else if (c->plan->apply_kerx) - hb_aat_layout_position (c->plan, c->font, c->buffer); - else if (c->plan->apply_kern) - hb_ot_layout_kern (c->plan, c->font, c->buffer); - else - _hb_ot_shape_fallback_kern (c->plan, c->font, c->buffer); - - if (c->plan->apply_trak) - hb_aat_layout_track (c->plan, c->font, c->buffer); + c->plan->position (c->font, c->buffer); if (c->plan->zero_marks) switch (c->plan->shaper->zero_width_marks) diff --git a/src/hb-ot-shape.hh b/src/hb-ot-shape.hh index b35f243ef..397634c25 100644 --- a/src/hb-ot-shape.hh +++ b/src/hb-ot-shape.hh @@ -84,7 +84,6 @@ struct hb_ot_shape_plan_t bool apply_morx : 1; bool apply_trak : 1; - inline void collect_lookups (hb_tag_t table_tag, hb_set_t *lookups) const { unsigned int table_index; @@ -95,12 +94,13 @@ struct hb_ot_shape_plan_t } map.collect_lookups (table_index, lookups); } - inline void substitute (hb_font_t *font, hb_buffer_t *buffer) const { map.substitute (this, font, buffer); } - inline void position (hb_font_t *font, hb_buffer_t *buffer) const { map.position (this, font, buffer); } HB_INTERNAL bool init0 (hb_face_t *face, const hb_shape_plan_key_t *key); HB_INTERNAL void fini (void); + + HB_INTERNAL void substitute (hb_font_t *font, hb_buffer_t *buffer) const; + HB_INTERNAL void position (hb_font_t *font, hb_buffer_t *buffer) const; }; struct hb_shape_plan_t; From 3bf1ce748fa89316dd32de28bfdc636495e657fb Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 14 Nov 2018 21:08:54 -0500 Subject: [PATCH 2/3] [shaper] Rename --- src/hb-shape-plan.cc | 2 +- src/hb-shape.cc | 2 +- src/hb-shaper.cc | 16 ++++++++-------- src/hb-shaper.hh | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/hb-shape-plan.cc b/src/hb-shape-plan.cc index acb589ad3..460d77b5f 100644 --- a/src/hb-shape-plan.cc +++ b/src/hb-shape-plan.cc @@ -108,7 +108,7 @@ hb_shape_plan_key_t::init (bool copy, } else { - const hb_shaper_pair_static_t *shapers = _hb_shapers_get (); + const hb_shaper_entry_t *shapers = _hb_shapers_get (); for (unsigned int i = 0; i < HB_SHAPERS_COUNT; i++) if (false) ; diff --git a/src/hb-shape.cc b/src/hb-shape.cc index 325be0f12..270da3d77 100644 --- a/src/hb-shape.cc +++ b/src/hb-shape.cc @@ -63,7 +63,7 @@ static struct hb_shaper_list_lazy_loader_t : hb_lazy_loader_t { - static inline hb_shaper_pair_static_t *create (void) + static inline hb_shaper_entry_t *create (void) { char *env = getenv ("HB_SHAPER_LIST"); if (!env || !*env) return nullptr; - hb_shaper_pair_static_t *shapers = (hb_shaper_pair_static_t *) calloc (1, sizeof (all_shapers)); + hb_shaper_entry_t *shapers = (hb_shaper_entry_t *) calloc (1, sizeof (all_shapers)); if (unlikely (!shapers)) return nullptr; @@ -68,7 +68,7 @@ static struct hb_shapers_lazy_loader_t : hb_lazy_loader_t Date: Thu, 15 Nov 2018 02:48:50 -0500 Subject: [PATCH 3/3] [base] Add TODO items --- src/hb-ot-layout-base-table.hh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/hb-ot-layout-base-table.hh b/src/hb-ot-layout-base-table.hh index 582e60155..fb57e7624 100644 --- a/src/hb-ot-layout-base-table.hh +++ b/src/hb-ot-layout-base-table.hh @@ -198,6 +198,7 @@ struct MinMax const BaseCoord **min, const BaseCoord **max) const { + /* TODO Replace hb_bsearch() with .bsearch(). */ const FeatMinMaxRecord *minMaxCoord = (const FeatMinMaxRecord *) hb_bsearch (&feature_tag, featMinMaxRecords.arrayZ, featMinMaxRecords.len, @@ -230,7 +231,7 @@ struct MinMax maxCoord; /* Offset to BaseCoord table that defines * maximum extent value, from the beginning * of MinMax table (may be NULL) */ - ArrayOf + SortedArrayOf featMinMaxRecords; /* Array of FeatMinMaxRecords, in alphabetical * order by featureTableTag */ @@ -302,6 +303,7 @@ struct BaseScript { inline const MinMax &get_min_max (hb_tag_t language_tag) const { + /* TODO Replace hb_bsearch() with .bsearch(). */ const BaseLangSysRecord* record = (const BaseLangSysRecord *) hb_bsearch (&language_tag, baseLangSysRecords.arrayZ, baseLangSysRecords.len, @@ -332,7 +334,7 @@ struct BaseScript OffsetTo defaultMinMax; /* Offset to MinMax table, from beginning of * BaseScript table (may be NULL) */ - ArrayOf + SortedArrayOf baseLangSysRecords; /* Number of BaseLangSysRecords * defined — may be zero (0) */ @@ -377,6 +379,7 @@ struct BaseScriptList { inline const BaseScriptRecord *find_record (hb_tag_t script) const { + /* TODO Replace hb_bsearch() with .bsearch(). */ return (const BaseScriptRecord *) hb_bsearch (&script, baseScriptRecords.arrayZ, baseScriptRecords.len, BaseScriptRecord::static_size, @@ -400,7 +403,7 @@ struct BaseScriptList } protected: - ArrayOf + SortedArrayOf baseScriptRecords; public: