[cmap] Fix skipping gid0 in Format4 collect_unicodes()

This commit is contained in:
Behdad Esfahbod 2018-08-25 21:23:43 -07:00
parent acce1fa3ea
commit 28634db07e
1 changed files with 18 additions and 2 deletions

View File

@ -298,8 +298,24 @@ struct CmapSubtableFormat4
count--; /* Skip sentinel segment. */
for (unsigned int i = 0; i < count; i++)
{
/* XXX This does NOT skip over chars mapping to gid0... */
out->add_range (this->startCount[i], this->endCount[i]);
unsigned int rangeOffset = this->idRangeOffset[i];
if (rangeOffset == 0)
out->add_range (this->startCount[i], this->endCount[i]);
else
{
for (hb_codepoint_t codepoint = this->startCount[i];
codepoint <= this->endCount[i];
codepoint++)
{
unsigned int index = rangeOffset / 2 + (codepoint - this->startCount[i]) + i - this->segCount;
if (unlikely (index >= this->glyphIdArrayLength))
break;
hb_codepoint_t gid = this->glyphIdArray[index];
if (unlikely (!gid))
continue;
out->add (codepoint);
}
}
}
}