From 9a13ed453ef96822a47d6e6f58332b87f38d5c59 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 22 Feb 2016 11:44:45 +0900 Subject: [PATCH] Make FixedVersion a template --- src/hb-open-file-private.hh | 4 ++-- src/hb-open-type-private.hh | 9 +++++---- src/hb-ot-head-table.hh | 4 ++-- src/hb-ot-hhea-table.hh | 2 +- src/hb-ot-layout-gdef-table.hh | 2 +- src/hb-ot-layout-gsubgpos-private.hh | 2 +- src/hb-ot-layout-jstf-table.hh | 2 +- src/hb-ot-maxp-table.hh | 2 +- 8 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh index 152230a..5357ddc 100644 --- a/src/hb-open-file-private.hh +++ b/src/hb-open-file-private.hh @@ -140,7 +140,7 @@ struct TTCHeaderVersion1 protected: 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 */ ArrayOf, ULONG> table; /* Array of offsets to the OffsetTable for each font @@ -187,7 +187,7 @@ struct TTCHeader union { struct { Tag ttcTag; /* TrueType Collection ID string: 'ttcf' */ - FixedVersion version; /* Version of the TTC Header (1.0 or 2.0), + FixedVersion<>version; /* Version of the TTC Header (1.0 or 2.0), * 0x00010000u or 0x00020000u */ } header; TTCHeaderVersion1 version1; diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index 6323da8..6a52000 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -739,9 +739,10 @@ struct CheckSum : ULONG * Version Numbers */ +template struct FixedVersion { - inline uint32_t to_int (void) const { return (major << 16) + minor; } + inline uint32_t to_int (void) const { return (major << sizeof(FixedType)) + minor; } inline bool sanitize (hb_sanitize_context_t *c) const { @@ -749,10 +750,10 @@ struct FixedVersion return_trace (c->check_struct (this)); } - USHORT major; - USHORT minor; + FixedType major; + FixedType minor; public: - DEFINE_SIZE_STATIC (4); + DEFINE_SIZE_STATIC (2 * sizeof(FixedType)); }; diff --git a/src/hb-ot-head-table.hh b/src/hb-ot-head-table.hh index 60644be..9c3e51e 100644 --- a/src/hb-ot-head-table.hh +++ b/src/hb-ot-head-table.hh @@ -61,9 +61,9 @@ struct head } protected: - FixedVersion version; /* Version of the head table--currently + FixedVersion<>version; /* Version of the head table--currently * 0x00010000u for version 1.0. */ - FixedVersion fontRevision; /* Set by font manufacturer. */ + FixedVersion<>fontRevision; /* Set by font manufacturer. */ ULONG checkSumAdjustment; /* To compute: set it to 0, sum the * entire font as ULONG, then store * 0xB1B0AFBAu - sum. */ diff --git a/src/hb-ot-hhea-table.hh b/src/hb-ot-hhea-table.hh index 2411453..c8e9536 100644 --- a/src/hb-ot-hhea-table.hh +++ b/src/hb-ot-hhea-table.hh @@ -56,7 +56,7 @@ struct _hea } public: - FixedVersion version; /* 0x00010000u for version 1.0. */ + FixedVersion<>version; /* 0x00010000u for version 1.0. */ FWORD ascender; /* Typographic ascent. */ FWORD descender; /* Typographic descent. */ FWORD lineGap; /* Typographic line gap. */ diff --git a/src/hb-ot-layout-gdef-table.hh b/src/hb-ot-layout-gdef-table.hh index bc36436..2b4bc5a 100644 --- a/src/hb-ot-layout-gdef-table.hh +++ b/src/hb-ot-layout-gdef-table.hh @@ -409,7 +409,7 @@ struct GDEF protected: - FixedVersion version; /* Version of the GDEF table--currently + FixedVersion<>version; /* Version of the GDEF table--currently * 0x00010002u */ OffsetTo glyphClassDef; /* Offset to class definition table diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh index 3f9d9ca..691334c 100644 --- a/src/hb-ot-layout-gsubgpos-private.hh +++ b/src/hb-ot-layout-gsubgpos-private.hh @@ -2277,7 +2277,7 @@ struct GSUBGPOS } protected: - FixedVersion version; /* Version of the GSUB/GPOS table--initially set + FixedVersion<>version; /* Version of the GSUB/GPOS table--initially set * to 0x00010000u */ OffsetTo scriptList; /* ScriptList table */ diff --git a/src/hb-ot-layout-jstf-table.hh b/src/hb-ot-layout-jstf-table.hh index 7e199c2..c306849 100644 --- a/src/hb-ot-layout-jstf-table.hh +++ b/src/hb-ot-layout-jstf-table.hh @@ -218,7 +218,7 @@ struct JSTF } protected: - FixedVersion version; /* Version of the JSTF table--initially set + FixedVersion<>version; /* Version of the JSTF table--initially set * to 0x00010000u */ RecordArrayOf scriptList; /* Array of JstfScripts--listed diff --git a/src/hb-ot-maxp-table.hh b/src/hb-ot-maxp-table.hh index 27105af..943e390 100644 --- a/src/hb-ot-maxp-table.hh +++ b/src/hb-ot-maxp-table.hh @@ -58,7 +58,7 @@ struct maxp /* We only implement version 0.5 as none of the extra fields in version 1.0 are useful. */ protected: - FixedVersion version; /* Version of the maxp table (0.5 or 1.0), + FixedVersion<>version; /* Version of the maxp table (0.5 or 1.0), * 0x00005000u or 0x00010000u. */ USHORT numGlyphs; /* The number of glyphs in the font. */ public: -- 2.7.4