Add set add_coverage() to Coverage()

This commit is contained in:
Behdad Esfahbod 2012-06-09 02:02:46 -04:00
parent 4952f0aa5b
commit 67bb9e8cea
2 changed files with 29 additions and 0 deletions

View File

@ -134,6 +134,10 @@ struct RangeRecord
return glyphs->intersects (start, end);
}
inline void add_coverage (hb_set_t *glyphs) const {
glyphs->add_range (start, end);
}
GlyphID start; /* First GlyphID in the range */
GlyphID end; /* Last GlyphID in the range */
USHORT value; /* Value */
@ -357,6 +361,12 @@ struct CoverageFormat1
return glyphs->has (glyphArray[index]);
}
inline void add_coverage (hb_set_t *glyphs) const {
unsigned int count = glyphArray.len;
for (unsigned int i = 0; i < count; i++)
glyphs->add (glyphArray[i]);
}
struct Iter {
inline void init (const struct CoverageFormat1 &c_) { c = &c_; i = 0; };
inline bool more (void) { return i < c->glyphArray.len; }
@ -412,6 +422,12 @@ struct CoverageFormat2
return false;
}
inline void add_coverage (hb_set_t *glyphs) const {
unsigned int count = rangeRecord.len;
for (unsigned int i = 0; i < count; i++)
rangeRecord[i].add_coverage (glyphs);
}
struct Iter {
inline void init (const CoverageFormat2 &c_) {
c = &c_;
@ -489,6 +505,14 @@ struct Coverage
}
}
inline void add_coverage (hb_set_t *glyphs) const {
switch (u.format) {
case 1: u.format1.add_coverage (glyphs); break;
case 2: u.format2.add_coverage (glyphs); break;
default: break;
}
}
struct Iter {
Iter (void) : format (0) {};
inline void init (const Coverage &c_) {

View File

@ -60,6 +60,11 @@ struct _hb_set_t
if (unlikely (g > MAX_G)) return;
elt (g) |= mask (g);
}
inline void add_range (hb_codepoint_t a, hb_codepoint_t b)
{
for (unsigned int i = a; i < b + 1; i++)
add (i);
}
inline void del (hb_codepoint_t g)
{
if (unlikely (g > MAX_G)) return;