From d46606e119b48dcca375d6313abd0f93ba5d09c3 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 21 Feb 2013 15:39:57 -0500 Subject: [PATCH] Port TrueType-kerning to use skippy iterator It skips joiners and default ignorables now. Skips marks too, but only if there is proper GDEF classes for marks. --- src/hb-ot-shape-fallback.cc | 50 +++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/src/hb-ot-shape-fallback.cc b/src/hb-ot-shape-fallback.cc index cd9d9a405..afe0f392c 100644 --- a/src/hb-ot-shape-fallback.cc +++ b/src/hb-ot-shape-fallback.cc @@ -25,6 +25,7 @@ */ #include "hb-ot-shape-fallback-private.hh" +#include "hb-ot-layout-gsubgpos-private.hh" static unsigned int recategorize_combining_class (hb_codepoint_t u, @@ -419,31 +420,36 @@ _hb_ot_shape_fallback_kern (const hb_ot_shape_plan_t *plan, hb_mask_t kern_mask = plan->map.get_1_mask (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction) ? HB_TAG ('k','e','r','n') : HB_TAG ('v','k','r','n')); - if (unlikely (!count)) return; + OT::hb_apply_context_t c (1, font, buffer, kern_mask, true/*auto_joiners*/); + c.set_lookup_props (OT::LookupFlag::IgnoreMarks); - bool enabled = buffer->info[0].mask & kern_mask; - for (unsigned int i = 1; i < count; i++) + for (buffer->idx = 0; buffer->idx < count;) { - bool next = buffer->info[i].mask & kern_mask; - if (enabled && next) + OT::hb_apply_context_t::skipping_forward_iterator_t skippy_iter (&c, buffer->idx, 1); + if (!skippy_iter.next ()) { - hb_position_t x_kern, y_kern, kern1, kern2; - font->get_glyph_kerning_for_direction (buffer->info[i - 1].codepoint, buffer->info[i].codepoint, - buffer->props.direction, - &x_kern, &y_kern); - - kern1 = x_kern >> 1; - kern2 = x_kern - kern1; - buffer->pos[i - 1].x_advance += kern1; - buffer->pos[i].x_advance += kern2; - buffer->pos[i].x_offset += kern2; - - kern1 = y_kern >> 1; - kern2 = y_kern - kern1; - buffer->pos[i - 1].y_advance += kern1; - buffer->pos[i].y_advance += kern2; - buffer->pos[i].y_offset += kern2; + buffer->idx++; + continue; } - enabled = next; + + hb_position_t x_kern, y_kern, kern1, kern2; + font->get_glyph_kerning_for_direction (buffer->info[buffer->idx].codepoint, + buffer->info[skippy_iter.idx].codepoint, + buffer->props.direction, + &x_kern, &y_kern); + + kern1 = x_kern >> 1; + kern2 = x_kern - kern1; + buffer->pos[buffer->idx].x_advance += kern1; + buffer->pos[skippy_iter.idx].x_advance += kern2; + buffer->pos[skippy_iter.idx].x_offset += kern2; + + kern1 = y_kern >> 1; + kern2 = y_kern - kern1; + buffer->pos[buffer->idx].y_advance += kern1; + buffer->pos[skippy_iter.idx].y_advance += kern2; + buffer->pos[skippy_iter.idx].y_offset += kern2; + + buffer->idx = skippy_iter.idx; } }