[iter] Port Coverage iterator to hb_iter_t
This commit is contained in:
parent
c68bca0f95
commit
e16884248f
|
@ -1104,7 +1104,9 @@ struct Coverage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Iter
|
struct Iter :
|
||||||
|
hb_iter_t<Iter, const hb_pair_t<unsigned, hb_codepoint_t> >,
|
||||||
|
hb_iter_mixin_t<Iter, const hb_pair_t<unsigned, hb_codepoint_t> >
|
||||||
{
|
{
|
||||||
Iter (const Coverage &c_)
|
Iter (const Coverage &c_)
|
||||||
{
|
{
|
||||||
|
@ -1117,7 +1119,7 @@ struct Coverage
|
||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool more () const
|
bool __more__ () const
|
||||||
{
|
{
|
||||||
switch (format)
|
switch (format)
|
||||||
{
|
{
|
||||||
|
@ -1126,7 +1128,7 @@ struct Coverage
|
||||||
default:return false;
|
default:return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void next ()
|
void __next__ ()
|
||||||
{
|
{
|
||||||
switch (format)
|
switch (format)
|
||||||
{
|
{
|
||||||
|
@ -1135,6 +1137,9 @@ struct Coverage
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
typedef hb_pair_t<unsigned, hb_codepoint_t> __item_type__;
|
||||||
|
__item_type__ __item__ () const { return hb_pair (get_coverage (), get_glyph ()); }
|
||||||
|
|
||||||
hb_codepoint_t get_glyph () const
|
hb_codepoint_t get_glyph () const
|
||||||
{
|
{
|
||||||
switch (format)
|
switch (format)
|
||||||
|
@ -1161,6 +1166,7 @@ struct Coverage
|
||||||
CoverageFormat1::Iter format1;
|
CoverageFormat1::Iter format1;
|
||||||
} u;
|
} u;
|
||||||
};
|
};
|
||||||
|
Iter iter () const { return Iter (*this); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
union {
|
union {
|
||||||
|
|
|
@ -723,7 +723,7 @@ struct PairPosFormat1
|
||||||
bool intersects (const hb_set_t *glyphs) const
|
bool intersects (const hb_set_t *glyphs) const
|
||||||
{
|
{
|
||||||
unsigned int count = pairSet.len;
|
unsigned int count = pairSet.len;
|
||||||
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
|
for (auto iter = (this+coverage).iter (); iter; iter++)
|
||||||
{
|
{
|
||||||
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 */
|
||||||
|
|
|
@ -46,7 +46,7 @@ struct SingleSubstFormat1
|
||||||
|
|
||||||
void closure (hb_closure_context_t *c) const
|
void closure (hb_closure_context_t *c) const
|
||||||
{
|
{
|
||||||
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
|
for (auto iter = (this+coverage).iter (); iter; iter++)
|
||||||
{
|
{
|
||||||
/* 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 */
|
||||||
|
@ -59,7 +59,7 @@ struct SingleSubstFormat1
|
||||||
void collect_glyphs (hb_collect_glyphs_context_t *c) const
|
void collect_glyphs (hb_collect_glyphs_context_t *c) const
|
||||||
{
|
{
|
||||||
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
|
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
|
||||||
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
|
for (auto iter = (this+coverage).iter (); iter; iter++)
|
||||||
{
|
{
|
||||||
/* 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 */
|
||||||
|
@ -110,7 +110,7 @@ struct SingleSubstFormat1
|
||||||
hb_vector_t<GlyphID> from;
|
hb_vector_t<GlyphID> from;
|
||||||
hb_vector_t<GlyphID> to;
|
hb_vector_t<GlyphID> to;
|
||||||
hb_codepoint_t delta = deltaGlyphID;
|
hb_codepoint_t delta = deltaGlyphID;
|
||||||
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
|
for (auto iter = (this+coverage).iter (); iter; iter++)
|
||||||
{
|
{
|
||||||
if (!glyphset.has (iter.get_glyph ())) continue;
|
if (!glyphset.has (iter.get_glyph ())) continue;
|
||||||
from.push ()->set (glyph_map[iter.get_glyph ()]);
|
from.push ()->set (glyph_map[iter.get_glyph ()]);
|
||||||
|
@ -146,7 +146,7 @@ struct SingleSubstFormat2
|
||||||
void closure (hb_closure_context_t *c) const
|
void closure (hb_closure_context_t *c) const
|
||||||
{
|
{
|
||||||
unsigned int count = substitute.len;
|
unsigned int count = substitute.len;
|
||||||
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
|
for (auto iter = (this+coverage).iter (); iter; iter++)
|
||||||
{
|
{
|
||||||
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 */
|
||||||
|
@ -159,7 +159,7 @@ struct SingleSubstFormat2
|
||||||
{
|
{
|
||||||
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
|
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
|
||||||
unsigned int count = substitute.len;
|
unsigned int count = substitute.len;
|
||||||
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
|
for (auto iter = (this+coverage).iter (); iter; iter++)
|
||||||
{
|
{
|
||||||
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 */
|
||||||
|
@ -206,7 +206,7 @@ struct SingleSubstFormat2
|
||||||
const hb_map_t &glyph_map = *c->plan->glyph_map;
|
const hb_map_t &glyph_map = *c->plan->glyph_map;
|
||||||
hb_vector_t<GlyphID> from;
|
hb_vector_t<GlyphID> from;
|
||||||
hb_vector_t<GlyphID> to;
|
hb_vector_t<GlyphID> to;
|
||||||
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
|
for (auto iter = (this+coverage).iter (); iter; iter++)
|
||||||
{
|
{
|
||||||
if (!glyphset.has (iter.get_glyph ())) continue;
|
if (!glyphset.has (iter.get_glyph ())) continue;
|
||||||
from.push ()->set (glyph_map[iter.get_glyph ()]);
|
from.push ()->set (glyph_map[iter.get_glyph ()]);
|
||||||
|
@ -362,7 +362,7 @@ struct MultipleSubstFormat1
|
||||||
void closure (hb_closure_context_t *c) const
|
void closure (hb_closure_context_t *c) const
|
||||||
{
|
{
|
||||||
unsigned int count = sequence.len;
|
unsigned int count = sequence.len;
|
||||||
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
|
for (auto iter = (this+coverage).iter (); iter; iter++)
|
||||||
{
|
{
|
||||||
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 */
|
||||||
|
@ -542,7 +542,7 @@ struct AlternateSubstFormat1
|
||||||
void closure (hb_closure_context_t *c) const
|
void closure (hb_closure_context_t *c) const
|
||||||
{
|
{
|
||||||
unsigned int count = alternateSet.len;
|
unsigned int count = alternateSet.len;
|
||||||
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
|
for (auto iter = (this+coverage).iter (); iter; iter++)
|
||||||
{
|
{
|
||||||
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 */
|
||||||
|
@ -555,7 +555,7 @@ struct AlternateSubstFormat1
|
||||||
{
|
{
|
||||||
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
|
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
|
||||||
unsigned int count = alternateSet.len;
|
unsigned int count = alternateSet.len;
|
||||||
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
|
for (auto iter = (this+coverage).iter (); iter; iter++)
|
||||||
{
|
{
|
||||||
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 */
|
||||||
|
@ -858,7 +858,7 @@ struct LigatureSubstFormat1
|
||||||
bool intersects (const hb_set_t *glyphs) const
|
bool intersects (const hb_set_t *glyphs) const
|
||||||
{
|
{
|
||||||
unsigned int count = ligatureSet.len;
|
unsigned int count = ligatureSet.len;
|
||||||
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
|
for (auto iter = (this+coverage).iter (); iter; iter++)
|
||||||
{
|
{
|
||||||
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 */
|
||||||
|
@ -872,7 +872,7 @@ struct LigatureSubstFormat1
|
||||||
void closure (hb_closure_context_t *c) const
|
void closure (hb_closure_context_t *c) const
|
||||||
{
|
{
|
||||||
unsigned int count = ligatureSet.len;
|
unsigned int count = ligatureSet.len;
|
||||||
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
|
for (auto iter = (this+coverage).iter (); iter; iter++)
|
||||||
{
|
{
|
||||||
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 */
|
||||||
|
@ -885,7 +885,7 @@ struct LigatureSubstFormat1
|
||||||
{
|
{
|
||||||
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
|
if (unlikely (!(this+coverage).add_coverage (c->input))) return;
|
||||||
unsigned int count = ligatureSet.len;
|
unsigned int count = ligatureSet.len;
|
||||||
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
|
for (auto iter = (this+coverage).iter (); iter; iter++)
|
||||||
{
|
{
|
||||||
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 */
|
||||||
|
@ -1062,7 +1062,7 @@ struct ReverseChainSingleSubstFormat1
|
||||||
|
|
||||||
const ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahead);
|
const ArrayOf<GlyphID> &substitute = StructAfter<ArrayOf<GlyphID> > (lookahead);
|
||||||
count = substitute.len;
|
count = substitute.len;
|
||||||
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
|
for (auto iter = (this+coverage).iter (); iter; iter++)
|
||||||
{
|
{
|
||||||
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 */
|
||||||
|
|
|
@ -1438,7 +1438,7 @@ struct ContextFormat1
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned int count = ruleSet.len;
|
unsigned int count = ruleSet.len;
|
||||||
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
|
for (auto iter = (this+coverage).iter (); iter; iter++)
|
||||||
{
|
{
|
||||||
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 */
|
||||||
|
@ -1457,7 +1457,7 @@ struct ContextFormat1
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned int count = ruleSet.len;
|
unsigned int count = ruleSet.len;
|
||||||
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
|
for (auto iter = (this+coverage).iter (); iter; iter++)
|
||||||
{
|
{
|
||||||
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 */
|
||||||
|
@ -2091,7 +2091,7 @@ struct ChainContextFormat1
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned int count = ruleSet.len;
|
unsigned int count = ruleSet.len;
|
||||||
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
|
for (auto iter = (this+coverage).iter (); iter; iter++)
|
||||||
{
|
{
|
||||||
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 */
|
||||||
|
@ -2110,7 +2110,7 @@ struct ChainContextFormat1
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned int count = ruleSet.len;
|
unsigned int count = ruleSet.len;
|
||||||
for (Coverage::Iter iter (this+coverage); iter.more (); iter.next ())
|
for (auto iter = (this+coverage).iter (); iter; iter++)
|
||||||
{
|
{
|
||||||
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 */
|
||||||
|
|
Loading…
Reference in New Issue