[COLR] Use bsearch in get_extents

This commit is contained in:
Behdad Esfahbod 2022-12-11 13:21:01 -07:00
parent d0ee5a452f
commit 68964efa55
2 changed files with 10 additions and 3 deletions

View File

@ -953,6 +953,9 @@ struct ClipBox
struct ClipRecord
{
int cmp (hb_codepoint_t g) const
{ return g < startGlyphID ? -1 : g <= endGlyphID ? 0 : +1; }
ClipRecord* copy (hb_serialize_context_t *c, const void *base) const
{
TRACE_SERIALIZE (this);
@ -980,6 +983,7 @@ struct ClipRecord
public:
DEFINE_SIZE_STATIC (7);
};
DECLARE_NULL_NAMESPACE_BYTES (OT, ClipRecord);
struct ClipList
{
@ -1075,10 +1079,11 @@ struct ClipList
bool
get_extents (hb_codepoint_t gid, hb_glyph_extents_t *extents) const
{
for (auto& record : clips)
auto *rec = clips.as_array ().bsearch (gid);
if (rec)
{
if (record.startGlyphID <= gid && gid <= record.endGlyphID)
return record.get_extents (extents, this);
rec->get_extents (extents, this);
return true;
}
return false;
}

View File

@ -33,6 +33,7 @@
#include "hb-aat-layout-feat-table.hh"
#include "hb-ot-layout-common.hh"
#include "hb-ot-cmap-table.hh"
#include "hb-ot-color-colr-table.hh"
#include "hb-ot-glyf-table.hh"
#include "hb-ot-head-table.hh"
#include "hb-ot-maxp-table.hh"
@ -47,6 +48,7 @@ DEFINE_NULL_NAMESPACE_BYTES (OT, Index) = {0xFF,0xFF};
DEFINE_NULL_NAMESPACE_BYTES (OT, VarIdx) = {0xFF,0xFF,0xFF,0xFF};
DEFINE_NULL_NAMESPACE_BYTES (OT, LangSys) = {0x00,0x00, 0xFF,0xFF, 0x00,0x00};
DEFINE_NULL_NAMESPACE_BYTES (OT, RangeRecord) = {0x01};
DEFINE_NULL_NAMESPACE_BYTES (OT, ClipRecord) = {0x01};
DEFINE_NULL_NAMESPACE_BYTES (OT, CmapSubtableLongGroup) = {0x00,0x00,0x00,0x01, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00};
DEFINE_NULL_NAMESPACE_BYTES (AAT, SettingName) = {0xFF,0xFF, 0xFF,0xFF};
DEFINE_NULL_NAMESPACE_BYTES (AAT, Lookup) = {0xFF,0xFF};