Revert "collect_unicodes() to check gid < num_glyphs with cmap 12"

Didn't fix the case actually, making bots to fail.

This reverts commit 15b43a4104.
This commit is contained in:
Ebrahim Byagowi 2020-02-28 21:24:27 +03:30
parent 61208401f4
commit e90213868b
3 changed files with 13 additions and 19 deletions

View File

@ -546,7 +546,7 @@ void
hb_face_collect_unicodes (hb_face_t *face, hb_face_collect_unicodes (hb_face_t *face,
hb_set_t *out) hb_set_t *out)
{ {
face->table.cmap->collect_unicodes (out, face->get_num_glyphs ()); face->table.cmap->collect_unicodes (out);
} }
/** /**
* hb_face_collect_variation_selectors: * hb_face_collect_variation_selectors:

View File

@ -539,7 +539,7 @@ struct CmapSubtableLongSegmented
return true; return true;
} }
void collect_unicodes (hb_set_t *out, unsigned int num_glyphs) const void collect_unicodes (hb_set_t *out) const
{ {
for (unsigned int i = 0; i < this->groups.len; i++) for (unsigned int i = 0; i < this->groups.len; i++)
{ {
@ -548,7 +548,7 @@ struct CmapSubtableLongSegmented
(hb_codepoint_t) HB_UNICODE_MAX); (hb_codepoint_t) HB_UNICODE_MAX);
for (hb_codepoint_t codepoint = start; codepoint <= end; codepoint++) for (hb_codepoint_t codepoint = start; codepoint <= end; codepoint++)
{ {
hb_codepoint_t gid = T::group_get_glyph (this->groups[i], codepoint, num_glyphs); hb_codepoint_t gid = T::group_get_glyph (this->groups[i], codepoint);
if (unlikely (!gid)) if (unlikely (!gid))
continue; continue;
out->add (codepoint); out->add (codepoint);
@ -576,15 +576,9 @@ struct CmapSubtableLongSegmented
struct CmapSubtableFormat12 : CmapSubtableLongSegmented<CmapSubtableFormat12> struct CmapSubtableFormat12 : CmapSubtableLongSegmented<CmapSubtableFormat12>
{ {
static hb_codepoint_t group_get_glyph (const CmapSubtableLongGroup &group, static hb_codepoint_t group_get_glyph (const CmapSubtableLongGroup &group,
hb_codepoint_t u, unsigned int num_glyphs = UINT_MAX) hb_codepoint_t u)
{ { return likely (group.startCharCode <= group.endCharCode) ?
hb_codepoint_t g = group.glyphID; group.glyphID + (u - group.startCharCode) : 0; }
hb_codepoint_t s = group.startCharCode;
return likely (s <= group.endCharCode &&
g < num_glyphs &&
g + (u - s) < num_glyphs) ?
g + (u - s) : 0;
}
template<typename Iterator, template<typename Iterator,
@ -658,8 +652,8 @@ struct CmapSubtableFormat12 : CmapSubtableLongSegmented<CmapSubtableFormat12>
struct CmapSubtableFormat13 : CmapSubtableLongSegmented<CmapSubtableFormat13> struct CmapSubtableFormat13 : CmapSubtableLongSegmented<CmapSubtableFormat13>
{ {
static hb_codepoint_t group_get_glyph (const CmapSubtableLongGroup &group, static hb_codepoint_t group_get_glyph (const CmapSubtableLongGroup &group,
hb_codepoint_t u HB_UNUSED, unsigned int num_glyphs = UINT_MAX) hb_codepoint_t u HB_UNUSED)
{ return likely (group.glyphID < num_glyphs) ? group.glyphID : 0; } { return group.glyphID; }
}; };
typedef enum typedef enum
@ -1083,15 +1077,15 @@ struct CmapSubtable
default: return false; default: return false;
} }
} }
void collect_unicodes (hb_set_t *out, unsigned int num_glyphs = UINT_MAX) const void collect_unicodes (hb_set_t *out) const
{ {
switch (u.format) { switch (u.format) {
case 0: u.format0 .collect_unicodes (out); return; case 0: u.format0 .collect_unicodes (out); return;
case 4: u.format4 .collect_unicodes (out); return; case 4: u.format4 .collect_unicodes (out); return;
case 6: u.format6 .collect_unicodes (out); return; case 6: u.format6 .collect_unicodes (out); return;
case 10: u.format10.collect_unicodes (out); return; case 10: u.format10.collect_unicodes (out); return;
case 12: u.format12.collect_unicodes (out, num_glyphs); return; case 12: u.format12.collect_unicodes (out); return;
case 13: u.format13.collect_unicodes (out, num_glyphs); return; case 13: u.format13.collect_unicodes (out); return;
case 14: case 14:
default: return; default: return;
} }
@ -1423,8 +1417,8 @@ struct cmap
return get_nominal_glyph (unicode, glyph); return get_nominal_glyph (unicode, glyph);
} }
void collect_unicodes (hb_set_t *out, unsigned int num_glyphs) const void collect_unicodes (hb_set_t *out) const
{ subtable->collect_unicodes (out, num_glyphs); } { subtable->collect_unicodes (out); }
void collect_variation_selectors (hb_set_t *out) const void collect_variation_selectors (hb_set_t *out) const
{ subtable_uvs->collect_variation_selectors (out); } { subtable_uvs->collect_variation_selectors (out); }
void collect_variation_unicodes (hb_codepoint_t variation_selector, void collect_variation_unicodes (hb_codepoint_t variation_selector,