[HarfBuzz] harfbuzz: Branch 'master' - 3 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Mon Sep 10 23:01:49 UTC 2018
src/hb-aat-layout-common.hh | 22 ++++++--------
src/hb-aat-layout-morx-table.hh | 16 +++++-----
src/hb-machinery.hh | 3 +
src/hb-open-type.hh | 16 +++++-----
src/hb-ot-cmap-table.hh | 8 +++--
src/hb-ot-color-cbdt-table.hh | 16 +++++-----
src/hb-ot-glyf-table.hh | 10 +++---
src/hb-ot-hdmx-table.hh | 30 ++++++++-----------
src/hb-ot-hmtx-table.hh | 8 ++---
src/hb-ot-kern-table.hh | 22 +++++++-------
src/hb-ot-layout-common.hh | 11 +++----
src/hb-ot-layout-gpos-table.hh | 30 +++++++++----------
src/hb-ot-layout-gsubgpos.hh | 61 ++++++++++++++++++++--------------------
src/hb-ot-math-table.hh | 40 ++++++++++++--------------
src/hb-ot-maxp-table.hh | 2 -
src/hb-ot-name-table.hh | 13 ++++----
src/hb-ot-post-table.hh | 5 +--
src/hb-ot-var-avar-table.hh | 8 +++--
src/hb-ot-var-fvar-table.hh | 7 ++--
src/hb-ot-var-hvar-table.hh | 9 +++--
src/hb-ot-var-mvar-table.hh | 9 +++--
21 files changed, 176 insertions(+), 170 deletions(-)
New commits:
commit dff2c45f1e2a30767f6813d3cb6a70978d98d424
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Sep 10 23:29:26 2018 +0200
Port rest from VAR to UnsizedArrayOf<>
diff --git a/src/hb-aat-layout-common.hh b/src/hb-aat-layout-common.hh
index 85c40a71..7a5be84c 100644
--- a/src/hb-aat-layout-common.hh
+++ b/src/hb-aat-layout-common.hh
@@ -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);
};
diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh
index 6f7bf770..e4774c4c 100644
--- a/src/hb-aat-layout-morx-table.hh
+++ b/src/hb-aat-layout-morx-table.hh
@@ -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);
diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh
index 49e52c6e..27ec7720 100644
--- a/src/hb-open-type.hh
+++ b/src/hb-open-type.hh
@@ -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);
};
diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh
index e6876d12..3f5fa01f 100644
--- a/src/hb-ot-cmap-table.hh
+++ b/src/hb-ot-cmap-table.hh
@@ -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:
diff --git a/src/hb-ot-color-cbdt-table.hh b/src/hb-ot-color-cbdt-table.hh
index a5636975..7c172ce4 100644
--- a/src/hb-ot-color-cbdt-table.hh
+++ b/src/hb-ot-color-cbdt-table.hh
@@ -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);
};
diff --git a/src/hb-ot-glyf-table.hh b/src/hb-ot-glyf-table.hh
index 7c209836..2145ac02 100644
--- a/src/hb-ot-glyf-table.hh
+++ b/src/hb-ot-glyf-table.hh
@@ -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);
};
diff --git a/src/hb-ot-hdmx-table.hh b/src/hb-ot-hdmx-table.hh
index 87dd6d01..04511b5d 100644
--- a/src/hb-ot-hdmx-table.hh
+++ b/src/hb-ot-hdmx-table.hh
@@ -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 */
diff --git a/src/hb-ot-hmtx-table.hh b/src/hb-ot-hmtx-table.hh
index 3e4b3bde..363395ab 100644
--- a/src/hb-ot-hmtx-table.hh
+++ b/src/hb-ot-hmtx-table.hh
@@ -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> {
diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh
index e9f109c3..8ed6298f 100644
--- a/src/hb-ot-kern-table.hh
+++ b/src/hb-ot-kern-table.hh
@@ -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
diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh
index e469ff87..8a3a703b 100644
--- a/src/hb-ot-layout-common.hh
+++ b/src/hb-ot-layout-common.hh
@@ -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
diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh
index b3651f93..1a96609d 100644
--- a/src/hb-ot-layout-gpos-table.hh
+++ b/src/hb-ot-layout-gpos-table.hh
@@ -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
diff --git a/src/hb-ot-math-table.hh b/src/hb-ot-math-table.hh
index 1b2d550a..87ebdc7d 100644
--- a/src/hb-ot-math-table.hh
+++ b/src/hb-ot-math-table.hh
@@ -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);
diff --git a/src/hb-ot-maxp-table.hh b/src/hb-ot-maxp-table.hh
index efcf593e..2572ad28 100644
--- a/src/hb-ot-maxp-table.hh
+++ b/src/hb-ot-maxp-table.hh
@@ -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);
};
diff --git a/src/hb-ot-name-table.hh b/src/hb-ot-name-table.hh
index c1e7adbd..bb49c2cb 100644
--- a/src/hb-ot-name-table.hh
+++ b/src/hb-ot-name-table.hh
@@ -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);
};
diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh
index d0265d05..29dc86fa 100644
--- a/src/hb-ot-post-table.hh
+++ b/src/hb-ot-post-table.hh
@@ -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);
commit 9507b05a7a65962d5d02eb424e4f5d8570976f4e
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Sep 10 23:18:07 2018 +0200
Simplify sanitize->check_array()
Fix a bug in CBDT sanitize, and redundant check in avar.
diff --git a/src/hb-aat-layout-common.hh b/src/hb-aat-layout-common.hh
index 25f4fe14..85c40a71 100644
--- a/src/hb-aat-layout-common.hh
+++ b/src/hb-aat-layout-common.hh
@@ -129,7 +129,7 @@ struct BinSearchArrayOf
TRACE_SANITIZE (this);
return_trace (header.sanitize (c) &&
Type::static_size >= header.unitSize &&
- c->check_array (bytesZ, header.unitSize, header.nUnits));
+ c->check_array (bytesZ, header.nUnits, header.unitSize));
}
protected:
@@ -480,8 +480,8 @@ struct StateTable
while (state < num_states)
{
if (unlikely (!c->check_array (states,
- states[0].static_size * nClasses,
- num_states)))
+ num_states,
+ states[0].static_size * nClasses)))
return_trace (false);
{ /* Sweep new states. */
const HBUINT16 *stop = &states[num_states * nClasses];
@@ -490,9 +490,7 @@ struct StateTable
state = num_states;
}
- if (unlikely (!c->check_array (entries,
- entries[0].static_size,
- num_entries)))
+ if (unlikely (!c->check_array (entries, num_entries)))
return_trace (false);
{ /* Sweep new entries. */
const Entry<Extra> *stop = &entries[num_entries];
diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh
index ef452e22..6f7bf770 100644
--- a/src/hb-aat-layout-morx-table.hh
+++ b/src/hb-aat-layout-morx-table.hh
@@ -648,7 +648,7 @@ struct Chain
!c->check_range (this, length))
return_trace (false);
- if (!c->check_array (featureZ, featureZ[0].static_size, featureCount))
+ if (!c->check_array (featureZ, featureCount))
return_trace (false);
const ChainSubtable *subtable = &StructAtOffset<ChainSubtable> (featureZ, featureZ[0].static_size * featureCount);
diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh
index 62f49072..f80cfdb2 100644
--- a/src/hb-machinery.hh
+++ b/src/hb-machinery.hh
@@ -296,7 +296,8 @@ struct hb_sanitize_context_t :
return likely (ok);
}
- inline bool check_array (const void *base, unsigned int record_size, unsigned int len) const
+ template <typename T>
+ inline bool check_array (const T *base, unsigned int len, unsigned int record_size = T::static_size) const
{
const char *p = (const char *) base;
bool overflows = hb_unsigned_mul_overflows (len, record_size);
diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh
index ef18163f..49e52c6e 100644
--- a/src/hb-open-type.hh
+++ b/src/hb-open-type.hh
@@ -345,7 +345,7 @@ struct UnsizedArrayOf
inline bool sanitize_shallow (hb_sanitize_context_t *c, unsigned int count) const
{
TRACE_SANITIZE (this);
- return_trace (c->check_array (arrayZ, arrayZ[0].static_size, count));
+ return_trace (c->check_array (arrayZ, count));
}
public:
@@ -487,7 +487,7 @@ struct ArrayOf
inline bool sanitize_shallow (hb_sanitize_context_t *c) const
{
TRACE_SANITIZE (this);
- return_trace (len.sanitize (c) && c->check_array (arrayZ, Type::static_size, len));
+ return_trace (len.sanitize (c) && c->check_array (arrayZ, len));
}
public:
@@ -596,7 +596,7 @@ struct HeadlessArrayOf
{
TRACE_SANITIZE (this);
return_trace (len.sanitize (c) &&
- (!len || c->check_array (arrayZ, Type::static_size, len - 1)));
+ (!len || c->check_array (arrayZ, len - 1)));
}
public:
diff --git a/src/hb-ot-color-cbdt-table.hh b/src/hb-ot-color-cbdt-table.hh
index 8bedf222..a5636975 100644
--- a/src/hb-ot-color-cbdt-table.hh
+++ b/src/hb-ot-color-cbdt-table.hh
@@ -128,7 +128,7 @@ struct IndexSubtableFormat1Or3
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) &&
- c->check_array (offsetArrayZ, offsetArrayZ[0].static_size, glyph_count + 1));
+ c->check_array (offsetArrayZ, glyph_count + 1));
}
bool get_image_data (unsigned int idx,
@@ -240,7 +240,7 @@ struct IndexSubtableArray
inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const
{
TRACE_SANITIZE (this);
- if (unlikely (!c->check_array (&indexSubtablesZ, indexSubtablesZ[0].static_size, count)))
+ if (unlikely (!c->check_array (indexSubtablesZ, count)))
return_trace (false);
for (unsigned int i = 0; i < count; i++)
if (unlikely (!indexSubtablesZ[i].sanitize (c, this)))
diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh
index 40f94be2..e9f109c3 100644
--- a/src/hb-ot-kern-table.hh
+++ b/src/hb-ot-kern-table.hh
@@ -208,7 +208,7 @@ struct KernSubTableWrapper
TRACE_SANITIZE (this);
return_trace (c->check_struct (thiz()) &&
thiz()->length >= T::min_size &&
- c->check_array (thiz(), 1, thiz()->length) &&
+ c->check_array (thiz(), thiz()->length, 1) &&
thiz()->subtable.sanitize (c, thiz()->format));
}
};
diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh
index dd65f338..e469ff87 100644
--- a/src/hb-ot-layout-common.hh
+++ b/src/hb-ot-layout-common.hh
@@ -1542,7 +1542,7 @@ struct VarData
regionIndices.sanitize(c) &&
shortCount <= regionIndices.len &&
c->check_array (&StructAfter<HBUINT8> (regionIndices),
- get_row_size (), itemCount));
+ itemCount, get_row_size ()));
}
protected:
diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh
index 5847306d..b3651f93 100644
--- a/src/hb-ot-layout-gpos-table.hh
+++ b/src/hb-ot-layout-gpos-table.hh
@@ -199,7 +199,7 @@ struct ValueFormat : HBUINT16
TRACE_SANITIZE (this);
unsigned int len = get_len ();
- if (!c->check_array (values, get_size (), count)) return_trace (false);
+ if (!c->check_array (values, count, get_size ())) return_trace (false);
if (!has_device ()) return_trace (true);
@@ -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, matrixZ[0].static_size, count)) return_trace (false);
+ if (!c->check_array (matrixZ, count)) return_trace (false);
for (unsigned int i = 0; i < count; i++)
if (!matrixZ[i].sanitize (c, this)) return_trace (false);
return_trace (true);
@@ -698,7 +698,7 @@ struct PairSet
{
TRACE_SANITIZE (this);
if (!(c->check_struct (this)
- && c->check_array (arrayZ, HBUINT16::static_size * closure->stride, len))) return_trace (false);
+ && c->check_array (arrayZ, len, HBUINT16::static_size * closure->stride))) return_trace (false);
unsigned int count = len;
const PairValueRecord *record = CastP<PairValueRecord> (arrayZ);
@@ -869,7 +869,7 @@ struct PairPosFormat2
unsigned int stride = len1 + len2;
unsigned int record_size = valueFormat1.get_size () + valueFormat2.get_size ();
unsigned int count = (unsigned int) class1Count * (unsigned int) class2Count;
- return_trace (c->check_array (values, record_size, count) &&
+ return_trace (c->check_array (values, count, record_size) &&
valueFormat1.sanitize_values_stride_unsafe (c, this, &values[0], count, stride) &&
valueFormat2.sanitize_values_stride_unsafe (c, this, &values[len1], count, stride));
}
diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh
index d4755655..719a5050 100644
--- a/src/hb-ot-layout-gsubgpos.hh
+++ b/src/hb-ot-layout-gsubgpos.hh
@@ -1677,11 +1677,11 @@ struct ContextFormat3
if (!c->check_struct (this)) return_trace (false);
unsigned int count = glyphCount;
if (!count) return_trace (false); /* We want to access coverageZ[0] freely. */
- if (!c->check_array (coverageZ.arrayZ, coverageZ[0].static_size, count)) return_trace (false);
+ if (!c->check_array (coverageZ.arrayZ, count)) return_trace (false);
for (unsigned int i = 0; i < count; i++)
if (!coverageZ[i].sanitize (c, this)) return_trace (false);
const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ.arrayZ, coverageZ[0].static_size * count);
- return_trace (c->check_array (lookupRecord, lookupRecord[0].static_size, lookupCount));
+ return_trace (c->check_array (lookupRecord, lookupCount));
}
protected:
diff --git a/src/hb-ot-math-table.hh b/src/hb-ot-math-table.hh
index b7ca167b..1b2d550a 100644
--- a/src/hb-ot-math-table.hh
+++ b/src/hb-ot-math-table.hh
@@ -242,9 +242,7 @@ struct MathKern
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) &&
- c->check_array (mathValueRecords,
- mathValueRecords[0].static_size,
- 2 * heightCount + 1) &&
+ c->check_array (mathValueRecords, 2 * heightCount + 1) &&
sanitize_math_value_records (c));
}
@@ -598,9 +596,7 @@ struct MathVariants
return_trace (c->check_struct (this) &&
vertGlyphCoverage.sanitize (c, this) &&
horizGlyphCoverage.sanitize (c, this) &&
- c->check_array (glyphConstruction,
- glyphConstruction[0].static_size,
- vertGlyphCount + horizGlyphCount) &&
+ c->check_array (glyphConstruction, vertGlyphCount + horizGlyphCount) &&
sanitize_offsets (c));
}
diff --git a/src/hb-ot-name-table.hh b/src/hb-ot-name-table.hh
index a1de1193..c1e7adbd 100644
--- a/src/hb-ot-name-table.hh
+++ b/src/hb-ot-name-table.hh
@@ -118,7 +118,7 @@ struct name
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) &&
likely (format == 0 || format == 1) &&
- c->check_array (nameRecord, nameRecord[0].static_size, count) &&
+ c->check_array (nameRecord, count) &&
sanitize_records (c));
}
diff --git a/src/hb-ot-var-avar-table.hh b/src/hb-ot-var-avar-table.hh
index 5428c97b..d100ca21 100644
--- a/src/hb-ot-var-avar-table.hh
+++ b/src/hb-ot-var-avar-table.hh
@@ -93,6 +93,7 @@ struct SegmentMaps : ArrayOf<AxisValueMap>
(value - arrayZ[i-1].fromCoord) + denom/2) / denom;
}
+ public:
DEFINE_SIZE_ARRAY (2, arrayZ);
};
@@ -105,8 +106,7 @@ struct avar
TRACE_SANITIZE (this);
if (unlikely (!(version.sanitize (c) &&
version.major == 1 &&
- c->check_struct (this),
- c->check_array(axisSegmentMapsZ.arrayZ, sizeof (axisSegmentMapsZ[0]), axisCount))))
+ c->check_struct (this))))
return_trace (false);
const SegmentMaps *map = axisSegmentMapsZ.arrayZ;
diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh
index 1a85b6e5..1d17a97e 100644
--- a/src/hb-ot-var-fvar-table.hh
+++ b/src/hb-ot-var-fvar-table.hh
@@ -46,7 +46,7 @@ struct InstanceRecord
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) &&
- c->check_array (coordinatesZ.arrayZ, coordinatesZ[0].static_size, axis_count));
+ c->check_array (coordinatesZ.arrayZ, axis_count));
}
protected:
diff --git a/src/hb-ot-var-hvar-table.hh b/src/hb-ot-var-hvar-table.hh
index 97300f42..d87285b7 100644
--- a/src/hb-ot-var-hvar-table.hh
+++ b/src/hb-ot-var-hvar-table.hh
@@ -39,7 +39,7 @@ struct DeltaSetIndexMap
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) &&
- c->check_array (mapDataZ.arrayZ, get_width (), mapCount));
+ c->check_array (mapDataZ.arrayZ, mapCount, get_width ()));
}
unsigned int map (unsigned int v) const /* Returns 16.16 outer.inner. */
diff --git a/src/hb-ot-var-mvar-table.hh b/src/hb-ot-var-mvar-table.hh
index d10c3e9d..d60c6b91 100644
--- a/src/hb-ot-var-mvar-table.hh
+++ b/src/hb-ot-var-mvar-table.hh
@@ -68,7 +68,7 @@ struct MVAR
c->check_struct (this) &&
valueRecordSize >= VariationValueRecord::static_size &&
varStore.sanitize (c, this) &&
- c->check_array (valuesZ.arrayZ, valueRecordSize, valueRecordCount));
+ c->check_array (valuesZ.arrayZ, valueRecordCount, valueRecordSize));
}
inline float get_var (hb_tag_t tag,
commit bc485a98122131efc4768fef9147823f2bce146b
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Sep 10 23:02:24 2018 +0200
Port some VAR arrays to UnsizedArrayOf<>
Fix avar sanitize().
diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh
index bd4611d2..d4755655 100644
--- a/src/hb-ot-layout-gsubgpos.hh
+++ b/src/hb-ot-layout-gsubgpos.hh
@@ -1222,42 +1222,42 @@ struct Rule
inline bool intersects (const hb_set_t *glyphs, ContextClosureLookupContext &lookup_context) const
{
return context_intersects (glyphs,
- inputCount, inputZ,
+ inputCount, inputZ.arrayZ,
lookup_context);
}
inline void closure (hb_closure_context_t *c, ContextClosureLookupContext &lookup_context) const
{
TRACE_CLOSURE (this);
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (inputZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0));
+ const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAtOffset<UnsizedArrayOf<LookupRecord> > (inputZ.arrayZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0));
context_closure_lookup (c,
- inputCount, inputZ,
- lookupCount, lookupRecord,
+ inputCount, inputZ.arrayZ,
+ lookupCount, lookupRecord.arrayZ,
lookup_context);
}
inline void collect_glyphs (hb_collect_glyphs_context_t *c, ContextCollectGlyphsLookupContext &lookup_context) const
{
TRACE_COLLECT_GLYPHS (this);
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (inputZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0));
+ const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAtOffset<UnsizedArrayOf<LookupRecord> > (inputZ.arrayZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0));
context_collect_glyphs_lookup (c,
- inputCount, inputZ,
- lookupCount, lookupRecord,
+ inputCount, inputZ.arrayZ,
+ lookupCount, lookupRecord.arrayZ,
lookup_context);
}
inline bool would_apply (hb_would_apply_context_t *c, ContextApplyLookupContext &lookup_context) const
{
TRACE_WOULD_APPLY (this);
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (inputZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0));
- return_trace (context_would_apply_lookup (c, inputCount, inputZ, lookupCount, lookupRecord, lookup_context));
+ const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAtOffset<UnsizedArrayOf<LookupRecord> > (inputZ.arrayZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0));
+ return_trace (context_would_apply_lookup (c, inputCount, inputZ.arrayZ, lookupCount, lookupRecord.arrayZ, lookup_context));
}
inline bool apply (hb_ot_apply_context_t *c, ContextApplyLookupContext &lookup_context) const
{
TRACE_APPLY (this);
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (inputZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0));
- return_trace (context_apply_lookup (c, inputCount, inputZ, lookupCount, lookupRecord, lookup_context));
+ const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAtOffset<UnsizedArrayOf<LookupRecord> > (inputZ.arrayZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0));
+ return_trace (context_apply_lookup (c, inputCount, inputZ.arrayZ, lookupCount, lookupRecord.arrayZ, lookup_context));
}
public:
@@ -1266,7 +1266,7 @@ struct Rule
TRACE_SANITIZE (this);
return_trace (inputCount.sanitize (c) &&
lookupCount.sanitize (c) &&
- c->check_range (inputZ,
+ c->check_range (inputZ.arrayZ,
inputZ[0].static_size * (inputCount ? inputCount - 1 : 0) +
LookupRecord::static_size * lookupCount));
}
@@ -1276,9 +1276,11 @@ struct Rule
* glyph sequence--includes the first
* glyph */
HBUINT16 lookupCount; /* Number of LookupRecords */
- HBUINT16 inputZ[VAR]; /* Array of match inputs--start with
+ UnsizedArrayOf<HBUINT16>
+ inputZ; /* Array of match inputs--start with
* second glyph */
-/*LookupRecord lookupRecordX[VAR];*/ /* Array of LookupRecords--in
+/*UnsizedArrayOf<LookupRecord>
+ lookupRecordX;*/ /* Array of LookupRecords--in
* design order */
public:
DEFINE_SIZE_ARRAY (4, inputZ);
@@ -1595,7 +1597,7 @@ struct ContextFormat3
this
};
return context_intersects (glyphs,
- glyphCount, (const HBUINT16 *) (coverageZ + 1),
+ glyphCount, (const HBUINT16 *) (coverageZ.arrayZ + 1),
lookup_context);
}
@@ -1605,13 +1607,13 @@ struct ContextFormat3
if (!(this+coverageZ[0]).intersects (c->glyphs))
return;
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ, coverageZ[0].static_size * glyphCount);
+ const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ.arrayZ, coverageZ[0].static_size * glyphCount);
struct ContextClosureLookupContext lookup_context = {
{intersects_coverage},
this
};
context_closure_lookup (c,
- glyphCount, (const HBUINT16 *) (coverageZ + 1),
+ glyphCount, (const HBUINT16 *) (coverageZ.arrayZ + 1),
lookupCount, lookupRecord,
lookup_context);
}
@@ -1621,14 +1623,14 @@ struct ContextFormat3
TRACE_COLLECT_GLYPHS (this);
(this+coverageZ[0]).add_coverage (c->input);
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ, coverageZ[0].static_size * glyphCount);
+ const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ.arrayZ, coverageZ[0].static_size * glyphCount);
struct ContextCollectGlyphsLookupContext lookup_context = {
{collect_coverage},
this
};
context_collect_glyphs_lookup (c,
- glyphCount, (const HBUINT16 *) (coverageZ + 1),
+ glyphCount, (const HBUINT16 *) (coverageZ.arrayZ + 1),
lookupCount, lookupRecord,
lookup_context);
}
@@ -1637,12 +1639,12 @@ struct ContextFormat3
{
TRACE_WOULD_APPLY (this);
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ, coverageZ[0].static_size * glyphCount);
+ const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ.arrayZ, coverageZ[0].static_size * glyphCount);
struct ContextApplyLookupContext lookup_context = {
{match_coverage},
this
};
- return_trace (context_would_apply_lookup (c, glyphCount, (const HBUINT16 *) (coverageZ + 1), lookupCount, lookupRecord, lookup_context));
+ return_trace (context_would_apply_lookup (c, glyphCount, (const HBUINT16 *) (coverageZ.arrayZ + 1), lookupCount, lookupRecord, lookup_context));
}
inline const Coverage &get_coverage (void) const
@@ -1654,12 +1656,12 @@ struct ContextFormat3
unsigned int index = (this+coverageZ[0]).get_coverage (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return_trace (false);
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ, coverageZ[0].static_size * glyphCount);
+ const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ.arrayZ, coverageZ[0].static_size * glyphCount);
struct ContextApplyLookupContext lookup_context = {
{match_coverage},
this
};
- return_trace (context_apply_lookup (c, glyphCount, (const HBUINT16 *) (coverageZ + 1), lookupCount, lookupRecord, lookup_context));
+ return_trace (context_apply_lookup (c, glyphCount, (const HBUINT16 *) (coverageZ.arrayZ + 1), lookupCount, lookupRecord, lookup_context));
}
inline bool subset (hb_subset_context_t *c) const
@@ -1675,10 +1677,10 @@ struct ContextFormat3
if (!c->check_struct (this)) return_trace (false);
unsigned int count = glyphCount;
if (!count) return_trace (false); /* We want to access coverageZ[0] freely. */
- if (!c->check_array (coverageZ, coverageZ[0].static_size, count)) return_trace (false);
+ if (!c->check_array (coverageZ.arrayZ, coverageZ[0].static_size, count)) return_trace (false);
for (unsigned int i = 0; i < count; i++)
if (!coverageZ[i].sanitize (c, this)) return_trace (false);
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ, coverageZ[0].static_size * count);
+ const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ.arrayZ, coverageZ[0].static_size * count);
return_trace (c->check_array (lookupRecord, lookupRecord[0].static_size, lookupCount));
}
@@ -1687,10 +1689,11 @@ struct ContextFormat3
HBUINT16 glyphCount; /* Number of glyphs in the input glyph
* sequence */
HBUINT16 lookupCount; /* Number of LookupRecords */
- OffsetTo<Coverage>
- coverageZ[VAR]; /* Array of offsets to Coverage
+ UnsizedArrayOf<OffsetTo<Coverage> >
+ coverageZ; /* Array of offsets to Coverage
* table in glyph sequence order */
-/*LookupRecord lookupRecordX[VAR];*/ /* Array of LookupRecords--in
+/*UnsizedArrayOf<LookupRecord>
+ lookupRecordX;*/ /* Array of LookupRecords--in
* design order */
public:
DEFINE_SIZE_ARRAY (6, coverageZ);
diff --git a/src/hb-ot-var-avar-table.hh b/src/hb-ot-var-avar-table.hh
index 8343018b..5428c97b 100644
--- a/src/hb-ot-var-avar-table.hh
+++ b/src/hb-ot-var-avar-table.hh
@@ -105,10 +105,11 @@ struct avar
TRACE_SANITIZE (this);
if (unlikely (!(version.sanitize (c) &&
version.major == 1 &&
- c->check_struct (this))))
+ c->check_struct (this),
+ c->check_array(axisSegmentMapsZ.arrayZ, sizeof (axisSegmentMapsZ[0]), axisCount))))
return_trace (false);
- const SegmentMaps *map = axisSegmentMapsZ;
+ const SegmentMaps *map = axisSegmentMapsZ.arrayZ;
unsigned int count = axisCount;
for (unsigned int i = 0; i < count; i++)
{
@@ -124,7 +125,7 @@ struct avar
{
unsigned int count = MIN<unsigned int> (coords_length, axisCount);
- const SegmentMaps *map = axisSegmentMapsZ;
+ const SegmentMaps *map = axisSegmentMapsZ.arrayZ;
for (unsigned int i = 0; i < count; i++)
{
coords[i] = map->map (coords[i]);
@@ -139,7 +140,8 @@ struct avar
HBUINT16 axisCount; /* The number of variation axes in the font. This
* must be the same number as axisCount in the
* 'fvar' table. */
- SegmentMaps axisSegmentMapsZ[VAR];
+ UnsizedArrayOf<SegmentMaps>
+ axisSegmentMapsZ;
public:
DEFINE_SIZE_MIN (8);
diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh
index afd29046..1a85b6e5 100644
--- a/src/hb-ot-var-fvar-table.hh
+++ b/src/hb-ot-var-fvar-table.hh
@@ -46,20 +46,21 @@ struct InstanceRecord
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) &&
- c->check_array (coordinates, coordinates[0].static_size, axis_count));
+ c->check_array (coordinatesZ.arrayZ, coordinatesZ[0].static_size, axis_count));
}
protected:
NameID subfamilyNameID;/* The name ID for entries in the 'name' table
* that provide subfamily names for this instance. */
HBUINT16 reserved; /* Reserved for future use — set to 0. */
- Fixed coordinates[VAR];/* The coordinates array for this instance. */
+ UnsizedArrayOf<Fixed>
+ coordinatesZ; /* The coordinates array for this instance. */
//NameID postScriptNameIDX;/*Optional. The name ID for entries in the 'name'
// * table that provide PostScript names for this
// * instance. */
public:
- DEFINE_SIZE_ARRAY (4, coordinates);
+ DEFINE_SIZE_ARRAY (4, coordinatesZ);
};
struct AxisRecord
diff --git a/src/hb-ot-var-hvar-table.hh b/src/hb-ot-var-hvar-table.hh
index 086e922f..97300f42 100644
--- a/src/hb-ot-var-hvar-table.hh
+++ b/src/hb-ot-var-hvar-table.hh
@@ -39,7 +39,7 @@ struct DeltaSetIndexMap
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) &&
- c->check_array (mapData, get_width (), mapCount));
+ c->check_array (mapDataZ.arrayZ, get_width (), mapCount));
}
unsigned int map (unsigned int v) const /* Returns 16.16 outer.inner. */
@@ -55,7 +55,7 @@ struct DeltaSetIndexMap
unsigned int u = 0;
{ /* Fetch it. */
unsigned int w = get_width ();
- const HBUINT8 *p = mapData + w * v;
+ const HBUINT8 *p = mapDataZ.arrayZ + w * v;
for (; w; w--)
u = (u << 8) + *p++;
}
@@ -81,10 +81,11 @@ struct DeltaSetIndexMap
HBUINT16 format; /* A packed field that describes the compressed
* representation of delta-set indices. */
HBUINT16 mapCount; /* The number of mapping entries. */
- HBUINT8 mapData[VAR]; /* The delta-set index mapping data. */
+ UnsizedArrayOf<HBUINT8>
+ mapDataZ; /* The delta-set index mapping data. */
public:
- DEFINE_SIZE_ARRAY (4, mapData);
+ DEFINE_SIZE_ARRAY (4, mapDataZ);
};
diff --git a/src/hb-ot-var-mvar-table.hh b/src/hb-ot-var-mvar-table.hh
index 20dd2200..d10c3e9d 100644
--- a/src/hb-ot-var-mvar-table.hh
+++ b/src/hb-ot-var-mvar-table.hh
@@ -68,14 +68,14 @@ struct MVAR
c->check_struct (this) &&
valueRecordSize >= VariationValueRecord::static_size &&
varStore.sanitize (c, this) &&
- c->check_array (values, valueRecordSize, valueRecordCount));
+ c->check_array (valuesZ.arrayZ, valueRecordSize, valueRecordCount));
}
inline float get_var (hb_tag_t tag,
int *coords, unsigned int coord_count) const
{
const VariationValueRecord *record;
- record = (VariationValueRecord *) bsearch (&tag, values,
+ record = (VariationValueRecord *) bsearch (&tag, valuesZ.arrayZ,
valueRecordCount, valueRecordSize,
tag_compare);
if (!record)
@@ -101,11 +101,12 @@ protected:
HBUINT16 valueRecordCount;/* The number of value records — may be zero. */
OffsetTo<VariationStore>
varStore; /* Offset to item variation store table. */
- HBUINT8 values[VAR]; /* Array of value records. The records must be
+ UnsizedArrayOf<HBUINT8>
+ valuesZ; /* Array of value records. The records must be
* in binary order of their valueTag field. */
public:
- DEFINE_SIZE_ARRAY (12, values);
+ DEFINE_SIZE_ARRAY (12, valuesZ);
};
} /* namespace OT */
More information about the HarfBuzz
mailing list