From 3c23ff9b7c4241ec23054a95f1fdfbdef2c51f40 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 8 Oct 2018 23:26:26 -0400 Subject: [PATCH] [kern] Add kerning driver to TT kern table --- src/hb-ot-kern-table.hh | 19 +++++++++++++++++-- src/hb-ot-shape-fallback.cc | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh index f7c2ed380..6033bcce5 100644 --- a/src/hb-ot-kern-table.hh +++ b/src/hb-ot-kern-table.hh @@ -35,7 +35,7 @@ template struct hb_kern_machine_t { - hb_kern_machine_t (Driver &driver_) : driver (driver_) {} + hb_kern_machine_t (const Driver &driver_) : driver (driver_) {} inline void kern (const hb_ot_shape_plan_t *plan, hb_font_t *font, @@ -96,7 +96,7 @@ struct hb_kern_machine_t } } - Driver &driver; + const Driver &driver; }; @@ -447,6 +447,21 @@ struct kern inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const { return table->get_h_kerning (left, right, table_length); } + inline int get_kerning (hb_codepoint_t first, hb_codepoint_t second) const + { return get_h_kerning (first, second); } + + inline void apply (hb_ot_shape_plan_t *plan, + hb_font_t *font, + hb_buffer_t *buffer) const + { + if (!HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction)) + return; + + hb_kern_machine_t machine (*this); + + machine.kern (plan, font, buffer); + } + private: hb_blob_t *blob; const kern *table; diff --git a/src/hb-ot-shape-fallback.cc b/src/hb-ot-shape-fallback.cc index 920ef22c6..fb7db1d5f 100644 --- a/src/hb-ot-shape-fallback.cc +++ b/src/hb-ot-shape-fallback.cc @@ -447,7 +447,7 @@ _hb_ot_shape_fallback_kern (const hb_ot_shape_plan_t *plan, hb_buffer_t *buffer) : font (font_), direction (buffer->props.direction) {} - hb_position_t get_kerning (hb_codepoint_t first, hb_codepoint_t second) + hb_position_t get_kerning (hb_codepoint_t first, hb_codepoint_t second) const { hb_position_t kern = 0; font->get_glyph_kerning_for_direction (first, second,