#include "hb-ot-layout-gsubgpos-private.hh"
-
-#undef BUFFER
-#define BUFFER context->buffer
+HB_BEGIN_DECLS
struct SingleSubstFormat1
private:
- inline bool apply (hb_apply_context_t *context) const
+ inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
- hb_codepoint_t glyph_id = IN_CURGLYPH ();
+ hb_codepoint_t glyph_id = c->buffer->info[c->buffer->i].codepoint;
unsigned int index = (this+coverage) (glyph_id);
if (likely (index == NOT_COVERED))
return false;
glyph_id += deltaGlyphID;
- _hb_buffer_replace_glyph (context->buffer, glyph_id);
+ c->buffer->replace_glyph (glyph_id);
/* We inherit the old glyph class to the substituted glyph */
- if (_hb_ot_layout_has_new_glyph_classes (context->layout->face))
- _hb_ot_layout_set_glyph_property (context->layout->face, glyph_id, context->property);
+ if (_hb_ot_layout_has_new_glyph_classes (c->layout->face))
+ _hb_ot_layout_set_glyph_property (c->layout->face, glyph_id, c->property);
return true;
}
- inline bool sanitize (hb_sanitize_context_t *context) {
+ inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- return coverage.sanitize (context, this)
- && deltaGlyphID.sanitize (context);
+ return coverage.sanitize (c, this)
+ && deltaGlyphID.sanitize (c);
}
private:
private:
- inline bool apply (hb_apply_context_t *context) const
+ inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
- hb_codepoint_t glyph_id = IN_CURGLYPH ();
+ hb_codepoint_t glyph_id = c->buffer->info[c->buffer->i].codepoint;
unsigned int index = (this+coverage) (glyph_id);
if (likely (index == NOT_COVERED))
return false;
return false;
glyph_id = substitute[index];
- _hb_buffer_replace_glyph (context->buffer, glyph_id);
+ c->buffer->replace_glyph (glyph_id);
/* We inherit the old glyph class to the substituted glyph */
- if (_hb_ot_layout_has_new_glyph_classes (context->layout->face))
- _hb_ot_layout_set_glyph_property (context->layout->face, glyph_id, context->property);
+ if (_hb_ot_layout_has_new_glyph_classes (c->layout->face))
+ _hb_ot_layout_set_glyph_property (c->layout->face, glyph_id, c->property);
return true;
}
- inline bool sanitize (hb_sanitize_context_t *context) {
+ inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- return coverage.sanitize (context, this)
- && substitute.sanitize (context);
+ return coverage.sanitize (c, this)
+ && substitute.sanitize (c);
}
private:
substitute; /* Array of substitute
* GlyphIDs--ordered by Coverage Index */
public:
- DEFINE_SIZE_VAR (6, GlyphID);
+ DEFINE_SIZE_ARRAY (6, substitute);
};
struct SingleSubst
private:
- inline bool apply (hb_apply_context_t *context) const
+ inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
switch (u.format) {
- case 1: return u.format1->apply (context);
- case 2: return u.format2->apply (context);
+ case 1: return u.format1.apply (c);
+ case 2: return u.format2.apply (c);
default:return false;
}
}
- inline bool sanitize (hb_sanitize_context_t *context) {
+ inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- if (!u.format.sanitize (context)) return false;
+ if (!u.format.sanitize (c)) return false;
switch (u.format) {
- case 1: return u.format1->sanitize (context);
- case 2: return u.format2->sanitize (context);
+ case 1: return u.format1.sanitize (c);
+ case 2: return u.format2.sanitize (c);
default:return true;
}
}
private:
union {
USHORT format; /* Format identifier */
- SingleSubstFormat1 format1[VAR];
- SingleSubstFormat2 format2[VAR];
+ SingleSubstFormat1 format1;
+ SingleSubstFormat2 format2;
} u;
};
friend struct MultipleSubstFormat1;
private:
- inline bool apply (hb_apply_context_t *context) const
+ inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
if (unlikely (!substitute.len))
return false;
- _hb_buffer_add_output_glyphs_be16 (context->buffer, 1,
- substitute.len, (const uint16_t *) substitute.array(),
+ c->buffer->add_output_glyphs_be16 (1,
+ substitute.len, (const uint16_t *) substitute.array,
0xFFFF, 0xFFFF);
/* This is a guess only ... */
- if (_hb_ot_layout_has_new_glyph_classes (context->layout->face))
+ if (_hb_ot_layout_has_new_glyph_classes (c->layout->face))
{
- unsigned int property = context->property;
+ unsigned int property = c->property;
if (property == HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE)
property = HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH;
unsigned int count = substitute.len;
for (unsigned int n = 0; n < count; n++)
- _hb_ot_layout_set_glyph_property (context->layout->face, substitute[n], property);
+ _hb_ot_layout_set_glyph_property (c->layout->face, substitute[n], property);
}
return true;
}
public:
- inline bool sanitize (hb_sanitize_context_t *context) {
+ inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- return substitute.sanitize (context);
+ return substitute.sanitize (c);
}
private:
ArrayOf<GlyphID>
substitute; /* String of GlyphIDs to substitute */
public:
- DEFINE_SIZE_VAR (2, GlyphID);
+ DEFINE_SIZE_ARRAY (2, substitute);
};
struct MultipleSubstFormat1
private:
- inline bool apply (hb_apply_context_t *context) const
+ inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
- unsigned int index = (this+coverage) (IN_CURGLYPH ());
+ unsigned int index = (this+coverage) (c->buffer->info[c->buffer->i].codepoint);
if (likely (index == NOT_COVERED))
return false;
- return (this+sequence[index]).apply (context);
+ return (this+sequence[index]).apply (c);
}
- inline bool sanitize (hb_sanitize_context_t *context) {
+ inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- return coverage.sanitize (context, this)
- && sequence.sanitize (context, this);
+ return coverage.sanitize (c, this)
+ && sequence.sanitize (c, this);
}
private:
sequence; /* Array of Sequence tables
* ordered by Coverage Index */
public:
- DEFINE_SIZE_VAR (6, OffsetTo<Sequence>);
+ DEFINE_SIZE_ARRAY (6, sequence);
};
struct MultipleSubst
private:
- inline bool apply (hb_apply_context_t *context) const
+ inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
switch (u.format) {
- case 1: return u.format1->apply (context);
+ case 1: return u.format1.apply (c);
default:return false;
}
}
- inline bool sanitize (hb_sanitize_context_t *context) {
+ inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- if (!u.format.sanitize (context)) return false;
+ if (!u.format.sanitize (c)) return false;
switch (u.format) {
- case 1: return u.format1->sanitize (context);
+ case 1: return u.format1.sanitize (c);
default:return true;
}
}
private:
union {
USHORT format; /* Format identifier */
- MultipleSubstFormat1 format1[VAR];
+ MultipleSubstFormat1 format1;
} u;
};
private:
- inline bool apply (hb_apply_context_t *context) const
+ inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
- hb_codepoint_t glyph_id = IN_CURGLYPH ();
+ hb_codepoint_t glyph_id = c->buffer->info[c->buffer->i].codepoint;
+ hb_mask_t glyph_mask = c->buffer->info[c->buffer->i].mask;
+ hb_mask_t lookup_mask = c->lookup_mask;
unsigned int index = (this+coverage) (glyph_id);
if (likely (index == NOT_COVERED))
if (unlikely (!alt_set.len))
return false;
- unsigned int alt_index = 0;
-
- /* XXX callback to user to choose alternate
- if (context->layout->face->altfunc)
- alt_index = (context->layout->face->altfunc)(context->layout->layout, context->buffer,
- context->buffer->out_pos, glyph_id,
- alt_set.len, alt_set.array);
- */
+ /* Note: This breaks badly if two features enabled this lookup together. */
+ unsigned int shift = _hb_ctz (lookup_mask);
+ unsigned int alt_index = ((lookup_mask & glyph_mask) >> shift);
- if (unlikely (alt_index >= alt_set.len))
+ if (unlikely (alt_index > alt_set.len || alt_index == 0))
return false;
- glyph_id = alt_set[alt_index];
+ glyph_id = alt_set[alt_index - 1];
- _hb_buffer_replace_glyph (context->buffer, glyph_id);
+ c->buffer->replace_glyph (glyph_id);
/* We inherit the old glyph class to the substituted glyph */
- if (_hb_ot_layout_has_new_glyph_classes (context->layout->face))
- _hb_ot_layout_set_glyph_property (context->layout->face, glyph_id, context->property);
+ if (_hb_ot_layout_has_new_glyph_classes (c->layout->face))
+ _hb_ot_layout_set_glyph_property (c->layout->face, glyph_id, c->property);
return true;
}
- inline bool sanitize (hb_sanitize_context_t *context) {
+ inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- return coverage.sanitize (context, this)
- && alternateSet.sanitize (context, this);
+ return coverage.sanitize (c, this)
+ && alternateSet.sanitize (c, this);
}
private:
alternateSet; /* Array of AlternateSet tables
* ordered by Coverage Index */
public:
- DEFINE_SIZE_VAR (6, OffsetTo<AlternateSet>);
+ DEFINE_SIZE_ARRAY (6, alternateSet);
};
struct AlternateSubst
private:
- inline bool apply (hb_apply_context_t *context) const
+ inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
switch (u.format) {
- case 1: return u.format1->apply (context);
+ case 1: return u.format1.apply (c);
default:return false;
}
}
- inline bool sanitize (hb_sanitize_context_t *context) {
+ inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- if (!u.format.sanitize (context)) return false;
+ if (!u.format.sanitize (c)) return false;
switch (u.format) {
- case 1: return u.format1->sanitize (context);
+ case 1: return u.format1.sanitize (c);
default:return true;
}
}
private:
union {
USHORT format; /* Format identifier */
- AlternateSubstFormat1 format1[VAR];
+ AlternateSubstFormat1 format1;
} u;
};
friend struct LigatureSet;
private:
- inline bool apply (hb_apply_context_t *context, bool is_mark) const
+ inline bool apply (hb_apply_context_t *c, bool is_mark) const
{
TRACE_APPLY ();
unsigned int i, j;
unsigned int count = component.len;
- unsigned int end = MIN (context->buffer->in_length, context->buffer->in_pos + context->context_length);
- if (unlikely (context->buffer->in_pos + count > end))
+ unsigned int end = MIN (c->buffer->len, c->buffer->i + c->context_length);
+ if (unlikely (c->buffer->i + count > end))
return false;
- for (i = 1, j = context->buffer->in_pos + 1; i < count; i++, j++)
+ for (i = 1, j = c->buffer->i + 1; i < count; i++, j++)
{
unsigned int property;
- while (_hb_ot_layout_skip_mark (context->layout->face, IN_INFO (j), context->lookup_flag, &property))
+ while (_hb_ot_layout_skip_mark (c->layout->face, &c->buffer->info[j], c->lookup_flag, &property))
{
if (unlikely (j + count - i == end))
return false;
if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK))
is_mark = false;
- if (likely (IN_GLYPH (j) != component[i]))
+ if (likely (c->buffer->info[j].codepoint != component[i]))
return false;
}
/* This is just a guess ... */
- if (_hb_ot_layout_has_new_glyph_classes (context->layout->face))
- _hb_ot_layout_set_glyph_class (context->layout->face, ligGlyph,
+ if (_hb_ot_layout_has_new_glyph_classes (c->layout->face))
+ _hb_ot_layout_set_glyph_class (c->layout->face, ligGlyph,
is_mark ? HB_OT_LAYOUT_GLYPH_CLASS_MARK
: HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE);
- if (j == context->buffer->in_pos + i) /* No input glyphs skipped */
+ if (j == c->buffer->i + i) /* No input glyphs skipped */
/* We don't use a new ligature ID if there are no skipped
glyphs and the ligature already has an ID. */
- _hb_buffer_add_output_glyphs_be16 (context->buffer, i,
+ c->buffer->add_output_glyphs_be16 (i,
1, (const uint16_t *) &ligGlyph,
0,
- IN_LIGID (context->buffer->in_pos) && !IN_COMPONENT (context->buffer->in_pos) ?
- 0xFFFF : _hb_buffer_allocate_lig_id (context->buffer));
+ c->buffer->info[c->buffer->i].lig_id && !c->buffer->info[c->buffer->i].component ?
+ 0xFFFF : c->buffer->allocate_lig_id ());
else
{
- unsigned int lig_id = _hb_buffer_allocate_lig_id (context->buffer);
- _hb_buffer_add_output_glyph (context->buffer, ligGlyph, 0xFFFF, lig_id);
+ unsigned int lig_id = c->buffer->allocate_lig_id ();
+ c->buffer->add_output_glyph (ligGlyph, 0xFFFF, lig_id);
/* Now we must do a second loop to copy the skipped glyphs to
`out' and assign component values to it. We start with the
for ( i = 1; i < count; i++ )
{
- while (_hb_ot_layout_skip_mark (context->layout->face, IN_CURINFO (), context->lookup_flag, NULL))
- _hb_buffer_add_output_glyph (context->buffer, IN_CURGLYPH (), i, lig_id);
+ while (_hb_ot_layout_skip_mark (c->layout->face, &c->buffer->info[c->buffer->i], c->lookup_flag, NULL))
+ c->buffer->add_output_glyph (c->buffer->info[c->buffer->i].codepoint, i, lig_id);
- (context->buffer->in_pos)++;
+ (c->buffer->i)++;
}
}
}
public:
- inline bool sanitize (hb_sanitize_context_t *context) {
+ inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- return ligGlyph.sanitize (context)
- && component.sanitize (context);
+ return ligGlyph.sanitize (c)
+ && component.sanitize (c);
}
private:
* with the second component--ordered
* in writing direction */
public:
- DEFINE_SIZE_VAR (4, GlyphID);
+ DEFINE_SIZE_ARRAY (4, component);
};
struct LigatureSet
friend struct LigatureSubstFormat1;
private:
- inline bool apply (hb_apply_context_t *context, bool is_mark) const
+ inline bool apply (hb_apply_context_t *c, bool is_mark) const
{
TRACE_APPLY ();
unsigned int num_ligs = ligature.len;
for (unsigned int i = 0; i < num_ligs; i++)
{
const Ligature &lig = this+ligature[i];
- if (lig.apply (context, is_mark))
+ if (lig.apply (c, is_mark))
return true;
}
}
public:
- inline bool sanitize (hb_sanitize_context_t *context) {
+ inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- return ligature.sanitize (context, this);
+ return ligature.sanitize (c, this);
}
private:
ligature; /* Array LigatureSet tables
* ordered by preference */
public:
- DEFINE_SIZE_VAR (2, OffsetTo<Ligature>);
+ DEFINE_SIZE_ARRAY (2, ligature);
};
struct LigatureSubstFormat1
friend struct LigatureSubst;
private:
- inline bool apply (hb_apply_context_t *context) const
+ inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
- hb_codepoint_t glyph_id = IN_CURGLYPH ();
+ hb_codepoint_t glyph_id = c->buffer->info[c->buffer->i].codepoint;
- bool first_is_mark = !!(context->property & HB_OT_LAYOUT_GLYPH_CLASS_MARK);
+ bool first_is_mark = !!(c->property & HB_OT_LAYOUT_GLYPH_CLASS_MARK);
unsigned int index = (this+coverage) (glyph_id);
if (likely (index == NOT_COVERED))
return false;
const LigatureSet &lig_set = this+ligatureSet[index];
- return lig_set.apply (context, first_is_mark);
+ return lig_set.apply (c, first_is_mark);
}
- inline bool sanitize (hb_sanitize_context_t *context) {
+ inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- return coverage.sanitize (context, this)
- && ligatureSet.sanitize (context, this);
+ return coverage.sanitize (c, this)
+ && ligatureSet.sanitize (c, this);
}
private:
ligatureSet; /* Array LigatureSet tables
* ordered by Coverage Index */
public:
- DEFINE_SIZE_VAR (6, OffsetTo<LigatureSet>);
+ DEFINE_SIZE_ARRAY (6, ligatureSet);
};
struct LigatureSubst
friend struct SubstLookupSubTable;
private:
- inline bool apply (hb_apply_context_t *context) const
+ inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
switch (u.format) {
- case 1: return u.format1->apply (context);
+ case 1: return u.format1.apply (c);
default:return false;
}
}
- inline bool sanitize (hb_sanitize_context_t *context) {
+ inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- if (!u.format.sanitize (context)) return false;
+ if (!u.format.sanitize (c)) return false;
switch (u.format) {
- case 1: return u.format1->sanitize (context);
+ case 1: return u.format1.sanitize (c);
default:return true;
}
}
private:
union {
USHORT format; /* Format identifier */
- LigatureSubstFormat1 format1[VAR];
+ LigatureSubstFormat1 format1;
} u;
};
-
-static inline bool substitute_lookup (hb_apply_context_t *context, unsigned int lookup_index);
+HB_BEGIN_DECLS
+static inline bool substitute_lookup (hb_apply_context_t *c, unsigned int lookup_index);
+HB_END_DECLS
struct ContextSubst : Context
{
friend struct SubstLookupSubTable;
private:
- inline bool apply (hb_apply_context_t *context) const
+ inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
- return Context::apply (context, substitute_lookup);
+ return Context::apply (c, substitute_lookup);
}
};
friend struct SubstLookupSubTable;
private:
- inline bool apply (hb_apply_context_t *context) const
+ inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
- return ChainContext::apply (context, substitute_lookup);
+ return ChainContext::apply (c, substitute_lookup);
}
};
return StructAtOffset<SubstLookupSubTable> (this, offset);
}
- inline bool apply (hb_apply_context_t *context) const;
+ inline bool apply (hb_apply_context_t *c) const;
- inline bool sanitize (hb_sanitize_context_t *context);
+ inline bool sanitize (hb_sanitize_context_t *c);
inline bool is_reverse (void) const;
};
friend struct ReverseChainSingleSubst;
private:
- inline bool apply (hb_apply_context_t *context) const
+ inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
- if (unlikely (context->context_length != NO_CONTEXT))
+ if (unlikely (c->context_length != NO_CONTEXT))
return false; /* No chaining to this type */
- unsigned int index = (this+coverage) (IN_CURGLYPH ());
+ unsigned int index = (this+coverage) (c->buffer->info[c->buffer->i].codepoint);
if (likely (index == NOT_COVERED))
return false;
const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
const ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahead);
- if (match_backtrack (context,
- backtrack.len, (USHORT *) backtrack.array(),
+ if (match_backtrack (c,
+ backtrack.len, (USHORT *) backtrack.array,
match_coverage, this) &&
- match_lookahead (context,
- lookahead.len, (USHORT *) lookahead.array(),
+ match_lookahead (c,
+ lookahead.len, (USHORT *) lookahead.array,
match_coverage, this,
1))
{
- IN_CURGLYPH () = substitute[index];
- context->buffer->in_pos--; /* Reverse! */
+ c->buffer->info[c->buffer->i].codepoint = substitute[index];
+ c->buffer->i--; /* Reverse! */
return true;
}
return false;
}
- inline bool sanitize (hb_sanitize_context_t *context) {
+ inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- if (!(coverage.sanitize (context, this)
- && backtrack.sanitize (context, this)))
+ if (!(coverage.sanitize (c, this)
+ && backtrack.sanitize (c, this)))
return false;
OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
- if (!lookahead.sanitize (context, this))
+ if (!lookahead.sanitize (c, this))
return false;
ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahead);
- return substitute.sanitize (context);
+ return substitute.sanitize (c);
}
private:
friend struct SubstLookupSubTable;
private:
- inline bool apply (hb_apply_context_t *context) const
+ inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
switch (u.format) {
- case 1: return u.format1->apply (context);
+ case 1: return u.format1.apply (c);
default:return false;
}
}
- inline bool sanitize (hb_sanitize_context_t *context) {
+ inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- if (!u.format.sanitize (context)) return false;
+ if (!u.format.sanitize (c)) return false;
switch (u.format) {
- case 1: return u.format1->sanitize (context);
+ case 1: return u.format1.sanitize (c);
default:return true;
}
}
private:
union {
USHORT format; /* Format identifier */
- ReverseChainSingleSubstFormat1 format1[VAR];
+ ReverseChainSingleSubstFormat1 format1;
} u;
};
ReverseChainSingle = 8
};
- inline bool apply (hb_apply_context_t *context, unsigned int lookup_type) const
+ inline bool apply (hb_apply_context_t *c, unsigned int lookup_type) const
{
TRACE_APPLY ();
switch (lookup_type) {
- case Single: return u.single->apply (context);
- case Multiple: return u.multiple->apply (context);
- case Alternate: return u.alternate->apply (context);
- case Ligature: return u.ligature->apply (context);
- case Context: return u.context->apply (context);
- case ChainContext: return u.chainContext->apply (context);
- case Extension: return u.extension->apply (context);
- case ReverseChainSingle: return u.reverseChainContextSingle->apply (context);
+ case Single: return u.single.apply (c);
+ case Multiple: return u.multiple.apply (c);
+ case Alternate: return u.alternate.apply (c);
+ case Ligature: return u.ligature.apply (c);
+ case Context: return u.c.apply (c);
+ case ChainContext: return u.chainContext.apply (c);
+ case Extension: return u.extension.apply (c);
+ case ReverseChainSingle: return u.reverseChainContextSingle.apply (c);
default:return false;
}
}
- inline bool sanitize (hb_sanitize_context_t *context) {
+ inline bool sanitize (hb_sanitize_context_t *c, unsigned int lookup_type) {
TRACE_SANITIZE ();
- if (!u.format.sanitize (context)) return false;
- switch (u.format) {
- case Single: return u.single->sanitize (context);
- case Multiple: return u.multiple->sanitize (context);
- case Alternate: return u.alternate->sanitize (context);
- case Ligature: return u.ligature->sanitize (context);
- case Context: return u.context->sanitize (context);
- case ChainContext: return u.chainContext->sanitize (context);
- case Extension: return u.extension->sanitize (context);
- case ReverseChainSingle: return u.reverseChainContextSingle->sanitize (context);
+ switch (lookup_type) {
+ case Single: return u.single.sanitize (c);
+ case Multiple: return u.multiple.sanitize (c);
+ case Alternate: return u.alternate.sanitize (c);
+ case Ligature: return u.ligature.sanitize (c);
+ case Context: return u.c.sanitize (c);
+ case ChainContext: return u.chainContext.sanitize (c);
+ case Extension: return u.extension.sanitize (c);
+ case ReverseChainSingle: return u.reverseChainContextSingle.sanitize (c);
default:return true;
}
}
private:
union {
- USHORT format;
- SingleSubst single[VAR];
- MultipleSubst multiple[VAR];
- AlternateSubst alternate[VAR];
- LigatureSubst ligature[VAR];
- ContextSubst context[VAR];
- ChainContextSubst chainContext[VAR];
- ExtensionSubst extension[VAR];
- ReverseChainSingleSubst reverseChainContextSingle[VAR];
+ USHORT sub_format;
+ SingleSubst single;
+ MultipleSubst multiple;
+ AlternateSubst alternate;
+ LigatureSubst ligature;
+ ContextSubst c;
+ ChainContextSubst chainContext;
+ ExtensionSubst extension;
+ ReverseChainSingleSubst reverseChainContextSingle;
} u;
public:
- DEFINE_SIZE_MIN (2);
+ DEFINE_SIZE_UNION (2, sub_format);
};
inline bool apply_once (hb_ot_layout_context_t *layout,
hb_buffer_t *buffer,
+ hb_mask_t lookup_mask,
unsigned int context_length,
unsigned int nesting_level_left) const
{
unsigned int lookup_type = get_type ();
- hb_apply_context_t context[1] = {{0}};
+ hb_apply_context_t c[1] = {{0}};
- context->layout = layout;
- context->buffer = buffer;
- context->context_length = context_length;
- context->nesting_level_left = nesting_level_left;
- context->lookup_flag = get_flag ();
+ c->layout = layout;
+ c->buffer = buffer;
+ c->lookup_mask = lookup_mask;
+ c->context_length = context_length;
+ c->nesting_level_left = nesting_level_left;
+ c->lookup_flag = get_flag ();
- if (!_hb_ot_layout_check_glyph_property (context->layout->face, IN_CURINFO (), context->lookup_flag, &context->property))
+ if (!_hb_ot_layout_check_glyph_property (c->layout->face, &c->buffer->info[c->buffer->i], c->lookup_flag, &c->property))
return false;
if (unlikely (lookup_type == SubstLookupSubTable::Extension))
* This is rather slow to do this here for every glyph,
* but it's easiest, and who uses extension lookups anyway?!*/
unsigned int count = get_subtable_count ();
- unsigned int type = get_subtable(0).u.extension->get_type ();
+ unsigned int type = get_subtable(0).u.extension.get_type ();
for (unsigned int i = 1; i < count; i++)
- if (get_subtable(i).u.extension->get_type () != type)
+ if (get_subtable(i).u.extension.get_type () != type)
return false;
}
unsigned int count = get_subtable_count ();
for (unsigned int i = 0; i < count; i++)
- if (get_subtable (i).apply (context, lookup_type))
+ if (get_subtable (i).apply (c, lookup_type))
return true;
return false;
hb_buffer_t *buffer,
hb_mask_t mask) const
{
-#undef BUFFER
-#define BUFFER buffer
bool ret = false;
- if (unlikely (!buffer->in_length))
+ if (unlikely (!buffer->len))
return false;
if (likely (!is_reverse ()))
{
/* in/out forward substitution */
- _hb_buffer_clear_output (buffer);
- buffer->in_pos = 0;
- while (buffer->in_pos < buffer->in_length)
+ buffer->clear_output ();
+ buffer->i = 0;
+ while (buffer->i < buffer->len)
{
- if ((~IN_MASK (buffer->in_pos) & mask) &&
- apply_once (layout, buffer, NO_CONTEXT, MAX_NESTING_LEVEL))
+ if ((buffer->info[buffer->i].mask & mask) &&
+ apply_once (layout, buffer, mask, NO_CONTEXT, MAX_NESTING_LEVEL))
ret = true;
else
- _hb_buffer_next_glyph (buffer);
+ buffer->next_glyph ();
}
if (ret)
- _hb_buffer_swap (buffer);
+ buffer->swap ();
}
else
{
/* in-place backward substitution */
- buffer->in_pos = buffer->in_length - 1;
+ buffer->i = buffer->len - 1;
do
{
- if ((~IN_MASK (buffer->in_pos) & mask) &&
- apply_once (layout, buffer, NO_CONTEXT, MAX_NESTING_LEVEL))
+ if ((buffer->info[buffer->i].mask & mask) &&
+ apply_once (layout, buffer, mask, NO_CONTEXT, MAX_NESTING_LEVEL))
ret = true;
else
- buffer->in_pos--;
+ buffer->i--;
}
- while ((int) buffer->in_pos >= 0);
+ while ((int) buffer->i >= 0);
}
return ret;
}
- inline bool sanitize (hb_sanitize_context_t *context) {
+ inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- if (unlikely (!Lookup::sanitize (context))) return false;
+ if (unlikely (!Lookup::sanitize (c))) return false;
OffsetArrayOf<SubstLookupSubTable> &list = CastR<OffsetArrayOf<SubstLookupSubTable> > (subTable);
- return list.sanitize (context, this);
+ return list.sanitize (c, this, get_type ());
}
};
hb_mask_t mask) const
{ return get_lookup (lookup_index).apply_string (layout, buffer, mask); }
- inline bool sanitize (hb_sanitize_context_t *context) {
+ inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- if (unlikely (!GSUBGPOS::sanitize (context))) return false;
+ if (unlikely (!GSUBGPOS::sanitize (c))) return false;
OffsetTo<SubstLookupList> &list = CastR<OffsetTo<SubstLookupList> > (lookupList);
- return list.sanitize (context, this);
+ return list.sanitize (c, this);
}
public:
DEFINE_SIZE_STATIC (10);
/* Out-of-class implementation for methods recursing */
-inline bool ExtensionSubst::apply (hb_apply_context_t *context) const
+inline bool ExtensionSubst::apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
- return get_subtable ().apply (context, get_type ());
+ return get_subtable ().apply (c, get_type ());
}
-inline bool ExtensionSubst::sanitize (hb_sanitize_context_t *context)
+inline bool ExtensionSubst::sanitize (hb_sanitize_context_t *c)
{
TRACE_SANITIZE ();
- if (unlikely (!Extension::sanitize (context))) return false;
+ if (unlikely (!Extension::sanitize (c))) return false;
unsigned int offset = get_offset ();
if (unlikely (!offset)) return true;
- return StructAtOffset<SubstLookupSubTable> (this, offset).sanitize (context);
+ return StructAtOffset<SubstLookupSubTable> (this, offset).sanitize (c, get_type ());
}
inline bool ExtensionSubst::is_reverse (void) const
return SubstLookup::lookup_type_is_reverse (type);
}
-static inline bool substitute_lookup (hb_apply_context_t *context, unsigned int lookup_index)
+static inline bool substitute_lookup (hb_apply_context_t *c, unsigned int lookup_index)
{
- const GSUB &gsub = *(context->layout->face->ot_layout.gsub);
+ const GSUB &gsub = *(c->layout->face->ot_layout->gsub);
const SubstLookup &l = gsub.get_lookup (lookup_index);
- if (unlikely (context->nesting_level_left == 0))
+ if (unlikely (c->nesting_level_left == 0))
return false;
- if (unlikely (context->context_length < 1))
+ if (unlikely (c->context_length < 1))
return false;
- return l.apply_once (context->layout, context->buffer, context->context_length, context->nesting_level_left - 1);
+ return l.apply_once (c->layout, c->buffer, c->lookup_mask, c->context_length, c->nesting_level_left - 1);
}
+HB_END_DECLS
+
#endif /* HB_OT_LAYOUT_GSUB_PRIVATE_HH */