|
|
@ -54,13 +54,13 @@ struct SingleSubstFormat1 |
|
|
|
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const |
|
|
|
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
TRACE_COLLECT_GLYPHS (this); |
|
|
|
TRACE_COLLECT_GLYPHS (this); |
|
|
|
|
|
|
|
if (unlikely (!(this+coverage).add_coverage (c->input))) return; |
|
|
|
Coverage::Iter iter; |
|
|
|
Coverage::Iter iter; |
|
|
|
for (iter.init (this+coverage); iter.more (); iter.next ()) |
|
|
|
for (iter.init (this+coverage); iter.more (); iter.next ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
/* TODO Switch to range-based API to work around malicious fonts.
|
|
|
|
/* TODO Switch to range-based API to work around malicious fonts.
|
|
|
|
* https://github.com/harfbuzz/harfbuzz/issues/363 */
|
|
|
|
* https://github.com/harfbuzz/harfbuzz/issues/363 */
|
|
|
|
hb_codepoint_t glyph_id = iter.get_glyph (); |
|
|
|
hb_codepoint_t glyph_id = iter.get_glyph (); |
|
|
|
c->input->add (glyph_id); |
|
|
|
|
|
|
|
c->output->add ((glyph_id + deltaGlyphID) & 0xFFFFu); |
|
|
|
c->output->add ((glyph_id + deltaGlyphID) & 0xFFFFu); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -139,13 +139,13 @@ struct SingleSubstFormat2 |
|
|
|
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const |
|
|
|
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
TRACE_COLLECT_GLYPHS (this); |
|
|
|
TRACE_COLLECT_GLYPHS (this); |
|
|
|
|
|
|
|
if (unlikely (!(this+coverage).add_coverage (c->input))) return; |
|
|
|
Coverage::Iter iter; |
|
|
|
Coverage::Iter iter; |
|
|
|
unsigned int count = substitute.len; |
|
|
|
unsigned int count = substitute.len; |
|
|
|
for (iter.init (this+coverage); iter.more (); iter.next ()) |
|
|
|
for (iter.init (this+coverage); iter.more (); iter.next ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (unlikely (iter.get_coverage () >= count)) |
|
|
|
if (unlikely (iter.get_coverage () >= count)) |
|
|
|
break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */ |
|
|
|
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 ()]); |
|
|
|
c->output->add (substitute[iter.get_coverage ()]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -269,9 +269,7 @@ struct Sequence |
|
|
|
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const |
|
|
|
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
TRACE_COLLECT_GLYPHS (this); |
|
|
|
TRACE_COLLECT_GLYPHS (this); |
|
|
|
unsigned int count = substitute.len; |
|
|
|
c->output->add_array (substitute.array, substitute.len); |
|
|
|
for (unsigned int i = 0; i < count; i++) |
|
|
|
|
|
|
|
c->output->add (substitute[i]); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
inline bool apply (hb_apply_context_t *c) const |
|
|
|
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 |
|
|
|
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
TRACE_COLLECT_GLYPHS (this); |
|
|
|
TRACE_COLLECT_GLYPHS (this); |
|
|
|
(this+coverage).add_coverage (c->input); |
|
|
|
if (unlikely (!(this+coverage).add_coverage (c->input))) return; |
|
|
|
unsigned int count = sequence.len; |
|
|
|
unsigned int count = sequence.len; |
|
|
|
for (unsigned int i = 0; i < count; i++) |
|
|
|
for (unsigned int i = 0; i < count; i++) |
|
|
|
(this+sequence[i]).collect_glyphs (c); |
|
|
|
(this+sequence[i]).collect_glyphs (c); |
|
|
@ -474,17 +472,15 @@ struct AlternateSubstFormat1 |
|
|
|
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const |
|
|
|
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
TRACE_COLLECT_GLYPHS (this); |
|
|
|
TRACE_COLLECT_GLYPHS (this); |
|
|
|
|
|
|
|
if (unlikely (!(this+coverage).add_coverage (c->input))) return; |
|
|
|
Coverage::Iter iter; |
|
|
|
Coverage::Iter iter; |
|
|
|
unsigned int count = alternateSet.len; |
|
|
|
unsigned int count = alternateSet.len; |
|
|
|
for (iter.init (this+coverage); iter.more (); iter.next ()) |
|
|
|
for (iter.init (this+coverage); iter.more (); iter.next ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (unlikely (iter.get_coverage () >= count)) |
|
|
|
if (unlikely (iter.get_coverage () >= count)) |
|
|
|
break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */ |
|
|
|
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 ()]; |
|
|
|
const AlternateSet &alt_set = this+alternateSet[iter.get_coverage ()]; |
|
|
|
unsigned int count = alt_set.len; |
|
|
|
c->output->add_array (alt_set.array, alt_set.len); |
|
|
|
for (unsigned int i = 0; i < count; i++) |
|
|
|
|
|
|
|
c->output->add (alt_set[i]); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -615,9 +611,7 @@ struct Ligature |
|
|
|
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const |
|
|
|
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
TRACE_COLLECT_GLYPHS (this); |
|
|
|
TRACE_COLLECT_GLYPHS (this); |
|
|
|
unsigned int count = component.len; |
|
|
|
c->input->add_array (component.array, component.len ? component.len - 1 : 0); |
|
|
|
for (unsigned int i = 1; i < count; i++) |
|
|
|
|
|
|
|
c->input->add (component[i]); |
|
|
|
|
|
|
|
c->output->add (ligGlyph); |
|
|
|
c->output->add (ligGlyph); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -801,13 +795,13 @@ struct LigatureSubstFormat1 |
|
|
|
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const |
|
|
|
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
TRACE_COLLECT_GLYPHS (this); |
|
|
|
TRACE_COLLECT_GLYPHS (this); |
|
|
|
|
|
|
|
if (unlikely (!(this+coverage).add_coverage (c->input))) return; |
|
|
|
Coverage::Iter iter; |
|
|
|
Coverage::Iter iter; |
|
|
|
unsigned int count = ligatureSet.len; |
|
|
|
unsigned int count = ligatureSet.len; |
|
|
|
for (iter.init (this+coverage); iter.more (); iter.next ()) |
|
|
|
for (iter.init (this+coverage); iter.more (); iter.next ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (unlikely (iter.get_coverage () >= count)) |
|
|
|
if (unlikely (iter.get_coverage () >= count)) |
|
|
|
break; /* Work around malicious fonts. https://github.com/harfbuzz/harfbuzz/issues/363 */ |
|
|
|
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); |
|
|
|
(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 |
|
|
|
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
TRACE_COLLECT_GLYPHS (this); |
|
|
|
TRACE_COLLECT_GLYPHS (this); |
|
|
|
|
|
|
|
if (unlikely (!(this+coverage).add_coverage (c->input))) return; |
|
|
|
const OffsetArrayOf<Coverage> &lookahead = StructAfter<OffsetArrayOf<Coverage> > (backtrack); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int count; |
|
|
|
unsigned int count; |
|
|
|
|
|
|
|
|
|
|
|
(this+coverage).add_coverage (c->input); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
count = backtrack.len; |
|
|
|
count = backtrack.len; |
|
|
|
for (unsigned int i = 0; i < count; i++) |
|
|
|
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; |
|
|
|
count = lookahead.len; |
|
|
|
for (unsigned int i = 0; i < count; i++) |
|
|
|
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); |
|
|
|
const ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahead); |
|
|
|
count = substitute.len; |
|
|
|
count = substitute.len; |
|
|
|
for (unsigned int i = 0; i < count; i++) |
|
|
|
c->output->add_array (substitute.array, substitute.len); |
|
|
|
c->output->add (substitute[i]); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
inline const Coverage &get_coverage (void) const |
|
|
|
inline const Coverage &get_coverage (void) const |
|
|
|