[open-type] Add VarIdx::add()

This commit is contained in:
Behdad Esfahbod 2022-12-16 11:29:51 -07:00
parent bf2ae3f0ca
commit 251f9f6213
2 changed files with 10 additions and 5 deletions

View File

@ -213,6 +213,11 @@ typedef Index NameID;
struct VarIdx : HBUINT32 {
static constexpr unsigned NO_VARIATION = 0xFFFFFFFFu;
static_assert (NO_VARIATION == HB_OT_LAYOUT_NO_VARIATIONS_INDEX, "");
static uint32_t add (uint32_t i, unsigned short v)
{
if (i == NO_VARIATION) return i;
return i + v;
}
VarIdx& operator = (uint32_t i) { HBUINT32::operator= (i); return *this; }
};
DECLARE_NULL_NAMESPACE_BYTES (OT, VarIdx);

View File

@ -940,13 +940,13 @@ struct ClipBox
int ymin = u.format1.yMin;
int xmax = u.format1.xMax;
int ymax = u.format1.yMax;
if (u.format == 2 && instancer && u.format2.varIdxBase != VarIdx::NO_VARIATION)
if (u.format == 2 && instancer)
{
uint32_t varIdx = u.format2.varIdxBase;
xmin += _hb_roundf (instancer (varIdx+0));
ymin += _hb_roundf (instancer (varIdx+1));
xmax += _hb_roundf (instancer (varIdx+2));
ymax += _hb_roundf (instancer (varIdx+3));
xmin += _hb_roundf (instancer (VarIdx::add (varIdx, 0)));
ymin += _hb_roundf (instancer (VarIdx::add (varIdx, 1)));
xmax += _hb_roundf (instancer (VarIdx::add (varIdx, 2)));
ymax += _hb_roundf (instancer (VarIdx::add (varIdx, 3)));
}
extents->x_bearing = xmin;
extents->y_bearing = ymax;