[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.
This commit is contained in:
Behdad Esfahbod 2012-05-13 15:17:51 +02:00
parent 28b9d502bb
commit 5df809b655
4 changed files with 13 additions and 29 deletions

View File

@ -34,7 +34,6 @@
#include "hb-set-private.hh" #include "hb-set-private.hh"
#define NO_CONTEXT ((unsigned int) 0x110000)
#define NOT_COVERED ((unsigned int) 0x110000) #define NOT_COVERED ((unsigned int) 0x110000)
#define MAX_NESTING_LEVEL 8 #define MAX_NESTING_LEVEL 8

View File

@ -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)) if (unlikely (c->nesting_level_left == 0))
return false; return false;
if (unlikely (c->context_length < 1))
return false;
hb_apply_context_t new_c (*c); hb_apply_context_t new_c (*c);
new_c.nesting_level_left--; new_c.nesting_level_left--;
new_c.set_lookup (l); new_c.set_lookup (l);

View File

@ -804,7 +804,8 @@ struct ReverseChainSingleSubstFormat1
inline bool apply (hb_apply_context_t *c) const inline bool apply (hb_apply_context_t *c) const
{ {
TRACE_APPLY (); 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); unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false); 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)) if (unlikely (c->nesting_level_left == 0))
return false; return false;
if (unlikely (c->context_length < 1))
return false;
hb_apply_context_t new_c (*c); hb_apply_context_t new_c (*c);
new_c.nesting_level_left--; new_c.nesting_level_left--;
new_c.set_lookup (l); new_c.set_lookup (l);

View File

@ -106,7 +106,6 @@ struct hb_apply_context_t
hb_buffer_t *buffer; hb_buffer_t *buffer;
hb_direction_t direction; hb_direction_t direction;
hb_mask_t lookup_mask; hb_mask_t lookup_mask;
unsigned int context_length;
unsigned int nesting_level_left; unsigned int nesting_level_left;
unsigned int lookup_props; unsigned int lookup_props;
unsigned int property; /* propety of first glyph */ unsigned int property; /* propety of first glyph */
@ -117,12 +116,10 @@ struct hb_apply_context_t
hb_face_t *face_, hb_face_t *face_,
hb_buffer_t *buffer_, hb_buffer_t *buffer_,
hb_mask_t lookup_mask_, hb_mask_t lookup_mask_,
unsigned int context_length_ = NO_CONTEXT,
unsigned int nesting_level_left_ = MAX_NESTING_LEVEL) : unsigned int nesting_level_left_ = MAX_NESTING_LEVEL) :
font (font_), face (face_), buffer (buffer_), font (font_), face (face_), buffer (buffer_),
direction (buffer_->props.direction), direction (buffer_->props.direction),
lookup_mask (lookup_mask_), lookup_mask (lookup_mask_),
context_length (context_length_),
nesting_level_left (nesting_level_left_), nesting_level_left (nesting_level_left_),
lookup_props (0), property (0), debug_depth (0) {} lookup_props (0), property (0), debug_depth (0) {}
@ -142,7 +139,7 @@ struct hb_apply_context_t
num_items = num_items_; num_items = num_items_;
mask = context_match ? -1 : c->lookup_mask; mask = context_match ? -1 : c->lookup_mask;
syllable = context_match ? 0 : c->buffer->info[c->buffer->idx].syllable (); 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 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 */ const USHORT input[], /* Array of input values--start with second glyph */
match_func_t match_func, match_func_t match_func,
const void *match_data, 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); hb_apply_context_t::mark_skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, count - 1);
if (skippy_iter.has_no_chance ()) if (skippy_iter.has_no_chance ())
@ -335,7 +332,8 @@ static inline bool match_input (hb_apply_context_t *c,
return false; 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; 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 */ const LookupRecord lookupRecord[], /* Array of LookupRecords--in design order */
apply_lookup_func_t apply_func) 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)) if (unlikely (count == 0 || c->buffer->idx + count > end))
return false; return false;
@ -509,12 +507,10 @@ static inline bool context_apply_lookup (hb_apply_context_t *c,
const LookupRecord lookupRecord[], const LookupRecord lookupRecord[],
ContextApplyLookupContext &lookup_context) ContextApplyLookupContext &lookup_context)
{ {
hb_apply_context_t new_context = *c;
return match_input (c, return match_input (c,
inputCount, input, inputCount, input,
lookup_context.funcs.match, lookup_context.match_data, lookup_context.funcs.match, lookup_context.match_data)
&new_context.context_length) && apply_lookup (c,
&& apply_lookup (&new_context,
inputCount, inputCount,
lookupCount, lookupRecord, lookupCount, lookupRecord,
lookup_context.funcs.apply); lookup_context.funcs.apply);
@ -883,25 +879,19 @@ static inline bool chain_context_apply_lookup (hb_apply_context_t *c,
const LookupRecord lookupRecord[], const LookupRecord lookupRecord[],
ChainContextApplyLookupContext &lookup_context) ChainContextApplyLookupContext &lookup_context)
{ {
/* First guess */ unsigned int lookahead_offset;
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;
return match_backtrack (c, return match_backtrack (c,
backtrackCount, backtrack, backtrackCount, backtrack,
lookup_context.funcs.match, lookup_context.match_data[0]) lookup_context.funcs.match, lookup_context.match_data[0])
&& match_input (c, && match_input (c,
inputCount, input, inputCount, input,
lookup_context.funcs.match, lookup_context.match_data[1], lookup_context.funcs.match, lookup_context.match_data[1],
&new_context.context_length) &lookahead_offset)
&& match_lookahead (c, && match_lookahead (c,
lookaheadCount, lookahead, lookaheadCount, lookahead,
lookup_context.funcs.match, lookup_context.match_data[2], lookup_context.funcs.match, lookup_context.match_data[2],
new_context.context_length) lookahead_offset)
&& apply_lookup (&new_context, && apply_lookup (c,
inputCount, inputCount,
lookupCount, lookupRecord, lookupCount, lookupRecord,
lookup_context.funcs.apply); lookup_context.funcs.apply);