提交 dff2c45f 编写于 作者: B Behdad Esfahbod

Port rest from VAR to UnsizedArrayOf<>

上级 9507b05a
......@@ -67,11 +67,11 @@ struct BinSearchArrayOf
inline const Type& operator [] (unsigned int i) const
{
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)
{
return StructAtOffset<Type> (bytesZ, i * header.unitSize);
return StructAtOffset<Type> (&bytesZ, i * header.unitSize);
}
inline unsigned int get_size (void) const
{ 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
* reference other structs via offsets.
*/
(void) (false && StructAtOffset<Type> (bytesZ, 0).sanitize (c));
(void) (false && StructAtOffset<Type> (&bytesZ, 0).sanitize (c));
return_trace (true);
}
......@@ -111,7 +111,7 @@ struct BinSearchArrayOf
while (min <= max)
{
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);
if (c < 0)
max = mid - 1;
......@@ -129,12 +129,12 @@ struct BinSearchArrayOf
TRACE_SANITIZE (this);
return_trace (header.sanitize (c) &&
Type::static_size >= header.unitSize &&
c->check_array (bytesZ, header.nUnits, header.unitSize));
c->check_array (bytesZ.arrayZ, header.nUnits, header.unitSize));
}
protected:
BinSearchHeader header;
HBUINT8 bytesZ[VAR];
BinSearchHeader header;
UnsizedArrayOf<HBUINT8> bytesZ;
public:
DEFINE_SIZE_ARRAY (10, bytesZ);
};
......
......@@ -619,7 +619,7 @@ struct Chain
{
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;
for (unsigned int i = 0; i < count; i++)
{
......@@ -648,10 +648,10 @@ struct Chain
!c->check_range (this, length))
return_trace (false);
if (!c->check_array (featureZ, featureCount))
if (!c->check_array (featureZ.arrayZ, featureCount))
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;
for (unsigned int i = 0; i < count; i++)
{
......@@ -669,8 +669,8 @@ struct Chain
HBUINT32 featureCount; /* Number of feature subtable entries. */
HBUINT32 subtableCount; /* The number of subtables in the chain. */
Feature featureZ[VAR]; /* Features. */
/*ChainSubtable subtableX[VAR];*//* Subtables. */
UnsizedArrayOf<Feature> featureZ; /* Features. */
/*ChainSubtable firstSubtable;*//* Subtables. */
/*subtableGlyphCoverageArray*/ /* Only if major == 3. */
public:
......@@ -689,7 +689,7 @@ struct morx
inline void apply (hb_aat_apply_context_t *c) const
{
c->set_lookup_index (0);
const Chain *chain = chainsZ;
const Chain *chain = &firstChain;
unsigned int count = chainCount;
for (unsigned int i = 0; i < count; i++)
{
......@@ -706,7 +706,7 @@ struct morx
!chainCount.sanitize (c))
return_trace (false);
const Chain *chain = chainsZ;
const Chain *chain = &firstChain;
unsigned int count = chainCount;
for (unsigned int i = 0; i < count; i++)
{
......@@ -723,7 +723,7 @@ struct morx
* 1 for mort, 2 or 3 for morx. */
HBUINT32 chainCount; /* Number of metamorphosis chains contained in this
* table. */
Chain chainsZ[VAR]; /* Chains. */
Chain firstChain; /* Chains. */
public:
DEFINE_SIZE_MIN (8);
......
......@@ -349,7 +349,7 @@ struct UnsizedArrayOf
}
public:
Type arrayZ[VAR];
Type arrayZ[VAR];
public:
DEFINE_SIZE_ARRAY (0, arrayZ);
};
......@@ -491,8 +491,8 @@ struct ArrayOf
}
public:
LenType len;
Type arrayZ[VAR];
LenType len;
Type arrayZ[VAR];
public:
DEFINE_SIZE_ARRAY (sizeof (LenType), arrayZ);
};
......@@ -600,8 +600,8 @@ struct HeadlessArrayOf
}
public:
LenType len;
Type arrayZ[VAR];
LenType len;
Type arrayZ[VAR];
public:
DEFINE_SIZE_ARRAY (sizeof (LenType), arrayZ);
};
......
......@@ -231,7 +231,7 @@ struct CmapSubtableFormat4
inline void init (const CmapSubtableFormat4 *subtable)
{
segCount = subtable->segCountX2 / 2;
endCount = subtable->values;
endCount = subtable->values.arrayZ;
startCount = endCount + segCount + 1;
idDelta = startCount + segCount;
idRangeOffset = idDelta + segCount;
......@@ -369,7 +369,8 @@ struct CmapSubtableFormat4
HBUINT16 entrySelector; /* log2(searchRange/2) */
HBUINT16 rangeShift; /* 2 x segCount - searchRange */
HBUINT16 values[VAR];
UnsizedArrayOf<HBUINT16>
values;
#if 0
HBUINT16 endCount[segCount]; /* End characterCode for each segment,
* last=0xFFFFu. */
......@@ -377,7 +378,8 @@ struct CmapSubtableFormat4
HBUINT16 startCount[segCount]; /* Start character code for each segment. */
HBINT16 idDelta[segCount]; /* Delta for all character codes in segment. */
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
public:
......
......@@ -128,7 +128,7 @@ struct IndexSubtableFormat1Or3
{
TRACE_SANITIZE (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,
......@@ -144,7 +144,8 @@ struct IndexSubtableFormat1Or3
}
IndexSubtableHeader header;
Offset<OffsetType> offsetArrayZ[VAR];
UnsizedArrayOf<Offset<OffsetType> >
offsetArrayZ;
public:
DEFINE_SIZE_ARRAY(8, offsetArrayZ);
};
......@@ -240,7 +241,7 @@ struct IndexSubtableArray
inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const
{
TRACE_SANITIZE (this);
if (unlikely (!c->check_array (indexSubtablesZ, count)))
if (unlikely (!c->check_array (indexSubtablesZ.arrayZ, count)))
return_trace (false);
for (unsigned int i = 0; i < count; i++)
if (unlikely (!indexSubtablesZ[i].sanitize (c, this)))
......@@ -255,15 +256,14 @@ struct IndexSubtableArray
{
unsigned int firstGlyphIndex = indexSubtablesZ[i].firstGlyphIndex;
unsigned int lastGlyphIndex = indexSubtablesZ[i].lastGlyphIndex;
if (firstGlyphIndex <= glyph && glyph <= lastGlyphIndex) {
if (firstGlyphIndex <= glyph && glyph <= lastGlyphIndex)
return &indexSubtablesZ[i];
}
}
return nullptr;
}
protected:
IndexSubtableRecord indexSubtablesZ[VAR];
UnsizedArrayOf<IndexSubtableRecord> indexSubtablesZ;
public:
DEFINE_SIZE_ARRAY(0, indexSubtablesZ);
};
......@@ -527,8 +527,8 @@ struct CBDT
protected:
FixedVersion<> version;
HBUINT8 dataZ[VAR];
FixedVersion<> version;
UnsizedArrayOf<HBUINT8> dataZ;
public:
DEFINE_SIZE_ARRAY(4, dataZ);
};
......
......@@ -54,7 +54,7 @@ struct loca
}
protected:
HBUINT8 dataZ[VAR]; /* Location data. */
UnsizedArrayOf<HBUINT8> dataZ; /* Location data. */
DEFINE_SIZE_ARRAY (0, dataZ);
};
......@@ -375,13 +375,13 @@ struct glyf
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];
*end_offset = 2 * offsets[glyph + 1];
}
else
{
const HBUINT32 *offsets = (const HBUINT32 *) loca_table->dataZ;
const HBUINT32 *offsets = (const HBUINT32 *) loca_table->dataZ.arrayZ;
*start_offset = offsets[glyph];
*end_offset = offsets[glyph + 1];
......@@ -418,7 +418,7 @@ struct glyf
} while (composite_it.move_to_next());
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
*instruction_start = end_offset;
*instruction_end = end_offset;
......@@ -483,7 +483,7 @@ struct glyf
};
protected:
HBUINT8 dataZ[VAR]; /* Glyphs data. */
UnsizedArrayOf<HBUINT8> dataZ; /* Glyphs data. */
DEFINE_SIZE_ARRAY (0, dataZ);
};
......
......@@ -66,7 +66,7 @@ struct DeviceRecord
if (unlikely (i >= len())) return nullptr;
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)
return width;
......@@ -77,11 +77,7 @@ struct DeviceRecord
static inline unsigned int get_size (unsigned int count)
{
unsigned int raw_size = min_size + count * HBUINT8::static_size;
if (raw_size % 4)
/* Align to 32 bits */
return raw_size + (4 - (raw_size % 4));
return raw_size;
return hb_ceil_to_4 (min_size + count * HBUINT8::static_size);
}
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);
return_trace (false);
}
widths[i].set (*width);
widthsZ[i].set (*width);
}
return_trace (true);
......@@ -120,11 +116,11 @@ struct DeviceRecord
c->check_range (this, size_device_record)));
}
HBUINT8 pixel_size; /* Pixel size for following widths (as ppem). */
HBUINT8 max_width; /* Maximum width. */
HBUINT8 widths[VAR]; /* Array of widths (numGlyphs is from the 'maxp' table). */
HBUINT8 pixel_size; /* Pixel size for following widths (as ppem). */
HBUINT8 max_width; /* Maximum width. */
UnsizedArrayOf<HBUINT8> widthsZ; /* Array of widths (numGlyphs is from the 'maxp' table). */
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
{
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)
......@@ -211,12 +207,12 @@ struct hdmx
}
protected:
HBUINT16 version; /* Table version number (0) */
HBUINT16 num_records; /* Number of device records. */
HBUINT32 size_device_record; /* Size of a device record, 32-bit aligned. */
HBUINT8 data[VAR]; /* Array of device records. */
HBUINT16 version; /* Table version number (0) */
HBUINT16 num_records; /* Number of device records. */
HBUINT32 size_device_record; /* Size of a device record, 32-bit aligned. */
UnsizedArrayOf<HBUINT8> dataZ; /* Array of device records. */
public:
DEFINE_SIZE_ARRAY (8, data);
DEFINE_SIZE_ARRAY (8, dataZ);
};
} /* namespace OT */
......
......@@ -262,7 +262,7 @@ struct hmtxvmtx
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,
......@@ -295,7 +295,7 @@ struct hmtxvmtx
};
protected:
LongMetric longMetric[VAR]; /* Paired advance width and leading
UnsizedArrayOf<LongMetric>longMetricZ;/* Paired advance width and leading
* bearing values for each glyph. The
* value numOfHMetrics comes from
* the 'hhea' table. If the font is
......@@ -303,7 +303,7 @@ struct hmtxvmtx
* be in the array, but that entry is
* required. The last entry applies to
* 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
* for the last entry above. The
* number of entries in this array is
......@@ -317,7 +317,7 @@ struct hmtxvmtx
* font to vary the side bearing
* values for each glyph. */
public:
DEFINE_SIZE_ARRAY (0, longMetric);
DEFINE_SIZE_ARRAY (0, longMetricZ);
};
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
{
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;
for (unsigned int i = 0; i < count; i++)
{
......@@ -241,7 +241,7 @@ struct KernTable
thiz()->version != T::VERSION))
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;
for (unsigned int i = 0; i < count; i++)
{
......@@ -287,11 +287,11 @@ struct KernOT : KernTable<KernOT>
};
protected:
HBUINT16 version; /* Version--0x0000u */
HBUINT16 nTables; /* Number of subtables in the kerning table. */
HBUINT8 data[VAR];
HBUINT16 version; /* Version--0x0000u */
HBUINT16 nTables; /* Number of subtables in the kerning table. */
UnsizedArrayOf<HBUINT8> dataZ;
public:
DEFINE_SIZE_ARRAY (4, data);
DEFINE_SIZE_ARRAY (4, dataZ);
};
struct KernAAT : KernTable<KernAAT>
......@@ -327,11 +327,11 @@ struct KernAAT : KernTable<KernAAT>
};
protected:
HBUINT32 version; /* Version--0x00010000u */
HBUINT32 nTables; /* Number of subtables in the kerning table. */
HBUINT8 data[VAR];
HBUINT32 version; /* Version--0x00010000u */
HBUINT32 nTables; /* Number of subtables in the kerning table. */
UnsizedArrayOf<HBUINT8> dataZ;
public:
DEFINE_SIZE_ARRAY (8, data);
DEFINE_SIZE_ARRAY (8, dataZ);
};
struct kern
......
......@@ -1549,7 +1549,7 @@ struct VarData
HBUINT16 itemCount;
HBUINT16 shortCount;
ArrayOf<HBUINT16> regionIndices;
HBUINT8 bytesX[VAR];
UnsizedArrayOf<HBUINT8>bytesX;
public:
DEFINE_SIZE_ARRAY2 (6, regionIndices, bytesX);
};
......@@ -1844,7 +1844,7 @@ struct HintingDevice
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 mask = (0xFFFFu >> (16 - (1 << f)));
......@@ -1864,9 +1864,10 @@ struct HintingDevice
* 2 Signed 4-bit value, 4 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:
DEFINE_SIZE_ARRAY (6, deltaValue);
DEFINE_SIZE_ARRAY (6, deltaValueZ);
};
struct VariationDevice
......
......@@ -376,7 +376,7 @@ struct AnchorMatrix
if (!c->check_struct (this)) return_trace (false);
if (unlikely (hb_unsigned_mul_overflows (rows, cols))) return_trace (false);
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++)
if (!matrixZ[i].sanitize (c, this)) return_trace (false);
return_trace (true);
......@@ -384,8 +384,8 @@ struct AnchorMatrix
HBUINT16 rows; /* Number of rows */
protected:
OffsetTo<Anchor>
matrixZ[VAR]; /* Matrix of offsets to Anchor tables--
UnsizedArrayOf<OffsetTo<Anchor> >
matrixZ; /* Matrix of offsets to Anchor tables--
* from beginning of AnchorMatrix table */
public:
DEFINE_SIZE_ARRAY (2, matrixZ);
......@@ -621,7 +621,7 @@ struct PairSet
unsigned int len2 = valueFormats[1].get_len ();
unsigned int record_size = HBUINT16::static_size * (1 + len1 + len2);
const PairValueRecord *record = CastP<PairValueRecord> (arrayZ);
const PairValueRecord *record = &firstPairValueRecord;
unsigned int count = len;
for (unsigned int i = 0; i < count; i++)
{
......@@ -640,7 +640,7 @@ struct PairSet
unsigned int len2 = valueFormats[1].get_len ();
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);
}
......@@ -654,7 +654,6 @@ struct PairSet
unsigned int len2 = valueFormats[1].get_len ();
unsigned int record_size = HBUINT16::static_size * (1 + len1 + len2);
const PairValueRecord *record_array = CastP<PairValueRecord> (arrayZ);
unsigned int count = len;
/* Hand-coded bsearch. */
......@@ -665,7 +664,7 @@ struct PairSet
while (min <= max)
{
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;
if (x < mid_x)
max = mid - 1;
......@@ -698,20 +697,21 @@ struct PairSet
{
TRACE_SANITIZE (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;
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) &&
closure->valueFormats[1].sanitize_values_stride_unsafe (c, closure->base, &record->values[closure->len1], count, closure->stride));
}
protected:
HBUINT16 len; /* Number of PairValueRecords */
HBUINT16 arrayZ[VAR]; /* Array of PairValueRecords--ordered
* by GlyphID of the second glyph */
HBUINT16 len; /* Number of PairValueRecords */
PairValueRecord firstPairValueRecord;
/* Array of PairValueRecords--ordered
* by GlyphID of the second glyph */
public:
DEFINE_SIZE_ARRAY (2, arrayZ);
DEFINE_SIZE_MIN (2);
};
struct PairPosFormat1
......
......@@ -234,7 +234,7 @@ struct MathKern
TRACE_SANITIZE (this);
unsigned int count = 2 * heightCount + 1;
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);
}
......@@ -242,14 +242,14 @@ struct MathKern
{
TRACE_SANITIZE (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));
}
inline hb_position_t get_value (hb_position_t correction_height, hb_font_t *font) const
{
const MathValueRecord* correctionHeight = mathValueRecords;
const MathValueRecord* kernValue = mathValueRecords + heightCount;
const MathValueRecord* correctionHeight = mathValueRecordsZ.arrayZ;
const MathValueRecord* kernValue = mathValueRecordsZ.arrayZ + heightCount;
int sign = font->y_scale < 0 ? -1 : +1;
/* The description of the MathKern table is a ambiguous, but interpreting
......@@ -277,18 +277,19 @@ struct MathKern
}
protected:
HBUINT16 heightCount;
MathValueRecord mathValueRecords[VAR]; /* Array of correction heights at
* which the kern value changes.
* Sorted by the height value in
* design units (heightCount entries),
* Followed by:
* Array of kern values corresponding
* to heights. (heightCount+1 entries).
*/
HBUINT16 heightCount;
UnsizedArrayOf<MathValueRecord>
mathValueRecordsZ; /* Array of correction heights at
* which the kern value changes.
* Sorted by the height value in
* design units (heightCount entries),
* Followed by:
* Array of kern values corresponding
* to heights. (heightCount+1 entries).
*/
public:
DEFINE_SIZE_ARRAY (2, mathValueRecords);
DEFINE_SIZE_ARRAY (2, mathValueRecordsZ);
};
struct MathKernInfoRecord
......@@ -586,7 +587,7 @@ struct MathVariants
TRACE_SANITIZE (this);
unsigned int count = vertGlyphCount + horizGlyphCount;
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);
}
......@@ -596,7 +597,7 @@ struct MathVariants
return_trace (c->check_struct (this) &&
vertGlyphCoverage.sanitize (c, this) &&
horizGlyphCoverage.sanitize (c, this) &&
c->check_array (glyphConstruction, vertGlyphCount + horizGlyphCount) &&
c->check_array (glyphConstruction.arrayZ, vertGlyphCount + horizGlyphCount) &&
sanitize_offsets (c));
}
......@@ -666,7 +667,8 @@ struct MathVariants
/* Array of offsets to MathGlyphConstruction tables - from the beginning of
the MathVariants table, for shapes growing in vertical/horizontal
direction. */
OffsetTo<MathGlyphConstruction> glyphConstruction[VAR];
UnsizedArrayOf<OffsetTo<MathGlyphConstruction> >
glyphConstruction;
public:
DEFINE_SIZE_ARRAY (10, glyphConstruction);
......
......@@ -136,7 +136,7 @@ struct maxp
FixedVersion<>version; /* Version of the maxp table (0.5 or 1.0),
* 0x00005000u or 0x00010000u. */
HBUINT16 numGlyphs; /* The number of glyphs in the font. */
/*maxpV1Tail v1Tail[VAR]; */
/*maxpV1Tail v1Tail[VAR]; */
public:
DEFINE_SIZE_STATIC (6);
};
......
......@@ -91,7 +91,7 @@ struct name
key.encodingID.set (encoding_id);
key.languageID.set (language_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)
return 0;
......@@ -102,14 +102,14 @@ struct name
}
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 {
TRACE_SANITIZE (this);
char *string_pool = (char *) this + stringOffset;
unsigned int _count = count;
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);
}
......@@ -118,7 +118,7 @@ struct name
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) &&
likely (format == 0 || format == 1) &&
c->check_array (nameRecord, count) &&
c->check_array (nameRecordZ.arrayZ, count) &&
sanitize_records (c));
}
......@@ -126,9 +126,10 @@ struct name
HBUINT16 format; /* Format selector (=0/1). */
HBUINT16 count; /* Number of name records. */
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:
DEFINE_SIZE_ARRAY (6, nameRecord);
DEFINE_SIZE_ARRAY (6, nameRecordZ);
};
......
......@@ -55,10 +55,11 @@ struct postV2Tail
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'
* string tables. */
HBUINT8 namesX[VAR]; /* Glyph names with length bytes [variable]
UnsizedArrayOf<HBUINT8>
namesX; /* Glyph names with length bytes [variable]
* (a Pascal string). */
DEFINE_SIZE_ARRAY2 (2, glyphNameIndex, namesX);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册