From 5df809b655bb1318115651fd87d4555cdd9b41cb Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 13 May 2012 15:17:51 +0200 Subject: [PATCH] [GSUB/GPOS] Remove context_length The spec doesn't say contextual matching should be done this way, and AOTS doesn't do it either. It was inherited from old HarfBuzz. Remove it. --- src/hb-ot-layout-common-private.hh | 1 - src/hb-ot-layout-gpos-table.hh | 3 --- src/hb-ot-layout-gsub-table.hh | 6 ++---- src/hb-ot-layout-gsubgpos-private.hh | 32 ++++++++++------------------ 4 files changed, 13 insertions(+), 29 deletions(-) diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh index 20510009f..6ea28bc81 100644 --- a/src/hb-ot-layout-common-private.hh +++ b/src/hb-ot-layout-common-private.hh @@ -34,7 +34,6 @@ #include "hb-set-private.hh" -#define NO_CONTEXT ((unsigned int) 0x110000) #define NOT_COVERED ((unsigned int) 0x110000) #define MAX_NESTING_LEVEL 8 diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index 44ec65f52..ecd06c4d0 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -1532,9 +1532,6 @@ static inline bool position_lookup (hb_apply_context_t *c, unsigned int lookup_i if (unlikely (c->nesting_level_left == 0)) return false; - if (unlikely (c->context_length < 1)) - return false; - hb_apply_context_t new_c (*c); new_c.nesting_level_left--; new_c.set_lookup (l); diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index bc2b0e1b7..8c57f6086 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -804,7 +804,8 @@ struct ReverseChainSingleSubstFormat1 inline bool apply (hb_apply_context_t *c) const { TRACE_APPLY (); - if (unlikely (c->context_length != NO_CONTEXT)) return TRACE_RETURN (false); /* No chaining to this type */ + if (unlikely (c->nesting_level_left != MAX_NESTING_LEVEL)) + return TRACE_RETURN (false); /* No chaining to this type */ unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint); if (likely (index == NOT_COVERED)) return TRACE_RETURN (false); @@ -1243,9 +1244,6 @@ static inline bool substitute_lookup (hb_apply_context_t *c, unsigned int lookup if (unlikely (c->nesting_level_left == 0)) return false; - if (unlikely (c->context_length < 1)) - return false; - hb_apply_context_t new_c (*c); new_c.nesting_level_left--; new_c.set_lookup (l); diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh index a000c15a8..2e8b92a5b 100644 --- a/src/hb-ot-layout-gsubgpos-private.hh +++ b/src/hb-ot-layout-gsubgpos-private.hh @@ -106,7 +106,6 @@ struct hb_apply_context_t hb_buffer_t *buffer; hb_direction_t direction; hb_mask_t lookup_mask; - unsigned int context_length; unsigned int nesting_level_left; unsigned int lookup_props; unsigned int property; /* propety of first glyph */ @@ -117,12 +116,10 @@ struct hb_apply_context_t hb_face_t *face_, hb_buffer_t *buffer_, hb_mask_t lookup_mask_, - unsigned int context_length_ = NO_CONTEXT, unsigned int nesting_level_left_ = MAX_NESTING_LEVEL) : font (font_), face (face_), buffer (buffer_), direction (buffer_->props.direction), lookup_mask (lookup_mask_), - context_length (context_length_), nesting_level_left (nesting_level_left_), lookup_props (0), property (0), debug_depth (0) {} @@ -142,7 +139,7 @@ struct hb_apply_context_t num_items = num_items_; mask = context_match ? -1 : c->lookup_mask; syllable = context_match ? 0 : c->buffer->info[c->buffer->idx].syllable (); - end = MIN (c->buffer->len, c->buffer->idx + c->context_length); + end = c->buffer->len; } inline bool has_no_chance (void) const { @@ -320,7 +317,7 @@ static inline bool match_input (hb_apply_context_t *c, const USHORT input[], /* Array of input values--start with second glyph */ match_func_t match_func, const void *match_data, - unsigned int *context_length_out) + unsigned int *end_offset = NULL) { hb_apply_context_t::mark_skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, count - 1); if (skippy_iter.has_no_chance ()) @@ -335,7 +332,8 @@ static inline bool match_input (hb_apply_context_t *c, return false; } - *context_length_out = skippy_iter.idx - c->buffer->idx + 1; + if (end_offset) + *end_offset = skippy_iter.idx - c->buffer->idx + 1; return true; } @@ -418,7 +416,7 @@ static inline bool apply_lookup (hb_apply_context_t *c, const LookupRecord lookupRecord[], /* Array of LookupRecords--in design order */ apply_lookup_func_t apply_func) { - unsigned int end = MIN (c->buffer->len, c->buffer->idx + c->context_length); + unsigned int end = c->buffer->len; if (unlikely (count == 0 || c->buffer->idx + count > end)) return false; @@ -509,12 +507,10 @@ static inline bool context_apply_lookup (hb_apply_context_t *c, const LookupRecord lookupRecord[], ContextApplyLookupContext &lookup_context) { - hb_apply_context_t new_context = *c; return match_input (c, inputCount, input, - lookup_context.funcs.match, lookup_context.match_data, - &new_context.context_length) - && apply_lookup (&new_context, + lookup_context.funcs.match, lookup_context.match_data) + && apply_lookup (c, inputCount, lookupCount, lookupRecord, lookup_context.funcs.apply); @@ -883,25 +879,19 @@ static inline bool chain_context_apply_lookup (hb_apply_context_t *c, const LookupRecord lookupRecord[], ChainContextApplyLookupContext &lookup_context) { - /* First guess */ - if (unlikely (c->buffer->backtrack_len () < backtrackCount || - c->buffer->idx + inputCount + lookaheadCount > c->buffer->len || - inputCount + lookaheadCount > c->context_length)) - return false; - - hb_apply_context_t new_context = *c; + unsigned int lookahead_offset; return match_backtrack (c, backtrackCount, backtrack, lookup_context.funcs.match, lookup_context.match_data[0]) && match_input (c, inputCount, input, lookup_context.funcs.match, lookup_context.match_data[1], - &new_context.context_length) + &lookahead_offset) && match_lookahead (c, lookaheadCount, lookahead, lookup_context.funcs.match, lookup_context.match_data[2], - new_context.context_length) - && apply_lookup (&new_context, + lookahead_offset) + && apply_lookup (c, inputCount, lookupCount, lookupRecord, lookup_context.funcs.apply);