From 7d8d58ac81fe267e29ea68cdc6f4a4fa8c22d40f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 11 Feb 2016 16:34:28 +0700 Subject: [PATCH] [GPOS] Divide position_finish() into two phases, for advances and offsets Right now the position_finish_advances() is empty. To be used for spacing attachments proposal later. --- src/hb-ot-layout-gpos-table.hh | 11 +++++++++-- src/hb-ot-layout-gsub-table.hh | 6 ------ src/hb-ot-layout-private.hh | 19 +++++++++---------- src/hb-ot-layout.cc | 16 ++++++++-------- src/hb-ot-shape.cc | 7 +++---- 5 files changed, 29 insertions(+), 30 deletions(-) diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index 8795c8ab1..bc18c8707 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -1512,7 +1512,8 @@ struct GPOS : GSUBGPOS { return CastR (GSUBGPOS::get_lookup (i)); } static inline void position_start (hb_font_t *font, hb_buffer_t *buffer); - static inline void position_finish (hb_font_t *font, hb_buffer_t *buffer); + static inline void position_finish_advances (hb_font_t *font, hb_buffer_t *buffer); + static inline void position_finish_offsets (hb_font_t *font, hb_buffer_t *buffer); inline bool sanitize (hb_sanitize_context_t *c) const { @@ -1607,7 +1608,13 @@ GPOS::position_start (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer) } void -GPOS::position_finish (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer) +GPOS::position_finish_advances (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer) +{ + //_hb_buffer_assert_gsubgpos_vars (buffer); +} + +void +GPOS::position_finish_offsets (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer) { _hb_buffer_assert_gsubgpos_vars (buffer); diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index 459a1a3dd..38c2c6405 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -1268,7 +1268,6 @@ struct GSUB : GSUBGPOS { return CastR (GSUBGPOS::get_lookup (i)); } static inline void substitute_start (hb_font_t *font, hb_buffer_t *buffer); - static inline void substitute_finish (hb_font_t *font, hb_buffer_t *buffer); inline bool sanitize (hb_sanitize_context_t *c) const { @@ -1297,11 +1296,6 @@ GSUB::substitute_start (hb_font_t *font, hb_buffer_t *buffer) } } -void -GSUB::substitute_finish (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer HB_UNUSED) -{ -} - /* Out-of-class implementation for methods recursing */ diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh index f48184fd3..da3ba3a92 100644 --- a/src/hb-ot-layout-private.hh +++ b/src/hb-ot-layout-private.hh @@ -99,21 +99,20 @@ hb_ot_layout_substitute_lookup (OT::hb_apply_context_t *c, const hb_ot_layout_lookup_accelerator_t &accel); -/* Should be called after all the substitute_lookup's are done */ -HB_INTERNAL void -hb_ot_layout_substitute_finish (hb_font_t *font, - hb_buffer_t *buffer); - - -/* Should be called before all the position_lookup's are done. Resets positions to zero. */ +/* Should be called before all the position_lookup's are done. */ HB_INTERNAL void hb_ot_layout_position_start (hb_font_t *font, hb_buffer_t *buffer); -/* Should be called after all the position_lookup's are done */ +/* Should be called after all the position_lookup's are done, to finish advances. */ HB_INTERNAL void -hb_ot_layout_position_finish (hb_font_t *font, - hb_buffer_t *buffer); +hb_ot_layout_position_finish_advances (hb_font_t *font, + hb_buffer_t *buffer); + +/* Should be called after hb_ot_layout_position_finish_advances, to finish offsets. */ +HB_INTERNAL void +hb_ot_layout_position_finish_offsets (hb_font_t *font, + hb_buffer_t *buffer); diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index cdffc6172..adf232bf1 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -771,12 +771,6 @@ hb_ot_layout_substitute_start (hb_font_t *font, hb_buffer_t *buffer) OT::GSUB::substitute_start (font, buffer); } -void -hb_ot_layout_substitute_finish (hb_font_t *font, hb_buffer_t *buffer) -{ - OT::GSUB::substitute_finish (font, buffer); -} - /** * hb_ot_layout_lookup_substitute_closure: * @@ -811,9 +805,15 @@ hb_ot_layout_position_start (hb_font_t *font, hb_buffer_t *buffer) } void -hb_ot_layout_position_finish (hb_font_t *font, hb_buffer_t *buffer) +hb_ot_layout_position_finish_advances (hb_font_t *font, hb_buffer_t *buffer) { - OT::GPOS::position_finish (font, buffer); + OT::GPOS::position_finish_advances (font, buffer); +} + +void +hb_ot_layout_position_finish_offsets (hb_font_t *font, hb_buffer_t *buffer) +{ + OT::GPOS::position_finish_offsets (font, buffer); } /** diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 10c52cfaf..0b0232898 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -584,8 +584,6 @@ hb_ot_substitute_complex (hb_ot_shape_context_t *c) c->plan->substitute (c->font, buffer); - hb_ot_layout_substitute_finish (c->font, buffer); - return; } @@ -733,9 +731,10 @@ hb_ot_position_complex (hb_ot_shape_context_t *c) break; } + /* Finishing off GPOS has to follow a certain order. */ + hb_ot_layout_position_finish_advances (c->font, c->buffer); hb_ot_zero_width_default_ignorables (c); - - hb_ot_layout_position_finish (c->font, c->buffer); + hb_ot_layout_position_finish_offsets (c->font, c->buffer); return ret; }