for (iter.init (this+coverage); iter.more (); iter.next ())
{
/* TODO Switch to range-based API to work around malicious fonts.
- * https://github.com/behdad/harfbuzz/issues/363 */
+ * https://github.com/harfbuzz/harfbuzz/issues/363 */
hb_codepoint_t glyph_id = iter.get_glyph ();
if (c->glyphs->has (glyph_id))
c->glyphs->add ((glyph_id + deltaGlyphID) & 0xFFFFu);
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
TRACE_COLLECT_GLYPHS (this);
+ if (unlikely (!(this+coverage).add_coverage (c->input))) return;
Coverage::Iter iter;
for (iter.init (this+coverage); iter.more (); iter.next ())
{
/* TODO Switch to range-based API to work around malicious fonts.
- * https://github.com/behdad/harfbuzz/issues/363 */
+ * https://github.com/harfbuzz/harfbuzz/issues/363 */
hb_codepoint_t glyph_id = iter.get_glyph ();
- c->input->add (glyph_id);
c->output->add ((glyph_id + deltaGlyphID) & 0xFFFFu);
}
}
return_trace (c->len == 1 && (this+coverage).get_coverage (c->glyphs[0]) != NOT_COVERED);
}
- inline bool apply (hb_apply_context_t *c) const
+ inline bool apply (hb_ot_apply_context_t *c) const
{
TRACE_APPLY (this);
hb_codepoint_t glyph_id = c->buffer->cur().codepoint;
}
protected:
- USHORT format; /* Format identifier--format = 1 */
+ HBUINT16 format; /* Format identifier--format = 1 */
OffsetTo<Coverage>
coverage; /* Offset to Coverage table--from
* beginning of Substitution table */
- SHORT deltaGlyphID; /* Add to original GlyphID to get
+ HBINT16 deltaGlyphID; /* Add to original GlyphID to get
* substitute GlyphID */
public:
DEFINE_SIZE_STATIC (6);
for (iter.init (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
- break; /* Work around malicious fonts. https://github.com/behdad/harfbuzz/issues/363 */
+ break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
if (c->glyphs->has (iter.get_glyph ()))
c->glyphs->add (substitute[iter.get_coverage ()]);
}
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
TRACE_COLLECT_GLYPHS (this);
+ if (unlikely (!(this+coverage).add_coverage (c->input))) return;
Coverage::Iter iter;
unsigned int count = substitute.len;
for (iter.init (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
- break; /* Work around malicious fonts. https://github.com/behdad/harfbuzz/issues/363 */
- c->input->add (iter.get_glyph ());
+ break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
c->output->add (substitute[iter.get_coverage ()]);
}
}
return_trace (c->len == 1 && (this+coverage).get_coverage (c->glyphs[0]) != NOT_COVERED);
}
- inline bool apply (hb_apply_context_t *c) const
+ inline bool apply (hb_ot_apply_context_t *c) const
{
TRACE_APPLY (this);
hb_codepoint_t glyph_id = c->buffer->cur().codepoint;
}
protected:
- USHORT format; /* Format identifier--format = 2 */
+ HBUINT16 format; /* Format identifier--format = 2 */
OffsetTo<Coverage>
coverage; /* Offset to Coverage table--from
* beginning of Substitution table */
protected:
union {
- USHORT format; /* Format identifier */
+ HBUINT16 format; /* Format identifier */
SingleSubstFormat1 format1;
SingleSubstFormat2 format2;
} u;
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
TRACE_COLLECT_GLYPHS (this);
- unsigned int count = substitute.len;
- for (unsigned int i = 0; i < count; i++)
- c->output->add (substitute[i]);
+ c->output->add_array (substitute.array, substitute.len);
}
- inline bool apply (hb_apply_context_t *c) const
+ inline bool apply (hb_ot_apply_context_t *c) const
{
TRACE_APPLY (this);
unsigned int count = substitute.len;
return_trace (true);
}
/* Spec disallows this, but Uniscribe allows it.
- * https://github.com/behdad/harfbuzz/issues/253 */
+ * https://github.com/harfbuzz/harfbuzz/issues/253 */
else if (unlikely (count == 0))
{
c->buffer->delete_glyph ();
for (iter.init (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
- break; /* Work around malicious fonts. https://github.com/behdad/harfbuzz/issues/363 */
+ break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
if (c->glyphs->has (iter.get_glyph ()))
(this+sequence[iter.get_coverage ()]).closure (c);
}
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
TRACE_COLLECT_GLYPHS (this);
- (this+coverage).add_coverage (c->input);
+ if (unlikely (!(this+coverage).add_coverage (c->input))) return;
unsigned int count = sequence.len;
for (unsigned int i = 0; i < count; i++)
(this+sequence[i]).collect_glyphs (c);
return_trace (c->len == 1 && (this+coverage).get_coverage (c->glyphs[0]) != NOT_COVERED);
}
- inline bool apply (hb_apply_context_t *c) const
+ inline bool apply (hb_ot_apply_context_t *c) const
{
TRACE_APPLY (this);
if (unlikely (!sequence[i].serialize (c, this).serialize (c,
substitute_glyphs_list,
substitute_len_list[i]))) return_trace (false);
- substitute_len_list.advance (num_glyphs);
+ substitute_len_list += num_glyphs;
if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs, num_glyphs))) return_trace (false);
return_trace (true);
}
}
protected:
- USHORT format; /* Format identifier--format = 1 */
+ HBUINT16 format; /* Format identifier--format = 1 */
OffsetTo<Coverage>
coverage; /* Offset to Coverage table--from
* beginning of Substitution table */
protected:
union {
- USHORT format; /* Format identifier */
+ HBUINT16 format; /* Format identifier */
MultipleSubstFormat1 format1;
} u;
};
for (iter.init (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
- break; /* Work around malicious fonts. https://github.com/behdad/harfbuzz/issues/363 */
+ break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
if (c->glyphs->has (iter.get_glyph ())) {
const AlternateSet &alt_set = this+alternateSet[iter.get_coverage ()];
unsigned int count = alt_set.len;
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
TRACE_COLLECT_GLYPHS (this);
+ if (unlikely (!(this+coverage).add_coverage (c->input))) return;
Coverage::Iter iter;
unsigned int count = alternateSet.len;
for (iter.init (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
- break; /* Work around malicious fonts. https://github.com/behdad/harfbuzz/issues/363 */
- c->input->add (iter.get_glyph ());
+ break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
const AlternateSet &alt_set = this+alternateSet[iter.get_coverage ()];
- unsigned int count = alt_set.len;
- for (unsigned int i = 0; i < count; i++)
- c->output->add (alt_set[i]);
+ c->output->add_array (alt_set.array, alt_set.len);
}
}
return_trace (c->len == 1 && (this+coverage).get_coverage (c->glyphs[0]) != NOT_COVERED);
}
- inline bool apply (hb_apply_context_t *c) const
+ inline bool apply (hb_ot_apply_context_t *c) const
{
TRACE_APPLY (this);
hb_codepoint_t glyph_id = c->buffer->cur().codepoint;
if (unlikely (!alternateSet[i].serialize (c, this).serialize (c,
alternate_glyphs_list,
alternate_len_list[i]))) return_trace (false);
- alternate_len_list.advance (num_glyphs);
+ alternate_len_list += num_glyphs;
if (unlikely (!coverage.serialize (c, this).serialize (c, glyphs, num_glyphs))) return_trace (false);
return_trace (true);
}
}
protected:
- USHORT format; /* Format identifier--format = 1 */
+ HBUINT16 format; /* Format identifier--format = 1 */
OffsetTo<Coverage>
coverage; /* Offset to Coverage table--from
* beginning of Substitution table */
protected:
union {
- USHORT format; /* Format identifier */
+ HBUINT16 format; /* Format identifier */
AlternateSubstFormat1 format1;
} u;
};
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
TRACE_COLLECT_GLYPHS (this);
- unsigned int count = component.len;
- for (unsigned int i = 1; i < count; i++)
- c->input->add (component[i]);
+ c->input->add_array (component.array, component.len ? component.len - 1 : 0);
c->output->add (ligGlyph);
}
return_trace (true);
}
- inline bool apply (hb_apply_context_t *c) const
+ inline bool apply (hb_ot_apply_context_t *c) const
{
TRACE_APPLY (this);
unsigned int count = component.len;
if (likely (!match_input (c, count,
&component[1],
match_glyph,
- NULL,
+ nullptr,
&match_length,
match_positions,
&is_mark_ligature,
return_trace (false);
}
- inline bool apply (hb_apply_context_t *c) const
+ inline bool apply (hb_ot_apply_context_t *c) const
{
TRACE_APPLY (this);
unsigned int num_ligs = ligature.len;
ligatures[i],
component_list,
component_count_list[i]))) return_trace (false);
- ligatures.advance (num_ligatures);
- component_count_list.advance (num_ligatures);
+ ligatures += num_ligatures;
+ component_count_list += num_ligatures;
return_trace (true);
}
for (iter.init (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
- break; /* Work around malicious fonts. https://github.com/behdad/harfbuzz/issues/363 */
+ break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
if (c->glyphs->has (iter.get_glyph ()))
(this+ligatureSet[iter.get_coverage ()]).closure (c);
}
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
TRACE_COLLECT_GLYPHS (this);
+ if (unlikely (!(this+coverage).add_coverage (c->input))) return;
Coverage::Iter iter;
unsigned int count = ligatureSet.len;
for (iter.init (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
- break; /* Work around malicious fonts. https://github.com/behdad/harfbuzz/issues/363 */
- c->input->add (iter.get_glyph ());
+ break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
(this+ligatureSet[iter.get_coverage ()]).collect_glyphs (c);
}
}
return_trace (lig_set.would_apply (c));
}
- inline bool apply (hb_apply_context_t *c) const
+ inline bool apply (hb_ot_apply_context_t *c) const
{
TRACE_APPLY (this);
hb_codepoint_t glyph_id = c->buffer->cur().codepoint;
component_count_list,
ligature_per_first_glyph_count_list[i],
component_list))) return_trace (false);
- ligature_per_first_glyph_count_list.advance (num_first_glyphs);
+ ligature_per_first_glyph_count_list += num_first_glyphs;
if (unlikely (!coverage.serialize (c, this).serialize (c, first_glyphs, num_first_glyphs))) return_trace (false);
return_trace (true);
}
}
protected:
- USHORT format; /* Format identifier--format = 1 */
+ HBUINT16 format; /* Format identifier--format = 1 */
OffsetTo<Coverage>
coverage; /* Offset to Coverage table--from
* beginning of Substitution table */
protected:
union {
- USHORT format; /* Format identifier */
+ HBUINT16 format; /* Format identifier */
LigatureSubstFormat1 format1;
} u;
};
for (iter.init (this+coverage); iter.more (); iter.next ())
{
if (unlikely (iter.get_coverage () >= count))
- break; /* Work around malicious fonts. https://github.com/behdad/harfbuzz/issues/363 */
+ break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */
if (c->glyphs->has (iter.get_glyph ()))
c->glyphs->add (substitute[iter.get_coverage ()]);
}
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const
{
TRACE_COLLECT_GLYPHS (this);
-
- const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
+ if (unlikely (!(this+coverage).add_coverage (c->input))) return;
unsigned int count;
- (this+coverage).add_coverage (c->input);
-
count = backtrack.len;
for (unsigned int i = 0; i < count; i++)
- (this+backtrack[i]).add_coverage (c->before);
+ if (unlikely (!(this+backtrack[i]).add_coverage (c->before))) return;
+ const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
count = lookahead.len;
for (unsigned int i = 0; i < count; i++)
- (this+lookahead[i]).add_coverage (c->after);
+ if (unlikely (!(this+lookahead[i]).add_coverage (c->after))) return;
const ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahead);
count = substitute.len;
- for (unsigned int i = 0; i < count; i++)
- c->output->add (substitute[i]);
+ c->output->add_array (substitute.array, substitute.len);
}
inline const Coverage &get_coverage (void) const
return_trace (c->len == 1 && (this+coverage).get_coverage (c->glyphs[0]) != NOT_COVERED);
}
- inline bool apply (hb_apply_context_t *c) const
+ inline bool apply (hb_ot_apply_context_t *c) const
{
TRACE_APPLY (this);
if (unlikely (c->nesting_level_left != HB_MAX_NESTING_LEVEL))
const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (backtrack);
const ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahead);
+ unsigned int start_index = 0, end_index = 0;
if (match_backtrack (c,
- backtrack.len, (USHORT *) backtrack.array,
- match_coverage, this) &&
+ backtrack.len, (HBUINT16 *) backtrack.array,
+ match_coverage, this,
+ &start_index) &&
match_lookahead (c,
- lookahead.len, (USHORT *) lookahead.array,
+ lookahead.len, (HBUINT16 *) lookahead.array,
match_coverage, this,
- 1))
+ 1, &end_index))
{
+ c->buffer->unsafe_to_break_from_outbuffer (start_index, end_index);
c->replace_glyph_inplace (substitute[index]);
/* Note: We DON'T decrease buffer->idx. The main loop does it
* for us. This is useful for preventing surprises if someone
}
protected:
- USHORT format; /* Format identifier--format = 1 */
+ HBUINT16 format; /* Format identifier--format = 1 */
OffsetTo<Coverage>
coverage; /* Offset to Coverage table--from
* beginning of table */
protected:
union {
- USHORT format; /* Format identifier */
+ HBUINT16 format; /* Format identifier */
ReverseChainSingleSubstFormat1 format1;
} u;
};
protected:
union {
- USHORT sub_format;
+ HBUINT16 sub_format;
SingleSubst single;
MultipleSubst multiple;
AlternateSubst alternate;
return lookup_type_is_reverse (type);
}
- inline bool apply (hb_apply_context_t *c) const
+ inline bool apply (hb_ot_apply_context_t *c) const
{
TRACE_APPLY (this);
return_trace (dispatch (c));
return_trace (dispatch (c));
}
- static bool apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_index);
+ static bool apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index);
inline SubstLookupSubTable& serialize_subtable (hb_serialize_context_t *c,
unsigned int i)
if (unlikely (get_type () == SubstLookupSubTable::Extension))
{
/* The spec says all subtables of an Extension lookup should
- * have the same type. This is specially important if one has
- * a reverse type! */
+ * have the same type, which shall not be the Extension type
+ * itself (but we already checked for that).
+ * This is specially important if one has a reverse type! */
unsigned int type = get_subtable (0).u.extension.get_type ();
unsigned int count = get_subtable_count ();
for (unsigned int i = 1; i < count; i++)
return l.dispatch (c);
}
-/*static*/ inline bool SubstLookup::apply_recurse_func (hb_apply_context_t *c, unsigned int lookup_index)
+/*static*/ inline bool SubstLookup::apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index)
{
const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub);
const SubstLookup &l = gsub.get_lookup (lookup_index);