Tolerate unsorted OT table entries for small number of entries

See comment.

Fixes https://github.com/harfbuzz/harfbuzz/issues/3065
This commit is contained in:
Behdad Esfahbod 2021-07-22 11:37:39 -07:00
parent 03cd9c5cba
commit ba6db26b65
1 changed files with 7 additions and 1 deletions

View File

@ -102,7 +102,13 @@ typedef struct OpenTypeOffsetTable
{
Tag t;
t = tag;
return tables.bfind (t, table_index, HB_NOT_FOUND_STORE, Index::NOT_FOUND_INDEX);
/* Use lfind for small fonts; there are fonts that have unsorted table entries;
* those tend to work in other tools, so tolerate them.
* https://github.com/harfbuzz/harfbuzz/issues/3065 */
if (tables.len < 16)
return tables.lfind (t, table_index, HB_NOT_FOUND_STORE, Index::NOT_FOUND_INDEX);
else
return tables.bfind (t, table_index, HB_NOT_FOUND_STORE, Index::NOT_FOUND_INDEX);
}
const TableRecord& get_table_by_tag (hb_tag_t tag) const
{