Port rest from VAR to UnsizedArrayOf<>
This commit is contained in:
parent
9507b05a7a
commit
dff2c45f1e
|
@ -67,11 +67,11 @@ struct BinSearchArrayOf
|
||||||
inline const Type& operator [] (unsigned int i) const
|
inline const Type& operator [] (unsigned int i) const
|
||||||
{
|
{
|
||||||
if (unlikely (i >= header.nUnits)) return Null(Type);
|
if (unlikely (i >= header.nUnits)) return Null(Type);
|
||||||
return StructAtOffset<Type> (bytesZ, i * header.unitSize);
|
return StructAtOffset<Type> (&bytesZ, i * header.unitSize);
|
||||||
}
|
}
|
||||||
inline Type& operator [] (unsigned int i)
|
inline Type& operator [] (unsigned int i)
|
||||||
{
|
{
|
||||||
return StructAtOffset<Type> (bytesZ, i * header.unitSize);
|
return StructAtOffset<Type> (&bytesZ, i * header.unitSize);
|
||||||
}
|
}
|
||||||
inline unsigned int get_size (void) const
|
inline unsigned int get_size (void) const
|
||||||
{ return header.static_size + header.nUnits * header.unitSize; }
|
{ return header.static_size + header.nUnits * header.unitSize; }
|
||||||
|
@ -88,7 +88,7 @@ struct BinSearchArrayOf
|
||||||
* pointed to do have a simple sanitize(), ie. they do not
|
* pointed to do have a simple sanitize(), ie. they do not
|
||||||
* reference other structs via offsets.
|
* reference other structs via offsets.
|
||||||
*/
|
*/
|
||||||
(void) (false && StructAtOffset<Type> (bytesZ, 0).sanitize (c));
|
(void) (false && StructAtOffset<Type> (&bytesZ, 0).sanitize (c));
|
||||||
|
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ struct BinSearchArrayOf
|
||||||
while (min <= max)
|
while (min <= max)
|
||||||
{
|
{
|
||||||
int mid = (min + max) / 2;
|
int mid = (min + max) / 2;
|
||||||
const Type *p = (const Type *) (((const char *) bytesZ) + (mid * size));
|
const Type *p = (const Type *) (((const char *) &bytesZ) + (mid * size));
|
||||||
int c = p->cmp (key);
|
int c = p->cmp (key);
|
||||||
if (c < 0)
|
if (c < 0)
|
||||||
max = mid - 1;
|
max = mid - 1;
|
||||||
|
@ -129,12 +129,12 @@ struct BinSearchArrayOf
|
||||||
TRACE_SANITIZE (this);
|
TRACE_SANITIZE (this);
|
||||||
return_trace (header.sanitize (c) &&
|
return_trace (header.sanitize (c) &&
|
||||||
Type::static_size >= header.unitSize &&
|
Type::static_size >= header.unitSize &&
|
||||||
c->check_array (bytesZ, header.nUnits, header.unitSize));
|
c->check_array (bytesZ.arrayZ, header.nUnits, header.unitSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BinSearchHeader header;
|
BinSearchHeader header;
|
||||||
HBUINT8 bytesZ[VAR];
|
UnsizedArrayOf<HBUINT8> bytesZ;
|
||||||
public:
|
public:
|
||||||
DEFINE_SIZE_ARRAY (10, bytesZ);
|
DEFINE_SIZE_ARRAY (10, bytesZ);
|
||||||
};
|
};
|
||||||
|
|
|
@ -619,7 +619,7 @@ struct Chain
|
||||||
{
|
{
|
||||||
inline void apply (hb_aat_apply_context_t *c) const
|
inline void apply (hb_aat_apply_context_t *c) const
|
||||||
{
|
{
|
||||||
const ChainSubtable *subtable = &StructAtOffset<ChainSubtable> (featureZ, featureZ[0].static_size * featureCount);
|
const ChainSubtable *subtable = &StructAtOffset<ChainSubtable> (&featureZ, featureZ[0].static_size * featureCount);
|
||||||
unsigned int count = subtableCount;
|
unsigned int count = subtableCount;
|
||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
@ -648,10 +648,10 @@ struct Chain
|
||||||
!c->check_range (this, length))
|
!c->check_range (this, length))
|
||||||
return_trace (false);
|
return_trace (false);
|
||||||
|
|
||||||
if (!c->check_array (featureZ, featureCount))
|
if (!c->check_array (featureZ.arrayZ, featureCount))
|
||||||
return_trace (false);
|
return_trace (false);
|
||||||
|
|
||||||
const ChainSubtable *subtable = &StructAtOffset<ChainSubtable> (featureZ, featureZ[0].static_size * featureCount);
|
const ChainSubtable *subtable = &StructAtOffset<ChainSubtable> (&featureZ, featureZ[0].static_size * featureCount);
|
||||||
unsigned int count = subtableCount;
|
unsigned int count = subtableCount;
|
||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
@ -669,8 +669,8 @@ struct Chain
|
||||||
HBUINT32 featureCount; /* Number of feature subtable entries. */
|
HBUINT32 featureCount; /* Number of feature subtable entries. */
|
||||||
HBUINT32 subtableCount; /* The number of subtables in the chain. */
|
HBUINT32 subtableCount; /* The number of subtables in the chain. */
|
||||||
|
|
||||||
Feature featureZ[VAR]; /* Features. */
|
UnsizedArrayOf<Feature> featureZ; /* Features. */
|
||||||
/*ChainSubtable subtableX[VAR];*//* Subtables. */
|
/*ChainSubtable firstSubtable;*//* Subtables. */
|
||||||
/*subtableGlyphCoverageArray*/ /* Only if major == 3. */
|
/*subtableGlyphCoverageArray*/ /* Only if major == 3. */
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -689,7 +689,7 @@ struct morx
|
||||||
inline void apply (hb_aat_apply_context_t *c) const
|
inline void apply (hb_aat_apply_context_t *c) const
|
||||||
{
|
{
|
||||||
c->set_lookup_index (0);
|
c->set_lookup_index (0);
|
||||||
const Chain *chain = chainsZ;
|
const Chain *chain = &firstChain;
|
||||||
unsigned int count = chainCount;
|
unsigned int count = chainCount;
|
||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
@ -706,7 +706,7 @@ struct morx
|
||||||
!chainCount.sanitize (c))
|
!chainCount.sanitize (c))
|
||||||
return_trace (false);
|
return_trace (false);
|
||||||
|
|
||||||
const Chain *chain = chainsZ;
|
const Chain *chain = &firstChain;
|
||||||
unsigned int count = chainCount;
|
unsigned int count = chainCount;
|
||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
@ -723,7 +723,7 @@ struct morx
|
||||||
* 1 for mort, 2 or 3 for morx. */
|
* 1 for mort, 2 or 3 for morx. */
|
||||||
HBUINT32 chainCount; /* Number of metamorphosis chains contained in this
|
HBUINT32 chainCount; /* Number of metamorphosis chains contained in this
|
||||||
* table. */
|
* table. */
|
||||||
Chain chainsZ[VAR]; /* Chains. */
|
Chain firstChain; /* Chains. */
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DEFINE_SIZE_MIN (8);
|
DEFINE_SIZE_MIN (8);
|
||||||
|
|
|
@ -231,7 +231,7 @@ struct CmapSubtableFormat4
|
||||||
inline void init (const CmapSubtableFormat4 *subtable)
|
inline void init (const CmapSubtableFormat4 *subtable)
|
||||||
{
|
{
|
||||||
segCount = subtable->segCountX2 / 2;
|
segCount = subtable->segCountX2 / 2;
|
||||||
endCount = subtable->values;
|
endCount = subtable->values.arrayZ;
|
||||||
startCount = endCount + segCount + 1;
|
startCount = endCount + segCount + 1;
|
||||||
idDelta = startCount + segCount;
|
idDelta = startCount + segCount;
|
||||||
idRangeOffset = idDelta + segCount;
|
idRangeOffset = idDelta + segCount;
|
||||||
|
@ -369,7 +369,8 @@ struct CmapSubtableFormat4
|
||||||
HBUINT16 entrySelector; /* log2(searchRange/2) */
|
HBUINT16 entrySelector; /* log2(searchRange/2) */
|
||||||
HBUINT16 rangeShift; /* 2 x segCount - searchRange */
|
HBUINT16 rangeShift; /* 2 x segCount - searchRange */
|
||||||
|
|
||||||
HBUINT16 values[VAR];
|
UnsizedArrayOf<HBUINT16>
|
||||||
|
values;
|
||||||
#if 0
|
#if 0
|
||||||
HBUINT16 endCount[segCount]; /* End characterCode for each segment,
|
HBUINT16 endCount[segCount]; /* End characterCode for each segment,
|
||||||
* last=0xFFFFu. */
|
* last=0xFFFFu. */
|
||||||
|
@ -377,7 +378,8 @@ struct CmapSubtableFormat4
|
||||||
HBUINT16 startCount[segCount]; /* Start character code for each segment. */
|
HBUINT16 startCount[segCount]; /* Start character code for each segment. */
|
||||||
HBINT16 idDelta[segCount]; /* Delta for all character codes in segment. */
|
HBINT16 idDelta[segCount]; /* Delta for all character codes in segment. */
|
||||||
HBUINT16 idRangeOffset[segCount];/* Offsets into glyphIdArray or 0 */
|
HBUINT16 idRangeOffset[segCount];/* Offsets into glyphIdArray or 0 */
|
||||||
HBUINT16 glyphIdArray[VAR]; /* Glyph index array (arbitrary length) */
|
UnsizedArrayOf<HBUINT16>
|
||||||
|
glyphIdArray; /* Glyph index array (arbitrary length) */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -128,7 +128,7 @@ struct IndexSubtableFormat1Or3
|
||||||
{
|
{
|
||||||
TRACE_SANITIZE (this);
|
TRACE_SANITIZE (this);
|
||||||
return_trace (c->check_struct (this) &&
|
return_trace (c->check_struct (this) &&
|
||||||
c->check_array (offsetArrayZ, glyph_count + 1));
|
c->check_array (offsetArrayZ.arrayZ, glyph_count + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get_image_data (unsigned int idx,
|
bool get_image_data (unsigned int idx,
|
||||||
|
@ -144,7 +144,8 @@ struct IndexSubtableFormat1Or3
|
||||||
}
|
}
|
||||||
|
|
||||||
IndexSubtableHeader header;
|
IndexSubtableHeader header;
|
||||||
Offset<OffsetType> offsetArrayZ[VAR];
|
UnsizedArrayOf<Offset<OffsetType> >
|
||||||
|
offsetArrayZ;
|
||||||
public:
|
public:
|
||||||
DEFINE_SIZE_ARRAY(8, offsetArrayZ);
|
DEFINE_SIZE_ARRAY(8, offsetArrayZ);
|
||||||
};
|
};
|
||||||
|
@ -240,7 +241,7 @@ struct IndexSubtableArray
|
||||||
inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const
|
inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const
|
||||||
{
|
{
|
||||||
TRACE_SANITIZE (this);
|
TRACE_SANITIZE (this);
|
||||||
if (unlikely (!c->check_array (indexSubtablesZ, count)))
|
if (unlikely (!c->check_array (indexSubtablesZ.arrayZ, count)))
|
||||||
return_trace (false);
|
return_trace (false);
|
||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
if (unlikely (!indexSubtablesZ[i].sanitize (c, this)))
|
if (unlikely (!indexSubtablesZ[i].sanitize (c, this)))
|
||||||
|
@ -255,15 +256,14 @@ struct IndexSubtableArray
|
||||||
{
|
{
|
||||||
unsigned int firstGlyphIndex = indexSubtablesZ[i].firstGlyphIndex;
|
unsigned int firstGlyphIndex = indexSubtablesZ[i].firstGlyphIndex;
|
||||||
unsigned int lastGlyphIndex = indexSubtablesZ[i].lastGlyphIndex;
|
unsigned int lastGlyphIndex = indexSubtablesZ[i].lastGlyphIndex;
|
||||||
if (firstGlyphIndex <= glyph && glyph <= lastGlyphIndex) {
|
if (firstGlyphIndex <= glyph && glyph <= lastGlyphIndex)
|
||||||
return &indexSubtablesZ[i];
|
return &indexSubtablesZ[i];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IndexSubtableRecord indexSubtablesZ[VAR];
|
UnsizedArrayOf<IndexSubtableRecord> indexSubtablesZ;
|
||||||
public:
|
public:
|
||||||
DEFINE_SIZE_ARRAY(0, indexSubtablesZ);
|
DEFINE_SIZE_ARRAY(0, indexSubtablesZ);
|
||||||
};
|
};
|
||||||
|
@ -528,7 +528,7 @@ struct CBDT
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
FixedVersion<> version;
|
FixedVersion<> version;
|
||||||
HBUINT8 dataZ[VAR];
|
UnsizedArrayOf<HBUINT8> dataZ;
|
||||||
public:
|
public:
|
||||||
DEFINE_SIZE_ARRAY(4, dataZ);
|
DEFINE_SIZE_ARRAY(4, dataZ);
|
||||||
};
|
};
|
||||||
|
|
|
@ -54,7 +54,7 @@ struct loca
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HBUINT8 dataZ[VAR]; /* Location data. */
|
UnsizedArrayOf<HBUINT8> dataZ; /* Location data. */
|
||||||
DEFINE_SIZE_ARRAY (0, dataZ);
|
DEFINE_SIZE_ARRAY (0, dataZ);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -375,13 +375,13 @@ struct glyf
|
||||||
|
|
||||||
if (short_offset)
|
if (short_offset)
|
||||||
{
|
{
|
||||||
const HBUINT16 *offsets = (const HBUINT16 *) loca_table->dataZ;
|
const HBUINT16 *offsets = (const HBUINT16 *) loca_table->dataZ.arrayZ;
|
||||||
*start_offset = 2 * offsets[glyph];
|
*start_offset = 2 * offsets[glyph];
|
||||||
*end_offset = 2 * offsets[glyph + 1];
|
*end_offset = 2 * offsets[glyph + 1];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const HBUINT32 *offsets = (const HBUINT32 *) loca_table->dataZ;
|
const HBUINT32 *offsets = (const HBUINT32 *) loca_table->dataZ.arrayZ;
|
||||||
|
|
||||||
*start_offset = offsets[glyph];
|
*start_offset = offsets[glyph];
|
||||||
*end_offset = offsets[glyph + 1];
|
*end_offset = offsets[glyph + 1];
|
||||||
|
@ -418,7 +418,7 @@ struct glyf
|
||||||
} while (composite_it.move_to_next());
|
} while (composite_it.move_to_next());
|
||||||
|
|
||||||
if ( (uint16_t) last->flags & CompositeGlyphHeader::WE_HAVE_INSTRUCTIONS)
|
if ( (uint16_t) last->flags & CompositeGlyphHeader::WE_HAVE_INSTRUCTIONS)
|
||||||
*instruction_start = ((char *) last - (char *) glyf_table->dataZ) + last->get_size();
|
*instruction_start = ((char *) last - (char *) glyf_table->dataZ.arrayZ) + last->get_size();
|
||||||
else
|
else
|
||||||
*instruction_start = end_offset;
|
*instruction_start = end_offset;
|
||||||
*instruction_end = end_offset;
|
*instruction_end = end_offset;
|
||||||
|
@ -483,7 +483,7 @@ struct glyf
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HBUINT8 dataZ[VAR]; /* Glyphs data. */
|
UnsizedArrayOf<HBUINT8> dataZ; /* Glyphs data. */
|
||||||
|
|
||||||
DEFINE_SIZE_ARRAY (0, dataZ);
|
DEFINE_SIZE_ARRAY (0, dataZ);
|
||||||
};
|
};
|
||||||
|
|
|
@ -66,7 +66,7 @@ struct DeviceRecord
|
||||||
if (unlikely (i >= len())) return nullptr;
|
if (unlikely (i >= len())) return nullptr;
|
||||||
hb_codepoint_t gid = this->subset_plan->glyphs [i];
|
hb_codepoint_t gid = this->subset_plan->glyphs [i];
|
||||||
|
|
||||||
const HBUINT8* width = &(this->source_device_record->widths[gid]);
|
const HBUINT8* width = &(this->source_device_record->widthsZ[gid]);
|
||||||
|
|
||||||
if (width < ((const HBUINT8 *) this->source_device_record) + size_device_record)
|
if (width < ((const HBUINT8 *) this->source_device_record) + size_device_record)
|
||||||
return width;
|
return width;
|
||||||
|
@ -77,11 +77,7 @@ struct DeviceRecord
|
||||||
|
|
||||||
static inline unsigned int get_size (unsigned int count)
|
static inline unsigned int get_size (unsigned int count)
|
||||||
{
|
{
|
||||||
unsigned int raw_size = min_size + count * HBUINT8::static_size;
|
return hb_ceil_to_4 (min_size + count * HBUINT8::static_size);
|
||||||
if (raw_size % 4)
|
|
||||||
/* Align to 32 bits */
|
|
||||||
return raw_size + (4 - (raw_size % 4));
|
|
||||||
return raw_size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool serialize (hb_serialize_context_t *c, const SubsetView &subset_view)
|
inline bool serialize (hb_serialize_context_t *c, const SubsetView &subset_view)
|
||||||
|
@ -107,7 +103,7 @@ struct DeviceRecord
|
||||||
DEBUG_MSG(SUBSET, nullptr, "HDMX width for new gid %d is missing.", i);
|
DEBUG_MSG(SUBSET, nullptr, "HDMX width for new gid %d is missing.", i);
|
||||||
return_trace (false);
|
return_trace (false);
|
||||||
}
|
}
|
||||||
widths[i].set (*width);
|
widthsZ[i].set (*width);
|
||||||
}
|
}
|
||||||
|
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
|
@ -122,9 +118,9 @@ struct DeviceRecord
|
||||||
|
|
||||||
HBUINT8 pixel_size; /* Pixel size for following widths (as ppem). */
|
HBUINT8 pixel_size; /* Pixel size for following widths (as ppem). */
|
||||||
HBUINT8 max_width; /* Maximum width. */
|
HBUINT8 max_width; /* Maximum width. */
|
||||||
HBUINT8 widths[VAR]; /* Array of widths (numGlyphs is from the 'maxp' table). */
|
UnsizedArrayOf<HBUINT8> widthsZ; /* Array of widths (numGlyphs is from the 'maxp' table). */
|
||||||
public:
|
public:
|
||||||
DEFINE_SIZE_ARRAY (2, widths);
|
DEFINE_SIZE_ARRAY (2, widthsZ);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -140,7 +136,7 @@ struct hdmx
|
||||||
inline const DeviceRecord& operator [] (unsigned int i) const
|
inline const DeviceRecord& operator [] (unsigned int i) const
|
||||||
{
|
{
|
||||||
if (unlikely (i >= num_records)) return Null(DeviceRecord);
|
if (unlikely (i >= num_records)) return Null(DeviceRecord);
|
||||||
return StructAtOffset<DeviceRecord> (this->data, i * size_device_record);
|
return StructAtOffset<DeviceRecord> (&this->dataZ, i * size_device_record);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool serialize (hb_serialize_context_t *c, const hdmx *source_hdmx, hb_subset_plan_t *plan)
|
inline bool serialize (hb_serialize_context_t *c, const hdmx *source_hdmx, hb_subset_plan_t *plan)
|
||||||
|
@ -214,9 +210,9 @@ struct hdmx
|
||||||
HBUINT16 version; /* Table version number (0) */
|
HBUINT16 version; /* Table version number (0) */
|
||||||
HBUINT16 num_records; /* Number of device records. */
|
HBUINT16 num_records; /* Number of device records. */
|
||||||
HBUINT32 size_device_record; /* Size of a device record, 32-bit aligned. */
|
HBUINT32 size_device_record; /* Size of a device record, 32-bit aligned. */
|
||||||
HBUINT8 data[VAR]; /* Array of device records. */
|
UnsizedArrayOf<HBUINT8> dataZ; /* Array of device records. */
|
||||||
public:
|
public:
|
||||||
DEFINE_SIZE_ARRAY (8, data);
|
DEFINE_SIZE_ARRAY (8, dataZ);
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace OT */
|
} /* namespace OT */
|
||||||
|
|
|
@ -262,7 +262,7 @@ struct hmtxvmtx
|
||||||
return default_advance;
|
return default_advance;
|
||||||
}
|
}
|
||||||
|
|
||||||
return table->longMetric[MIN (glyph, (uint32_t) num_advances - 1)].advance;
|
return table->longMetricZ[MIN (glyph, (uint32_t) num_advances - 1)].advance;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsigned int get_advance (hb_codepoint_t glyph,
|
inline unsigned int get_advance (hb_codepoint_t glyph,
|
||||||
|
@ -295,7 +295,7 @@ struct hmtxvmtx
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
LongMetric longMetric[VAR]; /* Paired advance width and leading
|
UnsizedArrayOf<LongMetric>longMetricZ;/* Paired advance width and leading
|
||||||
* bearing values for each glyph. The
|
* bearing values for each glyph. The
|
||||||
* value numOfHMetrics comes from
|
* value numOfHMetrics comes from
|
||||||
* the 'hhea' table. If the font is
|
* the 'hhea' table. If the font is
|
||||||
|
@ -303,7 +303,7 @@ struct hmtxvmtx
|
||||||
* be in the array, but that entry is
|
* be in the array, but that entry is
|
||||||
* required. The last entry applies to
|
* required. The last entry applies to
|
||||||
* all subsequent glyphs. */
|
* all subsequent glyphs. */
|
||||||
/*FWORD leadingBearingX[VAR];*/ /* Here the advance is assumed
|
/*UnsizedArrayOf<FWORD> leadingBearingX;*//* Here the advance is assumed
|
||||||
* to be the same as the advance
|
* to be the same as the advance
|
||||||
* for the last entry above. The
|
* for the last entry above. The
|
||||||
* number of entries in this array is
|
* number of entries in this array is
|
||||||
|
@ -317,7 +317,7 @@ struct hmtxvmtx
|
||||||
* font to vary the side bearing
|
* font to vary the side bearing
|
||||||
* values for each glyph. */
|
* values for each glyph. */
|
||||||
public:
|
public:
|
||||||
DEFINE_SIZE_ARRAY (0, longMetric);
|
DEFINE_SIZE_ARRAY (0, longMetricZ);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct hmtx : hmtxvmtx<hmtx, hhea> {
|
struct hmtx : hmtxvmtx<hmtx, hhea> {
|
||||||
|
|
|
@ -222,7 +222,7 @@ struct KernTable
|
||||||
inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right, unsigned int table_length) const
|
inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right, unsigned int table_length) const
|
||||||
{
|
{
|
||||||
int v = 0;
|
int v = 0;
|
||||||
const typename T::SubTableWrapper *st = CastP<typename T::SubTableWrapper> (thiz()->data);
|
const typename T::SubTableWrapper *st = CastP<typename T::SubTableWrapper> (&thiz()->dataZ);
|
||||||
unsigned int count = thiz()->nTables;
|
unsigned int count = thiz()->nTables;
|
||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
@ -241,7 +241,7 @@ struct KernTable
|
||||||
thiz()->version != T::VERSION))
|
thiz()->version != T::VERSION))
|
||||||
return_trace (false);
|
return_trace (false);
|
||||||
|
|
||||||
const typename T::SubTableWrapper *st = CastP<typename T::SubTableWrapper> (thiz()->data);
|
const typename T::SubTableWrapper *st = CastP<typename T::SubTableWrapper> (&thiz()->dataZ);
|
||||||
unsigned int count = thiz()->nTables;
|
unsigned int count = thiz()->nTables;
|
||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
@ -289,9 +289,9 @@ struct KernOT : KernTable<KernOT>
|
||||||
protected:
|
protected:
|
||||||
HBUINT16 version; /* Version--0x0000u */
|
HBUINT16 version; /* Version--0x0000u */
|
||||||
HBUINT16 nTables; /* Number of subtables in the kerning table. */
|
HBUINT16 nTables; /* Number of subtables in the kerning table. */
|
||||||
HBUINT8 data[VAR];
|
UnsizedArrayOf<HBUINT8> dataZ;
|
||||||
public:
|
public:
|
||||||
DEFINE_SIZE_ARRAY (4, data);
|
DEFINE_SIZE_ARRAY (4, dataZ);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct KernAAT : KernTable<KernAAT>
|
struct KernAAT : KernTable<KernAAT>
|
||||||
|
@ -329,9 +329,9 @@ struct KernAAT : KernTable<KernAAT>
|
||||||
protected:
|
protected:
|
||||||
HBUINT32 version; /* Version--0x00010000u */
|
HBUINT32 version; /* Version--0x00010000u */
|
||||||
HBUINT32 nTables; /* Number of subtables in the kerning table. */
|
HBUINT32 nTables; /* Number of subtables in the kerning table. */
|
||||||
HBUINT8 data[VAR];
|
UnsizedArrayOf<HBUINT8> dataZ;
|
||||||
public:
|
public:
|
||||||
DEFINE_SIZE_ARRAY (8, data);
|
DEFINE_SIZE_ARRAY (8, dataZ);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct kern
|
struct kern
|
||||||
|
|
|
@ -1549,7 +1549,7 @@ struct VarData
|
||||||
HBUINT16 itemCount;
|
HBUINT16 itemCount;
|
||||||
HBUINT16 shortCount;
|
HBUINT16 shortCount;
|
||||||
ArrayOf<HBUINT16> regionIndices;
|
ArrayOf<HBUINT16> regionIndices;
|
||||||
HBUINT8 bytesX[VAR];
|
UnsizedArrayOf<HBUINT8>bytesX;
|
||||||
public:
|
public:
|
||||||
DEFINE_SIZE_ARRAY2 (6, regionIndices, bytesX);
|
DEFINE_SIZE_ARRAY2 (6, regionIndices, bytesX);
|
||||||
};
|
};
|
||||||
|
@ -1844,7 +1844,7 @@ struct HintingDevice
|
||||||
|
|
||||||
unsigned int s = ppem_size - startSize;
|
unsigned int s = ppem_size - startSize;
|
||||||
|
|
||||||
unsigned int byte = deltaValue[s >> (4 - f)];
|
unsigned int byte = deltaValueZ[s >> (4 - f)];
|
||||||
unsigned int bits = (byte >> (16 - (((s & ((1 << (4 - f)) - 1)) + 1) << f)));
|
unsigned int bits = (byte >> (16 - (((s & ((1 << (4 - f)) - 1)) + 1) << f)));
|
||||||
unsigned int mask = (0xFFFFu >> (16 - (1 << f)));
|
unsigned int mask = (0xFFFFu >> (16 - (1 << f)));
|
||||||
|
|
||||||
|
@ -1864,9 +1864,10 @@ struct HintingDevice
|
||||||
* 2 Signed 4-bit value, 4 values per uint16
|
* 2 Signed 4-bit value, 4 values per uint16
|
||||||
* 3 Signed 8-bit value, 2 values per uint16
|
* 3 Signed 8-bit value, 2 values per uint16
|
||||||
*/
|
*/
|
||||||
HBUINT16 deltaValue[VAR]; /* Array of compressed data */
|
UnsizedArrayOf<HBUINT16>
|
||||||
|
deltaValueZ; /* Array of compressed data */
|
||||||
public:
|
public:
|
||||||
DEFINE_SIZE_ARRAY (6, deltaValue);
|
DEFINE_SIZE_ARRAY (6, deltaValueZ);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VariationDevice
|
struct VariationDevice
|
||||||
|
|
|
@ -376,7 +376,7 @@ struct AnchorMatrix
|
||||||
if (!c->check_struct (this)) return_trace (false);
|
if (!c->check_struct (this)) return_trace (false);
|
||||||
if (unlikely (hb_unsigned_mul_overflows (rows, cols))) return_trace (false);
|
if (unlikely (hb_unsigned_mul_overflows (rows, cols))) return_trace (false);
|
||||||
unsigned int count = rows * cols;
|
unsigned int count = rows * cols;
|
||||||
if (!c->check_array (matrixZ, count)) return_trace (false);
|
if (!c->check_array (matrixZ.arrayZ, count)) return_trace (false);
|
||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
if (!matrixZ[i].sanitize (c, this)) return_trace (false);
|
if (!matrixZ[i].sanitize (c, this)) return_trace (false);
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
|
@ -384,8 +384,8 @@ struct AnchorMatrix
|
||||||
|
|
||||||
HBUINT16 rows; /* Number of rows */
|
HBUINT16 rows; /* Number of rows */
|
||||||
protected:
|
protected:
|
||||||
OffsetTo<Anchor>
|
UnsizedArrayOf<OffsetTo<Anchor> >
|
||||||
matrixZ[VAR]; /* Matrix of offsets to Anchor tables--
|
matrixZ; /* Matrix of offsets to Anchor tables--
|
||||||
* from beginning of AnchorMatrix table */
|
* from beginning of AnchorMatrix table */
|
||||||
public:
|
public:
|
||||||
DEFINE_SIZE_ARRAY (2, matrixZ);
|
DEFINE_SIZE_ARRAY (2, matrixZ);
|
||||||
|
@ -621,7 +621,7 @@ struct PairSet
|
||||||
unsigned int len2 = valueFormats[1].get_len ();
|
unsigned int len2 = valueFormats[1].get_len ();
|
||||||
unsigned int record_size = HBUINT16::static_size * (1 + len1 + len2);
|
unsigned int record_size = HBUINT16::static_size * (1 + len1 + len2);
|
||||||
|
|
||||||
const PairValueRecord *record = CastP<PairValueRecord> (arrayZ);
|
const PairValueRecord *record = &firstPairValueRecord;
|
||||||
unsigned int count = len;
|
unsigned int count = len;
|
||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
@ -640,7 +640,7 @@ struct PairSet
|
||||||
unsigned int len2 = valueFormats[1].get_len ();
|
unsigned int len2 = valueFormats[1].get_len ();
|
||||||
unsigned int record_size = HBUINT16::static_size * (1 + len1 + len2);
|
unsigned int record_size = HBUINT16::static_size * (1 + len1 + len2);
|
||||||
|
|
||||||
const PairValueRecord *record = CastP<PairValueRecord> (arrayZ);
|
const PairValueRecord *record = &firstPairValueRecord;
|
||||||
c->input->add_array (&record->secondGlyph, len, record_size);
|
c->input->add_array (&record->secondGlyph, len, record_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -654,7 +654,6 @@ struct PairSet
|
||||||
unsigned int len2 = valueFormats[1].get_len ();
|
unsigned int len2 = valueFormats[1].get_len ();
|
||||||
unsigned int record_size = HBUINT16::static_size * (1 + len1 + len2);
|
unsigned int record_size = HBUINT16::static_size * (1 + len1 + len2);
|
||||||
|
|
||||||
const PairValueRecord *record_array = CastP<PairValueRecord> (arrayZ);
|
|
||||||
unsigned int count = len;
|
unsigned int count = len;
|
||||||
|
|
||||||
/* Hand-coded bsearch. */
|
/* Hand-coded bsearch. */
|
||||||
|
@ -665,7 +664,7 @@ struct PairSet
|
||||||
while (min <= max)
|
while (min <= max)
|
||||||
{
|
{
|
||||||
int mid = (min + max) / 2;
|
int mid = (min + max) / 2;
|
||||||
const PairValueRecord *record = &StructAtOffset<PairValueRecord> (record_array, record_size * mid);
|
const PairValueRecord *record = &StructAtOffset<PairValueRecord> (&firstPairValueRecord, record_size * mid);
|
||||||
hb_codepoint_t mid_x = record->secondGlyph;
|
hb_codepoint_t mid_x = record->secondGlyph;
|
||||||
if (x < mid_x)
|
if (x < mid_x)
|
||||||
max = mid - 1;
|
max = mid - 1;
|
||||||
|
@ -698,20 +697,21 @@ struct PairSet
|
||||||
{
|
{
|
||||||
TRACE_SANITIZE (this);
|
TRACE_SANITIZE (this);
|
||||||
if (!(c->check_struct (this)
|
if (!(c->check_struct (this)
|
||||||
&& c->check_array (arrayZ, len, HBUINT16::static_size * closure->stride))) return_trace (false);
|
&& c->check_array (&firstPairValueRecord, len, HBUINT16::static_size * closure->stride))) return_trace (false);
|
||||||
|
|
||||||
unsigned int count = len;
|
unsigned int count = len;
|
||||||
const PairValueRecord *record = CastP<PairValueRecord> (arrayZ);
|
const PairValueRecord *record = &firstPairValueRecord;
|
||||||
return_trace (closure->valueFormats[0].sanitize_values_stride_unsafe (c, closure->base, &record->values[0], count, closure->stride) &&
|
return_trace (closure->valueFormats[0].sanitize_values_stride_unsafe (c, closure->base, &record->values[0], count, closure->stride) &&
|
||||||
closure->valueFormats[1].sanitize_values_stride_unsafe (c, closure->base, &record->values[closure->len1], count, closure->stride));
|
closure->valueFormats[1].sanitize_values_stride_unsafe (c, closure->base, &record->values[closure->len1], count, closure->stride));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HBUINT16 len; /* Number of PairValueRecords */
|
HBUINT16 len; /* Number of PairValueRecords */
|
||||||
HBUINT16 arrayZ[VAR]; /* Array of PairValueRecords--ordered
|
PairValueRecord firstPairValueRecord;
|
||||||
|
/* Array of PairValueRecords--ordered
|
||||||
* by GlyphID of the second glyph */
|
* by GlyphID of the second glyph */
|
||||||
public:
|
public:
|
||||||
DEFINE_SIZE_ARRAY (2, arrayZ);
|
DEFINE_SIZE_MIN (2);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PairPosFormat1
|
struct PairPosFormat1
|
||||||
|
|
|
@ -234,7 +234,7 @@ struct MathKern
|
||||||
TRACE_SANITIZE (this);
|
TRACE_SANITIZE (this);
|
||||||
unsigned int count = 2 * heightCount + 1;
|
unsigned int count = 2 * heightCount + 1;
|
||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
if (!mathValueRecords[i].sanitize (c, this)) return_trace (false);
|
if (!mathValueRecordsZ.arrayZ[i].sanitize (c, this)) return_trace (false);
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,14 +242,14 @@ struct MathKern
|
||||||
{
|
{
|
||||||
TRACE_SANITIZE (this);
|
TRACE_SANITIZE (this);
|
||||||
return_trace (c->check_struct (this) &&
|
return_trace (c->check_struct (this) &&
|
||||||
c->check_array (mathValueRecords, 2 * heightCount + 1) &&
|
c->check_array (mathValueRecordsZ.arrayZ, 2 * heightCount + 1) &&
|
||||||
sanitize_math_value_records (c));
|
sanitize_math_value_records (c));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline hb_position_t get_value (hb_position_t correction_height, hb_font_t *font) const
|
inline hb_position_t get_value (hb_position_t correction_height, hb_font_t *font) const
|
||||||
{
|
{
|
||||||
const MathValueRecord* correctionHeight = mathValueRecords;
|
const MathValueRecord* correctionHeight = mathValueRecordsZ.arrayZ;
|
||||||
const MathValueRecord* kernValue = mathValueRecords + heightCount;
|
const MathValueRecord* kernValue = mathValueRecordsZ.arrayZ + heightCount;
|
||||||
int sign = font->y_scale < 0 ? -1 : +1;
|
int sign = font->y_scale < 0 ? -1 : +1;
|
||||||
|
|
||||||
/* The description of the MathKern table is a ambiguous, but interpreting
|
/* The description of the MathKern table is a ambiguous, but interpreting
|
||||||
|
@ -278,7 +278,8 @@ struct MathKern
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HBUINT16 heightCount;
|
HBUINT16 heightCount;
|
||||||
MathValueRecord mathValueRecords[VAR]; /* Array of correction heights at
|
UnsizedArrayOf<MathValueRecord>
|
||||||
|
mathValueRecordsZ; /* Array of correction heights at
|
||||||
* which the kern value changes.
|
* which the kern value changes.
|
||||||
* Sorted by the height value in
|
* Sorted by the height value in
|
||||||
* design units (heightCount entries),
|
* design units (heightCount entries),
|
||||||
|
@ -288,7 +289,7 @@ struct MathKern
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DEFINE_SIZE_ARRAY (2, mathValueRecords);
|
DEFINE_SIZE_ARRAY (2, mathValueRecordsZ);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MathKernInfoRecord
|
struct MathKernInfoRecord
|
||||||
|
@ -586,7 +587,7 @@ struct MathVariants
|
||||||
TRACE_SANITIZE (this);
|
TRACE_SANITIZE (this);
|
||||||
unsigned int count = vertGlyphCount + horizGlyphCount;
|
unsigned int count = vertGlyphCount + horizGlyphCount;
|
||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
if (!glyphConstruction[i].sanitize (c, this)) return_trace (false);
|
if (!glyphConstruction.arrayZ[i].sanitize (c, this)) return_trace (false);
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -596,7 +597,7 @@ struct MathVariants
|
||||||
return_trace (c->check_struct (this) &&
|
return_trace (c->check_struct (this) &&
|
||||||
vertGlyphCoverage.sanitize (c, this) &&
|
vertGlyphCoverage.sanitize (c, this) &&
|
||||||
horizGlyphCoverage.sanitize (c, this) &&
|
horizGlyphCoverage.sanitize (c, this) &&
|
||||||
c->check_array (glyphConstruction, vertGlyphCount + horizGlyphCount) &&
|
c->check_array (glyphConstruction.arrayZ, vertGlyphCount + horizGlyphCount) &&
|
||||||
sanitize_offsets (c));
|
sanitize_offsets (c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,7 +667,8 @@ struct MathVariants
|
||||||
/* Array of offsets to MathGlyphConstruction tables - from the beginning of
|
/* Array of offsets to MathGlyphConstruction tables - from the beginning of
|
||||||
the MathVariants table, for shapes growing in vertical/horizontal
|
the MathVariants table, for shapes growing in vertical/horizontal
|
||||||
direction. */
|
direction. */
|
||||||
OffsetTo<MathGlyphConstruction> glyphConstruction[VAR];
|
UnsizedArrayOf<OffsetTo<MathGlyphConstruction> >
|
||||||
|
glyphConstruction;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DEFINE_SIZE_ARRAY (10, glyphConstruction);
|
DEFINE_SIZE_ARRAY (10, glyphConstruction);
|
||||||
|
|
|
@ -91,7 +91,7 @@ struct name
|
||||||
key.encodingID.set (encoding_id);
|
key.encodingID.set (encoding_id);
|
||||||
key.languageID.set (language_id);
|
key.languageID.set (language_id);
|
||||||
key.nameID.set (name_id);
|
key.nameID.set (name_id);
|
||||||
NameRecord *match = (NameRecord *) bsearch (&key, nameRecord, count, sizeof (nameRecord[0]), NameRecord::cmp);
|
NameRecord *match = (NameRecord *) bsearch (&key, nameRecordZ.arrayZ, count, sizeof (nameRecordZ[0]), NameRecord::cmp);
|
||||||
|
|
||||||
if (!match)
|
if (!match)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -102,14 +102,14 @@ struct name
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsigned int get_size (void) const
|
inline unsigned int get_size (void) const
|
||||||
{ return min_size + count * nameRecord[0].min_size; }
|
{ return min_size + count * nameRecordZ[0].min_size; }
|
||||||
|
|
||||||
inline bool sanitize_records (hb_sanitize_context_t *c) const {
|
inline bool sanitize_records (hb_sanitize_context_t *c) const {
|
||||||
TRACE_SANITIZE (this);
|
TRACE_SANITIZE (this);
|
||||||
char *string_pool = (char *) this + stringOffset;
|
char *string_pool = (char *) this + stringOffset;
|
||||||
unsigned int _count = count;
|
unsigned int _count = count;
|
||||||
for (unsigned int i = 0; i < _count; i++)
|
for (unsigned int i = 0; i < _count; i++)
|
||||||
if (!nameRecord[i].sanitize (c, string_pool)) return_trace (false);
|
if (!nameRecordZ[i].sanitize (c, string_pool)) return_trace (false);
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ struct name
|
||||||
TRACE_SANITIZE (this);
|
TRACE_SANITIZE (this);
|
||||||
return_trace (c->check_struct (this) &&
|
return_trace (c->check_struct (this) &&
|
||||||
likely (format == 0 || format == 1) &&
|
likely (format == 0 || format == 1) &&
|
||||||
c->check_array (nameRecord, count) &&
|
c->check_array (nameRecordZ.arrayZ, count) &&
|
||||||
sanitize_records (c));
|
sanitize_records (c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,9 +126,10 @@ struct name
|
||||||
HBUINT16 format; /* Format selector (=0/1). */
|
HBUINT16 format; /* Format selector (=0/1). */
|
||||||
HBUINT16 count; /* Number of name records. */
|
HBUINT16 count; /* Number of name records. */
|
||||||
Offset16 stringOffset; /* Offset to start of string storage (from start of table). */
|
Offset16 stringOffset; /* Offset to start of string storage (from start of table). */
|
||||||
NameRecord nameRecord[VAR]; /* The name records where count is the number of records. */
|
UnsizedArrayOf<NameRecord>
|
||||||
|
nameRecordZ; /* The name records where count is the number of records. */
|
||||||
public:
|
public:
|
||||||
DEFINE_SIZE_ARRAY (6, nameRecord);
|
DEFINE_SIZE_ARRAY (6, nameRecordZ);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -55,10 +55,11 @@ struct postV2Tail
|
||||||
return_trace (glyphNameIndex.sanitize (c));
|
return_trace (glyphNameIndex.sanitize (c));
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayOf<HBUINT16>glyphNameIndex; /* This is not an offset, but is the
|
ArrayOf<HBUINT16> glyphNameIndex; /* This is not an offset, but is the
|
||||||
* ordinal number of the glyph in 'post'
|
* ordinal number of the glyph in 'post'
|
||||||
* string tables. */
|
* string tables. */
|
||||||
HBUINT8 namesX[VAR]; /* Glyph names with length bytes [variable]
|
UnsizedArrayOf<HBUINT8>
|
||||||
|
namesX; /* Glyph names with length bytes [variable]
|
||||||
* (a Pascal string). */
|
* (a Pascal string). */
|
||||||
|
|
||||||
DEFINE_SIZE_ARRAY2 (2, glyphNameIndex, namesX);
|
DEFINE_SIZE_ARRAY2 (2, glyphNameIndex, namesX);
|
||||||
|
|
Loading…
Reference in New Issue