Add SortedArray{16,32}Of<>

This commit is contained in:
Behdad Esfahbod 2021-03-31 16:09:39 -06:00
parent 5639e253f9
commit 4dba749d83
7 changed files with 20 additions and 17 deletions

View File

@ -891,7 +891,7 @@ struct ArrayOfM1
};
/* An array with sorted elements. Supports binary searching. */
template <typename Type, typename LenType=HBUINT16>
template <typename Type, typename LenType>
struct SortedArrayOf : ArrayOf<Type, LenType>
{
hb_sorted_array_t< Type> as_array () { return hb_sorted_array (this->arrayZ, this->len); }
@ -942,6 +942,9 @@ struct SortedArrayOf : ArrayOf<Type, LenType>
{ return as_array ().bfind (x, i, not_found, to_store); }
};
template <typename Type> using SortedArray16Of = SortedArrayOf<Type, HBUINT16>;
template <typename Type> using SortedArray32Of = SortedArrayOf<Type, HBUINT32>;
/*
* Binary-search arrays
*/

View File

@ -672,7 +672,7 @@ struct CmapSubtableLongSegmented
HBUINT16 reserved; /* Reserved; set to 0. */
HBUINT32 length; /* Byte length of this subtable. */
HBUINT32 language; /* Ignore. */
SortedArrayOf<CmapSubtableLongGroup, HBUINT32>
SortedArray32Of<CmapSubtableLongGroup>
groups; /* Groupings. */
public:
DEFINE_SIZE_ARRAY (16, groups);
@ -786,7 +786,7 @@ struct UnicodeValueRange
DEFINE_SIZE_STATIC (4);
};
struct DefaultUVS : SortedArrayOf<UnicodeValueRange, HBUINT32>
struct DefaultUVS : SortedArray32Of<UnicodeValueRange>
{
void collect_unicodes (hb_set_t *out) const
{
@ -880,7 +880,7 @@ struct UVSMapping
DEFINE_SIZE_STATIC (5);
};
struct NonDefaultUVS : SortedArrayOf<UVSMapping, HBUINT32>
struct NonDefaultUVS : SortedArray32Of<UVSMapping>
{
void collect_unicodes (hb_set_t *out) const
{
@ -1186,7 +1186,7 @@ struct CmapSubtableFormat14
protected:
HBUINT16 format; /* Format number is set to 14. */
HBUINT32 length; /* Byte length of this subtable. */
SortedArrayOf<VariationSelectorRecord, HBUINT32>
SortedArray32Of<VariationSelectorRecord>
record; /* Variation selector records; sorted
* in increasing order of `varSelector'. */
public:
@ -1705,7 +1705,7 @@ struct cmap
protected:
HBUINT16 version; /* Table version number (0). */
SortedArrayOf<EncodingRecord>
SortedArray16Of<EncodingRecord>
encodingRecord; /* Encoding tables. */
public:
DEFINE_SIZE_ARRAY (4, encodingRecord);

View File

@ -107,7 +107,7 @@ struct SVG
protected:
HBUINT16 version; /* Table version (starting at 0). */
Offset32To<SortedArrayOf<SVGDocumentIndexEntry>>
Offset32To<SortedArray16Of<SVGDocumentIndexEntry>>
svgDocEntries; /* Offset (relative to the start of the SVG table) to the
* SVG Documents Index. Must be non-zero. */
/* Array of SVG Document Index Entries. */

View File

@ -220,7 +220,7 @@ struct MinMax
maxCoord; /* Offset to BaseCoord table that defines
* maximum extent value, from the beginning
* of MinMax table (may be NULL) */
SortedArrayOf<FeatMinMaxRecord>
SortedArray16Of<FeatMinMaxRecord>
featMinMaxRecords;
/* Array of FeatMinMaxRecords, in alphabetical
* order by featureTableTag */
@ -311,7 +311,7 @@ struct BaseScript
Offset16To<MinMax>
defaultMinMax; /* Offset to MinMax table, from beginning of
* BaseScript table (may be NULL) */
SortedArrayOf<BaseLangSysRecord>
SortedArray16Of<BaseLangSysRecord>
baseLangSysRecords;
/* Number of BaseLangSysRecords
* defined may be zero (0) */
@ -364,7 +364,7 @@ struct BaseScriptList
}
protected:
SortedArrayOf<BaseScriptRecord>
SortedArray16Of<BaseScriptRecord>
baseScriptRecords;
public:
@ -426,7 +426,7 @@ struct Axis
}
protected:
Offset16To<SortedArrayOf<Tag>>
Offset16To<SortedArray16Of<Tag>>
baseTagList; /* Offset to BaseTagList table, from beginning
* of Axis table (may be NULL)
* Array of 4-byte baseline identification tags must

View File

@ -392,7 +392,7 @@ struct Record
};
template <typename Type>
struct RecordArrayOf : SortedArrayOf<Record<Type>>
struct RecordArrayOf : SortedArray16Of<Record<Type>>
{
const Offset16To<Type>& get_offset (unsigned int i) const
{ return (*this)[i].offset; }
@ -1447,7 +1447,7 @@ struct CoverageFormat1
protected:
HBUINT16 coverageFormat; /* Format identifier--format = 1 */
SortedArrayOf<HBGlyphID>
SortedArray16Of<HBGlyphID>
glyphArray; /* Array of GlyphIDs--in numerical order */
public:
DEFINE_SIZE_ARRAY (4, glyphArray);
@ -1623,7 +1623,7 @@ struct CoverageFormat2
protected:
HBUINT16 coverageFormat; /* Format identifier--format = 2 */
SortedArrayOf<RangeRecord>
SortedArray16Of<RangeRecord>
rangeRecord; /* Array of glyph ranges--ordered by
* Start GlyphID. rangeCount entries
* long */
@ -2274,7 +2274,7 @@ struct ClassDefFormat2
protected:
HBUINT16 classFormat; /* Format identifier--format = 2 */
SortedArrayOf<RangeRecord>
SortedArray16Of<RangeRecord>
rangeRecord; /* Array of glyph ranges--ordered by
* Start GlyphID */
public:

View File

@ -136,7 +136,7 @@ struct JstfLangSys : List16OfOffset16To<JstfPriority>
* ExtenderGlyphs -- Extender Glyph Table
*/
typedef SortedArrayOf<HBGlyphID> ExtenderGlyphs;
typedef SortedArray16Of<HBGlyphID> ExtenderGlyphs;
/*

View File

@ -125,7 +125,7 @@ struct VORG
FixedVersion<>version; /* Version of VORG table. Set to 0x00010000u. */
FWORD defaultVertOriginY;
/* The default vertical origin. */
SortedArrayOf<VertOriginMetric>
SortedArray16Of<VertOriginMetric>
vertYOrigins; /* The array of vertical origins. */
public: