提交 02e1e5c6 编写于 作者: B Behdad Esfahbod

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

上级 f14c2b7a
...@@ -168,12 +168,9 @@ static inline bool context_lookup (LOOKUP_ARGS_DEF, ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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,38 +541,38 @@ struct ChainContextFormat3 { ...@@ -526,38 +541,38 @@ 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 {
}
inline bool apply (LOOKUP_ARGS_DEF, apply_lookup_func_t apply_func) const {
const OffsetArrayOf<Coverage> &input = * (const OffsetArrayOf<Coverage> *) const OffsetArrayOf<Coverage> &input = * (const OffsetArrayOf<Coverage> *)
((const char *) &backtrack + backtrack.get_size ()); ((const char *) &backtrack + backtrack.get_size ());
unsigned int index = (this+input[0]) (IN_CURGLYPH ());
if (G_LIKELY (index == NOT_COVERED))
return false;
const OffsetArrayOf<Coverage> &lookahead = * (const OffsetArrayOf<Coverage> *) const OffsetArrayOf<Coverage> &lookahead = * (const OffsetArrayOf<Coverage> *)
((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 ());
struct ChainContextLookupContext context = { struct ChainContextLookupContext context = {
{match_coverage, apply_func}, {match_coverage, apply_func},
{(char *) this, (char *) this, (char *) this} {(char *) this, (char *) this, (char *) this}
}; };
/* return chain_context_lookup (LOOKUP_ARGS,
XXXXXXXXXXXXXXXXXXXXX backtrack.len,
return context_lookup (LOOKUP_ARGS, (USHORT *) backtrack.array,
glyphCount, input.len,
(const USHORT *) (coverage + 1), (USHORT *) input.array,
lookupCount, lookahead.len,
record, (USHORT *) lookahead.array,
context); lookup.len,
*/ lookup.array,
context);
return false; return false;
} }
inline bool apply (LOOKUP_ARGS_DEF, apply_lookup_func_t apply_func) const {
/* XXX */
unsigned int index = 0;//(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 */
OffsetArrayOf<Coverage> OffsetArrayOf<Coverage>
...@@ -573,7 +588,7 @@ struct ChainContextFormat3 { ...@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册