[kern] Add kerning driver to TT kern table

This commit is contained in:
Behdad Esfahbod 2018-10-08 23:26:26 -04:00
parent 683c3a9533
commit 3c23ff9b7c
2 changed files with 18 additions and 3 deletions

View File

@ -35,7 +35,7 @@
template <typename Driver> template <typename Driver>
struct hb_kern_machine_t 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, inline void kern (const hb_ot_shape_plan_t *plan,
hb_font_t *font, 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 inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const
{ return table->get_h_kerning (left, right, table_length); } { 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<accelerator_t> machine (*this);
machine.kern (plan, font, buffer);
}
private: private:
hb_blob_t *blob; hb_blob_t *blob;
const kern *table; const kern *table;

View File

@ -447,7 +447,7 @@ _hb_ot_shape_fallback_kern (const hb_ot_shape_plan_t *plan,
hb_buffer_t *buffer) : hb_buffer_t *buffer) :
font (font_), direction (buffer->props.direction) {} 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; hb_position_t kern = 0;
font->get_glyph_kerning_for_direction (first, second, font->get_glyph_kerning_for_direction (first, second,