提交 67bb9e8c 编写于 作者: B Behdad Esfahbod

Add set add_coverage() to Coverage()

上级 4952f0aa
...@@ -134,6 +134,10 @@ struct RangeRecord ...@@ -134,6 +134,10 @@ struct RangeRecord
return glyphs->intersects (start, end); 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 start; /* First GlyphID in the range */
GlyphID end; /* Last GlyphID in the range */ GlyphID end; /* Last GlyphID in the range */
USHORT value; /* Value */ USHORT value; /* Value */
...@@ -357,6 +361,12 @@ struct CoverageFormat1 ...@@ -357,6 +361,12 @@ struct CoverageFormat1
return glyphs->has (glyphArray[index]); 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 { struct Iter {
inline void init (const struct CoverageFormat1 &c_) { c = &c_; i = 0; }; inline void init (const struct CoverageFormat1 &c_) { c = &c_; i = 0; };
inline bool more (void) { return i < c->glyphArray.len; } inline bool more (void) { return i < c->glyphArray.len; }
...@@ -412,6 +422,12 @@ struct CoverageFormat2 ...@@ -412,6 +422,12 @@ struct CoverageFormat2
return false; 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 { struct Iter {
inline void init (const CoverageFormat2 &c_) { inline void init (const CoverageFormat2 &c_) {
c = &c_; c = &c_;
...@@ -489,6 +505,14 @@ struct Coverage ...@@ -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 { struct Iter {
Iter (void) : format (0) {}; Iter (void) : format (0) {};
inline void init (const Coverage &c_) { inline void init (const Coverage &c_) {
......
...@@ -60,6 +60,11 @@ struct _hb_set_t ...@@ -60,6 +60,11 @@ struct _hb_set_t
if (unlikely (g > MAX_G)) return; if (unlikely (g > MAX_G)) return;
elt (g) |= mask (g); 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) inline void del (hb_codepoint_t g)
{ {
if (unlikely (g > MAX_G)) return; if (unlikely (g > MAX_G)) return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册