[ot-font] Clean up cmap with gid=0

Fixes https://github.com/harfbuzz/harfbuzz/issues/1145
This commit is contained in:
Behdad Esfahbod 2018-08-29 16:38:04 -07:00
parent 0c7b633f52
commit 2ccc322cf8
1 changed files with 15 additions and 10 deletions

View File

@ -48,7 +48,7 @@ struct CmapSubtableFormat0
if (!gid) if (!gid)
return false; return false;
*glyph = gid; *glyph = gid;
return *glyph != 0; return true;
} }
inline void collect_unicodes (hb_set_t *out) const inline void collect_unicodes (hb_set_t *out) const
{ {
@ -279,9 +279,11 @@ struct CmapSubtableFormat4
return false; return false;
gid += this->idDelta[i]; gid += this->idDelta[i];
} }
gid &= 0xFFFFu;
*glyph = gid & 0xFFFFu; if (!gid)
return *glyph != 0; return false;
*glyph = gid;
return true;
} }
static inline bool get_glyph_func (const void *obj, hb_codepoint_t codepoint, hb_codepoint_t *glyph) static inline bool get_glyph_func (const void *obj, hb_codepoint_t codepoint, hb_codepoint_t *glyph)
{ {
@ -423,7 +425,7 @@ struct CmapSubtableTrimmed
if (!gid) if (!gid)
return false; return false;
*glyph = gid; *glyph = gid;
return *glyph != 0; return true;
} }
inline void collect_unicodes (hb_set_t *out) const inline void collect_unicodes (hb_set_t *out) const
{ {
@ -465,8 +467,11 @@ struct CmapSubtableLongSegmented
int i = groups.bsearch (codepoint); int i = groups.bsearch (codepoint);
if (i == -1) if (i == -1)
return false; return false;
*glyph = T::group_get_glyph (groups[i], codepoint); hb_codepoint_t gid = T::group_get_glyph (groups[i], codepoint);
return *glyph != 0; if (!gid)
return false;
*glyph = gid;
return true;
} }
inline void collect_unicodes (hb_set_t *out) const inline void collect_unicodes (hb_set_t *out) const
@ -674,7 +679,7 @@ struct VariationSelectorRecord
return GLYPH_VARIANT_USE_DEFAULT; return GLYPH_VARIANT_USE_DEFAULT;
const NonDefaultUVS &nonDefaults = base+nonDefaultUVS; const NonDefaultUVS &nonDefaults = base+nonDefaultUVS;
i = nonDefaults.bsearch (codepoint); i = nonDefaults.bsearch (codepoint);
if (i != -1) if (i != -1 && nonDefaults[i].glyphID)
{ {
*glyph = nonDefaults[i].glyphID; *glyph = nonDefaults[i].glyphID;
return GLYPH_VARIANT_FOUND; return GLYPH_VARIANT_FOUND;
@ -1076,8 +1081,8 @@ struct cmap
hb_codepoint_t *glyph) const hb_codepoint_t *glyph) const
{ {
switch (this->subtable_uvs->get_glyph_variant (unicode, switch (this->subtable_uvs->get_glyph_variant (unicode,
variation_selector, variation_selector,
glyph)) glyph))
{ {
case GLYPH_VARIANT_NOT_FOUND: return false; case GLYPH_VARIANT_NOT_FOUND: return false;
case GLYPH_VARIANT_FOUND: return true; case GLYPH_VARIANT_FOUND: return true;