Add LOffsetTo<>

This commit is contained in:
Behdad Esfahbod 2017-01-22 20:28:56 -08:00
parent d6bdbbca30
commit 5e156fa5ed
7 changed files with 15 additions and 14 deletions

View File

@ -142,7 +142,7 @@ struct TTCHeaderVersion1
Tag ttcTag; /* TrueType Collection ID string: 'ttcf' */ Tag ttcTag; /* TrueType Collection ID string: 'ttcf' */
FixedVersion<>version; /* Version of the TTC Header (1.0), FixedVersion<>version; /* Version of the TTC Header (1.0),
* 0x00010000u */ * 0x00010000u */
ArrayOf<OffsetTo<OffsetTable, ULONG>, ULONG> ArrayOf<LOffsetTo<OffsetTable>, ULONG>
table; /* Array of offsets to the OffsetTable for each font table; /* Array of offsets to the OffsetTable for each font
* from the beginning of the file */ * from the beginning of the file */
public: public:

View File

@ -830,6 +830,7 @@ struct OffsetTo : Offset<OffsetType>
} }
DEFINE_SIZE_STATIC (sizeof(OffsetType)); DEFINE_SIZE_STATIC (sizeof(OffsetType));
}; };
template <typename Type> struct LOffsetTo : OffsetTo<Type, ULONG> {};
template <typename Base, typename OffsetType, typename Type> template <typename Base, typename OffsetType, typename Type>
static inline const Type& operator + (const Base &base, const OffsetTo<Type, OffsetType> &offset) { return offset (base); } static inline const Type& operator + (const Base &base, const OffsetTo<Type, OffsetType> &offset) { return offset (base); }
template <typename Base, typename OffsetType, typename Type> template <typename Base, typename OffsetType, typename Type>

View File

@ -216,7 +216,7 @@ struct IndexSubtableRecord
USHORT firstGlyphIndex; USHORT firstGlyphIndex;
USHORT lastGlyphIndex; USHORT lastGlyphIndex;
OffsetTo<IndexSubtable, ULONG> offsetToSubtable; LOffsetTo<IndexSubtable> offsetToSubtable;
DEFINE_SIZE_STATIC(8); DEFINE_SIZE_STATIC(8);
}; };
@ -275,7 +275,7 @@ struct BitmapSizeTable
} }
protected: protected:
OffsetTo<IndexSubtableArray, ULONG> indexSubtableArrayOffset; LOffsetTo<IndexSubtableArray> indexSubtableArrayOffset;
ULONG indexTablesSize; ULONG indexTablesSize;
ULONG numberOfIndexSubtables; ULONG numberOfIndexSubtables;
ULONG colorRef; ULONG colorRef;

View File

@ -380,9 +380,9 @@ struct VariationSelectorRecord
} }
UINT24 varSelector; /* Variation selector. */ UINT24 varSelector; /* Variation selector. */
OffsetTo<DefaultUVS, ULONG> LOffsetTo<DefaultUVS>
defaultUVS; /* Offset to Default UVS Table. May be 0. */ defaultUVS; /* Offset to Default UVS Table. May be 0. */
OffsetTo<NonDefaultUVS, ULONG> LOffsetTo<NonDefaultUVS>
nonDefaultUVS; /* Offset to Non-Default UVS Table. May be 0. */ nonDefaultUVS; /* Offset to Non-Default UVS Table. May be 0. */
public: public:
DEFINE_SIZE_STATIC (11); DEFINE_SIZE_STATIC (11);
@ -486,7 +486,7 @@ struct EncodingRecord
USHORT platformID; /* Platform ID. */ USHORT platformID; /* Platform ID. */
USHORT encodingID; /* Platform-specific encoding ID. */ USHORT encodingID; /* Platform-specific encoding ID. */
OffsetTo<CmapSubtable, ULONG> LOffsetTo<CmapSubtable>
subtable; /* Byte offset from beginning of table to the subtable for this encoding. */ subtable; /* Byte offset from beginning of table to the subtable for this encoding. */
public: public:
DEFINE_SIZE_STATIC (8); DEFINE_SIZE_STATIC (8);

View File

@ -1334,7 +1334,7 @@ struct VariationStore
protected: protected:
USHORT format; USHORT format;
OffsetTo<VarRegionList, ULONG> regions; LOffsetTo<VarRegionList> regions;
OffsetArrayOf<VarData, ULONG> dataSets; OffsetArrayOf<VarData, ULONG> dataSets;
public: public:
DEFINE_SIZE_ARRAY (8, dataSets); DEFINE_SIZE_ARRAY (8, dataSets);
@ -1434,7 +1434,7 @@ struct FeatureTableSubstitutionRecord
protected: protected:
USHORT featureIndex; USHORT featureIndex;
OffsetTo<Feature, ULONG> feature; LOffsetTo<Feature> feature;
public: public:
DEFINE_SIZE_STATIC (6); DEFINE_SIZE_STATIC (6);
}; };
@ -1481,9 +1481,9 @@ struct FeatureVariationRecord
} }
protected: protected:
OffsetTo<ConditionSet, ULONG> LOffsetTo<ConditionSet>
conditions; conditions;
OffsetTo<FeatureTableSubstitution, ULONG> LOffsetTo<FeatureTableSubstitution>
substitutions; substitutions;
public: public:
DEFINE_SIZE_STATIC (8); DEFINE_SIZE_STATIC (8);

View File

@ -295,7 +295,7 @@ struct MarkGlyphSetsFormat1
protected: protected:
USHORT format; /* Format identifier--format = 1 */ USHORT format; /* Format identifier--format = 1 */
ArrayOf<OffsetTo<Coverage, ULONG> > ArrayOf<LOffsetTo<Coverage> >
coverage; /* Array of long offsets to mark set coverage; /* Array of long offsets to mark set
* coverage tables */ * coverage tables */
public: public:
@ -443,7 +443,7 @@ struct GDEF
* definitions--from beginning of GDEF * definitions--from beginning of GDEF
* header (may be NULL). Introduced * header (may be NULL). Introduced
* in version 0x00010002. */ * in version 0x00010002. */
OffsetTo<VariationStore, ULONG> LOffsetTo<VariationStore>
varStore; /* Offset to the table of Item Variation varStore; /* Offset to the table of Item Variation
* Store--from beginning of GDEF * Store--from beginning of GDEF
* header (may be NULL). Introduced * header (may be NULL). Introduced

View File

@ -2313,7 +2313,7 @@ struct GSUBGPOS
featureList; /* FeatureList table */ featureList; /* FeatureList table */
OffsetTo<LookupList> OffsetTo<LookupList>
lookupList; /* LookupList table */ lookupList; /* LookupList table */
OffsetTo<FeatureVariations, ULONG> LOffsetTo<FeatureVariations>
featureVars; /* Offset to Feature Variations featureVars; /* Offset to Feature Variations
table--from beginning of table table--from beginning of table
* (may be NULL). Introduced * (may be NULL). Introduced