Fix Coverage iters

This commit is contained in:
Behdad Esfahbod 2012-04-23 14:21:33 -04:00
parent 3e32cd9570
commit 0da132bde4
1 changed files with 21 additions and 9 deletions

View File

@ -357,7 +357,8 @@ struct CoverageFormat1
struct Iter { struct Iter {
void init (const struct CoverageFormat1 &c_) { c = &c_; i = 0; }; void init (const struct CoverageFormat1 &c_) { c = &c_; i = 0; };
bool more (void) { return i < c->glyphArray.len; } bool more (void) { return i < c->glyphArray.len; }
uint16_t next (void) { return c->glyphArray[i++]; } void next (void) { i++; }
uint16_t get (void) { return c->glyphArray[i]; }
private: private:
const struct CoverageFormat1 *c; const struct CoverageFormat1 *c;
@ -394,14 +395,18 @@ struct CoverageFormat2
struct Iter { struct Iter {
void init (const CoverageFormat2 &c_) { c = &c_; i = 0; j = c->rangeRecord.len ? c_.rangeRecord[0].start : 0; } void init (const CoverageFormat2 &c_) { c = &c_; i = 0; j = c->rangeRecord.len ? c_.rangeRecord[0].start : 0; }
bool more (void) { return i < c->rangeRecord.len || bool more (void) { return i < c->rangeRecord.len; }
(i == c->rangeRecord.len && j < c->rangeRecord[i].end); } void next (void) {
uint16_t next (void) {
if (j == c->rangeRecord[i].end) { if (j == c->rangeRecord[i].end) {
i++; i++;
j = c->rangeRecord[i].start; if (more ())
j = c->rangeRecord[i].start;
return;
} }
return j++; j++;
}
uint16_t get (void) {
return j;
} }
private: private:
@ -458,10 +463,17 @@ struct Coverage
default:return true; default:return true;
} }
} }
uint16_t next (void) { void next (void) {
switch (format) { switch (format) {
case 1: return u.format1.next (); case 1: u.format1.next (); break;
case 2: return u.format2.next (); case 2: u.format2.next (); break;
default: break;
}
}
uint16_t get (void) {
switch (format) {
case 1: return u.format1.get ();
case 2: return u.format2.get ();
default:return true; default:return true;
} }
} }