[HB] One more step to go, for fully working GSUB and ChainContext

This commit is contained in:
Behdad Esfahbod 2009-05-18 02:47:57 -04:00
parent f14c2b7acf
commit 02e1e5c63f
1 changed files with 63 additions and 48 deletions

View File

@ -168,12 +168,9 @@ static inline bool context_lookup (LOOKUP_ARGS_DEF,
USHORT inputCount, /* Including the first glyph (not matched) */ USHORT inputCount, /* Including the first glyph (not matched) */
const USHORT input[], /* Array of input values--start with second glyph */ const USHORT input[], /* Array of input values--start with second glyph */
USHORT lookupCount, USHORT lookupCount,
const LookupRecord lookupRecord[], /* Array of LookupRecords--in design order */ const LookupRecord lookupRecord[],
ContextLookupContext &context) ContextLookupContext &context)
{ {
unsigned int i, j;
unsigned int count = inputCount;
return match_input (LOOKUP_ARGS, return match_input (LOOKUP_ARGS,
inputCount, input, inputCount, input,
context.funcs.match, context.match_data, context.funcs.match, context.match_data,
@ -308,8 +305,12 @@ struct ContextFormat3 {
friend struct Context; friend struct Context;
private: private:
inline bool apply (LOOKUP_ARGS_DEF, apply_lookup_func_t apply_func) const {
unsigned int index = (this+coverage[0]) (IN_CURGLYPH ());
if (G_LIKELY (index == NOT_COVERED))
return false;
inline bool apply_coverage (LOOKUP_ARGS_DEF, apply_lookup_func_t apply_func) const {
const LookupRecord *lookupRecord = (const LookupRecord *) const LookupRecord *lookupRecord = (const LookupRecord *)
((const char *) coverage + ((const char *) coverage +
sizeof (coverage[0]) * glyphCount); sizeof (coverage[0]) * glyphCount);
@ -325,15 +326,6 @@ struct ContextFormat3 {
context); context);
} }
inline bool apply (LOOKUP_ARGS_DEF, apply_lookup_func_t apply_func) const {
unsigned int index = (this+coverage[0]) (IN_CURGLYPH ());
if (G_LIKELY (index == NOT_COVERED))
return false;
return apply_coverage (LOOKUP_ARGS, apply_func);
}
private: private:
USHORT format; /* Format identifier--format = 3 */ USHORT format; /* Format identifier--format = 3 */
USHORT glyphCount; /* Number of glyphs in the input glyph USHORT glyphCount; /* Number of glyphs in the input glyph
@ -377,6 +369,26 @@ struct ChainContextLookupContext {
char *match_data[3]; char *match_data[3];
}; };
static inline bool chain_context_lookup (LOOKUP_ARGS_DEF,
USHORT backtrackCount,
const USHORT backtrack[],
USHORT inputCount, /* Including the first glyph (not matched) */
const USHORT input[], /* Array of input values--start with second glyph */
USHORT lookaheadCount,
const USHORT lookahead[],
USHORT lookupCount,
const LookupRecord lookupRecord[],
ChainContextLookupContext &context)
{
return match_input (LOOKUP_ARGS,
inputCount, input,
context.funcs.match, context.match_data[1],
&context_length) &&
apply_lookup (LOOKUP_ARGS,
inputCount,
lookupCount, lookupRecord,
context.funcs.apply);
}
struct ChainRule { struct ChainRule {
@ -388,15 +400,18 @@ struct ChainRule {
((const char *) &backtrack + backtrack.get_size ()); ((const char *) &backtrack + backtrack.get_size ());
const ArrayOf<USHORT> &lookahead = * (const ArrayOf<USHORT> *) const ArrayOf<USHORT> &lookahead = * (const ArrayOf<USHORT> *)
((const char *) &input + input.get_size ()); ((const char *) &input + input.get_size ());
const LookupRecord &lookupRecord = * (const LookupRecord *) const ArrayOf<LookupRecord> &lookup = * (const ArrayOf<LookupRecord> *)
((const char *) &lookahead + lookahead.get_size ()); ((const char *) &lookahead + lookahead.get_size ());
// XXXXXXXXXXXXXXXXXX return chain_context_lookup (LOOKUP_ARGS,
// return context_lookup (LOOKUP_ARGS, backtrack.len,
// inputCount, backtrack.array,
// input, input.len,
// lookupCount, input.array + 1,
// record, lookahead.len,
// context); lookahead.array,
lookup.len,
lookup.array,
context);
return false; return false;
} }
@ -413,7 +428,7 @@ struct ChainRule {
lookaheadX; /* Array of lookahead values's (to be lookaheadX; /* Array of lookahead values's (to be
* matched after the input sequence) */ * matched after the input sequence) */
ArrayOf<LookupRecord> ArrayOf<LookupRecord>
lookupRecordX; /* Array of LookupRecords--in lookupX; /* Array of LookupRecords--in
* design order) */ * design order) */
}; };
ASSERT_SIZE (ChainRule, 8); ASSERT_SIZE (ChainRule, 8);
@ -526,36 +541,36 @@ struct ChainContextFormat3 {
private: private:
inline bool apply_coverage (LOOKUP_ARGS_DEF, apply_lookup_func_t apply_func) const { inline bool apply_coverage (LOOKUP_ARGS_DEF, apply_lookup_func_t apply_func) const {
const OffsetArrayOf<Coverage> &input = * (const OffsetArrayOf<Coverage> *)
((const char *) &backtrack + backtrack.get_size ());
const OffsetArrayOf<Coverage> &lookahead = * (const OffsetArrayOf<Coverage> *)
((const char *) &input + input.get_size ());
const LookupRecord &lookupRecord = * (const LookupRecord *)
((const char *) &lookahead + lookahead.get_size ());
struct ChainContextLookupContext context = {
{match_coverage, apply_func},
{(char *) this, (char *) this, (char *) this}
};
/*
XXXXXXXXXXXXXXXXXXXXX
return context_lookup (LOOKUP_ARGS,
glyphCount,
(const USHORT *) (coverage + 1),
lookupCount,
record,
context);
*/
return false;
} }
inline bool apply (LOOKUP_ARGS_DEF, apply_lookup_func_t apply_func) const { inline bool apply (LOOKUP_ARGS_DEF, apply_lookup_func_t apply_func) const {
/* XXX */ const OffsetArrayOf<Coverage> &input = * (const OffsetArrayOf<Coverage> *)
unsigned int index = 0;//(this+coverage[0]) (IN_CURGLYPH ()); ((const char *) &backtrack + backtrack.get_size ());
unsigned int index = (this+input[0]) (IN_CURGLYPH ());
if (G_LIKELY (index == NOT_COVERED)) if (G_LIKELY (index == NOT_COVERED))
return false; return false;
return apply_coverage (LOOKUP_ARGS, apply_func); const OffsetArrayOf<Coverage> &lookahead = * (const OffsetArrayOf<Coverage> *)
((const char *) &input + input.get_size ());
const ArrayOf<LookupRecord> &lookup = * (const ArrayOf<LookupRecord> *)
((const char *) &lookahead + lookahead.get_size ());
struct ChainContextLookupContext context = {
{match_coverage, apply_func},
{(char *) this, (char *) this, (char *) this}
};
return chain_context_lookup (LOOKUP_ARGS,
backtrack.len,
(USHORT *) backtrack.array,
input.len,
(USHORT *) input.array,
lookahead.len,
(USHORT *) lookahead.array,
lookup.len,
lookup.array,
context);
return false;
} }
private: private:
@ -573,7 +588,7 @@ struct ChainContextFormat3 {
* in lookahead sequence, in glyph * in lookahead sequence, in glyph
* sequence order */ * sequence order */
ArrayOf<LookupRecord> ArrayOf<LookupRecord>
lookupRecordX; /* Array of LookupRecords--in lookupX; /* Array of LookupRecords--in
* design order) */ * design order) */
}; };
ASSERT_SIZE (ChainContextFormat3, 10); ASSERT_SIZE (ChainContextFormat3, 10);