From 8e88653f05daa3f78462ba4949b6713115b26aa9 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 1 Sep 2022 13:39:26 -0600 Subject: [PATCH] [layout] Move code around --- src/hb-ot-layout.cc | 104 ++++++++++++++++++++++---------------------- 1 file changed, 53 insertions(+), 51 deletions(-) diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 30cedbb7d..cbe1b7411 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -1710,57 +1710,6 @@ hb_ot_layout_get_size_params (hb_face_t *face, return false; } -struct hb_position_single_dispatch_t : - hb_dispatch_context_t -{ - static return_t default_return_value () { return false; } - bool stop_sublookup_iteration (return_t r) const { return r; } - - private: - template auto - _dispatch (const T &obj, hb_priority<1>, Ts&&... ds) HB_AUTO_RETURN - ( obj.position_single (std::forward (ds)...) ) - template auto - _dispatch (const T &obj, hb_priority<0>, Ts&&... ds) HB_AUTO_RETURN - ( default_return_value () ) - public: - template auto - dispatch (const T &obj, Ts&&... ds) HB_AUTO_RETURN - ( _dispatch (obj, hb_prioritize, std::forward (ds)...) ) -}; - -hb_position_t -hb_ot_layout_get_optical_bound (hb_font_t *font, - unsigned lookup_index, - hb_direction_t direction, - hb_codepoint_t glyph) -{ - const OT::PosLookup &lookup = font->face->table.GPOS->table->get_lookup (lookup_index); - hb_glyph_position_t pos = {0}; - hb_position_single_dispatch_t c; - lookup.dispatch (&c, font, direction, glyph, pos); - hb_position_t ret = 0; - switch (direction) - { - case HB_DIRECTION_LTR: - ret = pos.x_offset; - break; - case HB_DIRECTION_RTL: - ret = pos.x_advance - pos.x_offset; - break; - case HB_DIRECTION_TTB: - ret = pos.y_offset; - break; - case HB_DIRECTION_BTT: - ret = pos.y_advance - pos.y_offset; - break; - case HB_DIRECTION_INVALID: - default: - break; - } - return ret; -} - /** * hb_ot_layout_feature_get_name_ids: @@ -2426,4 +2375,57 @@ hb_ot_layout_lookup_get_glyph_alternates (hb_face_t *face, return ret; } + +struct hb_position_single_dispatch_t : + hb_dispatch_context_t +{ + static return_t default_return_value () { return false; } + bool stop_sublookup_iteration (return_t r) const { return r; } + + private: + template auto + _dispatch (const T &obj, hb_priority<1>, Ts&&... ds) HB_AUTO_RETURN + ( obj.position_single (std::forward (ds)...) ) + template auto + _dispatch (const T &obj, hb_priority<0>, Ts&&... ds) HB_AUTO_RETURN + ( default_return_value () ) + public: + template auto + dispatch (const T &obj, Ts&&... ds) HB_AUTO_RETURN + ( _dispatch (obj, hb_prioritize, std::forward (ds)...) ) +}; + +hb_position_t +hb_ot_layout_get_optical_bound (hb_font_t *font, + unsigned lookup_index, + hb_direction_t direction, + hb_codepoint_t glyph) +{ + const OT::PosLookup &lookup = font->face->table.GPOS->table->get_lookup (lookup_index); + hb_glyph_position_t pos = {0}; + hb_position_single_dispatch_t c; + lookup.dispatch (&c, font, direction, glyph, pos); + hb_position_t ret = 0; + switch (direction) + { + case HB_DIRECTION_LTR: + ret = pos.x_offset; + break; + case HB_DIRECTION_RTL: + ret = pos.x_advance - pos.x_offset; + break; + case HB_DIRECTION_TTB: + ret = pos.y_offset; + break; + case HB_DIRECTION_BTT: + ret = pos.y_advance - pos.y_offset; + break; + case HB_DIRECTION_INVALID: + default: + break; + } + return ret; +} + + #endif