mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-05 05:25:05 +00:00
[VARC] Store axisIndices and axisValues as HBUINT16
Speed up is worth it. Not in the spec.
This commit is contained in:
parent
2b6a65671b
commit
00d7d90b3c
3 changed files with 19 additions and 10 deletions
|
@ -192,17 +192,22 @@ VarComponent::get_path_at (hb_font_t *font,
|
|||
|
||||
// Axis values
|
||||
|
||||
hb_vector_t<unsigned> axisIndices;
|
||||
hb_array_t<const HBINT16> axisIndices;
|
||||
hb_vector_t<float> axisValues;
|
||||
if (flags & (unsigned) flags_t::HAVE_AXES)
|
||||
{
|
||||
unsigned axisIndicesIndex;
|
||||
READ_UINT32VAR (axisIndicesIndex);
|
||||
axisIndices = (&VARC+VARC.axisIndicesList)[axisIndicesIndex];
|
||||
axisValues.resize (axisIndices.length);
|
||||
const HBUINT8 *p = (const HBUINT8 *) record;
|
||||
TupleValues::decompile (p, axisValues, (const HBUINT8 *) end);
|
||||
record += (const unsigned char *) p - record;
|
||||
if (axisValues.resize (axisIndices.length))
|
||||
{
|
||||
if (unlikely (unsigned (end - record) < axisIndices.length * sizeof (HBINT16)))
|
||||
return hb_ubytes_t ();
|
||||
const HBINT16 *base = (const HBINT16 *) record;
|
||||
for (unsigned i = 0; i < axisIndices.length; i++)
|
||||
axisValues.arrayZ[i] = base[i];
|
||||
}
|
||||
record += axisIndices.length * sizeof (HBINT16);
|
||||
}
|
||||
|
||||
// Apply variations if any
|
||||
|
|
|
@ -178,7 +178,7 @@ struct VARC
|
|||
Offset32To<Coverage> coverage;
|
||||
Offset32To<MultiItemVariationStore> varStore;
|
||||
Offset32To<ConditionList> conditionList;
|
||||
Offset32To<TupleList> axisIndicesList;
|
||||
Offset32To<Int16TupleList> axisIndicesList;
|
||||
Offset32To<CFF2Index/*Of<VarCompositeGlyph>*/> glyphRecords;
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (24);
|
||||
|
|
|
@ -1879,16 +1879,20 @@ struct TupleList : CFF2Index
|
|||
}
|
||||
};
|
||||
|
||||
struct FloatTupleList : CFF2Index
|
||||
template <typename Type>
|
||||
struct TypedTupleList : CFF2Index
|
||||
{
|
||||
hb_array_t<const float> operator [] (unsigned i) const
|
||||
hb_array_t<const Type> operator [] (unsigned i) const
|
||||
{
|
||||
auto bytes = CFF2Index::operator [] (i);
|
||||
return hb_array (&StructAtOffsetUnaligned<float>(bytes.arrayZ, 0),
|
||||
bytes.length / sizeof (float));
|
||||
return hb_array (&StructAtOffsetUnaligned<Type>(bytes.arrayZ, 0),
|
||||
bytes.length / hb_static_size (Type));
|
||||
}
|
||||
};
|
||||
|
||||
using Int16TupleList = TypedTupleList<HBINT16>;
|
||||
using FloatTupleList = TypedTupleList<float>;
|
||||
|
||||
|
||||
} /* namespace OT */
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue