|
|
|
@ -54,13 +54,13 @@ struct SingleSubstFormat1 |
|
|
|
|
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/harfbuzz/harfbuzz/issues/363 */
|
|
|
|
|
hb_codepoint_t glyph_id = iter.get_glyph (); |
|
|
|
|
c->input->add (glyph_id); |
|
|
|
|
c->output->add ((glyph_id + deltaGlyphID) & 0xFFFFu); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -139,13 +139,13 @@ struct SingleSubstFormat2 |
|
|
|
|
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/harfbuzz/harfbuzz/issues/363 */ |
|
|
|
|
c->input->add (iter.get_glyph ()); |
|
|
|
|
c->output->add (substitute[iter.get_coverage ()]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -269,9 +269,7 @@ struct Sequence |
|
|
|
|
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 |
|
|
|
@ -348,7 +346,7 @@ struct MultipleSubstFormat1 |
|
|
|
|
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); |
|
|
|
@ -474,17 +472,15 @@ struct AlternateSubstFormat1 |
|
|
|
|
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/harfbuzz/harfbuzz/issues/363 */ |
|
|
|
|
c->input->add (iter.get_glyph ()); |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -615,9 +611,7 @@ struct Ligature |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -801,13 +795,13 @@ struct LigatureSubstFormat1 |
|
|
|
|
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/harfbuzz/harfbuzz/issues/363 */ |
|
|
|
|
c->input->add (iter.get_glyph ()); |
|
|
|
|
(this+ligatureSet[iter.get_coverage ()]).collect_glyphs (c); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -970,25 +964,22 @@ struct ReverseChainSingleSubstFormat1 |
|
|
|
|
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 |
|
|
|
|