[subset] limit the max codepoint value to the unicode limit.

When collecting all codepoints in the cmap avoid using large amount of memory for fonts that declare coverage over all 32 bit integers.
This commit is contained in:
Garret Rieger 2018-07-31 17:44:02 -07:00
parent 7278d9df30
commit 2bdd903c69
2 changed files with 7 additions and 2 deletions

View File

@ -37,6 +37,9 @@
*/
#define HB_OT_TAG_cmap HB_TAG('c','m','a','p')
#ifndef HB_MAX_UNICODE_CODEPOINT_VALUE
#define HB_MAX_UNICODE_CODEPOINT_VALUE 0x10FFFF
#endif
namespace OT {
@ -437,8 +440,10 @@ struct CmapSubtableLongSegmented
{
for (unsigned int i = 0; i < this->groups.len; i++) {
hb_set_add_range (out,
this->groups[i].startCharCode,
this->groups[i].endCharCode);
MIN ((unsigned int) this->groups[i].startCharCode,
(unsigned int) HB_MAX_UNICODE_CODEPOINT_VALUE),
MIN ((unsigned int) this->groups[i].endCharCode,
(unsigned int) HB_MAX_UNICODE_CODEPOINT_VALUE));
}
}