From 67bb9e8cea49a44be6996515e1c7d8cdc95a77e6 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 9 Jun 2012 02:02:46 -0400 Subject: [PATCH] Add set add_coverage() to Coverage() --- src/hb-ot-layout-common-private.hh | 24 ++++++++++++++++++++++++ src/hb-set-private.hh | 5 +++++ 2 files changed, 29 insertions(+) diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh index a3afb0839..a990b1556 100644 --- a/src/hb-ot-layout-common-private.hh +++ b/src/hb-ot-layout-common-private.hh @@ -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_) { diff --git a/src/hb-set-private.hh b/src/hb-set-private.hh index 5cdf8a0f2..7f478e4fc 100644 --- a/src/hb-set-private.hh +++ b/src/hb-set-private.hh @@ -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;