diff --git a/src/OT/Layout/Common/CoverageFormat1.hh b/src/OT/Layout/Common/CoverageFormat1.hh index 823e45073..ee9425ec2 100644 --- a/src/OT/Layout/Common/CoverageFormat1.hh +++ b/src/OT/Layout/Common/CoverageFormat1.hh @@ -43,10 +43,10 @@ struct CoverageFormat1_3 public: HBUINT16 coverageFormat; /* Format identifier--format = 1 */ - SortedArray16Of + typename Types::template SortedArrayOf glyphArray; /* Array of GlyphIDs--in numerical order */ - DEFINE_SIZE_ARRAY (4, glyphArray); + DEFINE_SIZE_ARRAY (2 + Types::HBUINT::static_size, glyphArray); private: bool sanitize (hb_sanitize_context_t *c) const diff --git a/src/OT/Layout/Common/CoverageFormat2.hh b/src/OT/Layout/Common/CoverageFormat2.hh index 19895cabb..10f979d14 100644 --- a/src/OT/Layout/Common/CoverageFormat2.hh +++ b/src/OT/Layout/Common/CoverageFormat2.hh @@ -39,15 +39,16 @@ template struct CoverageFormat2_4 { friend struct Coverage; + using CoverageRangeRecord = RangeRecord; public: HBUINT16 coverageFormat; /* Format identifier--format = 2 */ - SortedArray16Of> + typename Types::template SortedArrayOf rangeRecord; /* Array of glyph ranges--ordered by * Start GlyphID. rangeCount entries * long */ public: - DEFINE_SIZE_ARRAY (4, rangeRecord); + DEFINE_SIZE_ARRAY (2 + Types::HBUINT::static_size, rangeRecord); private: @@ -59,7 +60,7 @@ struct CoverageFormat2_4 unsigned int get_coverage (hb_codepoint_t glyph_id) const { - const RangeRecord &range = rangeRecord.bsearch (glyph_id); + const CoverageRangeRecord &range = rangeRecord.bsearch (glyph_id); return likely (range.first <= range.last) ? (unsigned int) range.value + (glyph_id - range.first) : NOT_COVERED; @@ -113,7 +114,7 @@ struct CoverageFormat2_4 } if (unlikely (unsorted)) - rangeRecord.as_array ().qsort (RangeRecord::cmp_range); + rangeRecord.as_array ().qsort (CoverageRangeRecord::cmp_range); return_trace (true); } @@ -129,7 +130,7 @@ struct CoverageFormat2_4 } return hb_any (+ hb_iter (rangeRecord) - | hb_map ([glyphs] (const RangeRecord &range) { return range.intersects (*glyphs); })); + | hb_map ([glyphs] (const CoverageRangeRecord &range) { return range.intersects (*glyphs); })); } bool intersects_coverage (const hb_set_t *glyphs, unsigned int index) const { diff --git a/src/OT/Layout/Common/RangeRecord.hh b/src/OT/Layout/Common/RangeRecord.hh index 85aacace9..ad9a637d6 100644 --- a/src/OT/Layout/Common/RangeRecord.hh +++ b/src/OT/Layout/Common/RangeRecord.hh @@ -33,14 +33,14 @@ namespace OT { namespace Layout { namespace Common { -template +template struct RangeRecord { typename Types::HBGlyphID first; /* First GlyphID in the range */ typename Types::HBGlyphID last; /* Last GlyphID in the range */ - HBUINT16 value; /* Value */ + Value value; /* Value */ - DEFINE_SIZE_STATIC (2 + 2 * Types::size); + DEFINE_SIZE_STATIC (2 * Types::size + Value::static_size); bool sanitize (hb_sanitize_context_t *c) const { @@ -86,10 +86,10 @@ struct RangeRecord // but that only works when there is only a single namespace level. // The macro should probably be fixed so it can work in this situation. extern HB_INTERNAL const unsigned char _hb_Null_OT_RangeRecord[9]; -template -struct Null> { - static OT::Layout::Common::RangeRecord const & get_null () { - return *reinterpret_cast *> (_hb_Null_OT_RangeRecord); +template +struct Null> { + static OT::Layout::Common::RangeRecord const & get_null () { + return *reinterpret_cast *> (_hb_Null_OT_RangeRecord); } }; diff --git a/src/OT/Layout/GPOS/MarkBasePosFormat1.hh b/src/OT/Layout/GPOS/MarkBasePosFormat1.hh index 550d29a6c..59db3607a 100644 --- a/src/OT/Layout/GPOS/MarkBasePosFormat1.hh +++ b/src/OT/Layout/GPOS/MarkBasePosFormat1.hh @@ -12,22 +12,22 @@ struct MarkBasePosFormat1_2 { protected: HBUINT16 format; /* Format identifier--format = 1 */ - typename Types::template OffsetTo + typename Types::template LOffsetTo markCoverage; /* Offset to MarkCoverage table--from * beginning of MarkBasePos subtable */ - typename Types::template OffsetTo + typename Types::template LOffsetTo baseCoverage; /* Offset to BaseCoverage table--from * beginning of MarkBasePos subtable */ HBUINT16 classCount; /* Number of classes defined for marks */ - typename Types::template OffsetTo> + typename Types::template LOffsetTo> markArray; /* Offset to MarkArray table--from * beginning of MarkBasePos subtable */ - typename Types::template OffsetTo> + typename Types::template LOffsetTo> baseArray; /* Offset to BaseArray table--from * beginning of MarkBasePos subtable */ public: - DEFINE_SIZE_STATIC (4 + 4 * Types::size); + DEFINE_SIZE_STATIC (4 + 4 * Types::LOffset::static_size); bool sanitize (hb_sanitize_context_t *c) const { diff --git a/src/OT/Layout/GPOS/MarkLigPosFormat1.hh b/src/OT/Layout/GPOS/MarkLigPosFormat1.hh index 518a4b0f0..e2765c9f6 100644 --- a/src/OT/Layout/GPOS/MarkLigPosFormat1.hh +++ b/src/OT/Layout/GPOS/MarkLigPosFormat1.hh @@ -13,22 +13,22 @@ struct MarkLigPosFormat1_2 { protected: HBUINT16 format; /* Format identifier--format = 1 */ - typename Types::template OffsetTo + typename Types::template LOffsetTo markCoverage; /* Offset to Mark Coverage table--from * beginning of MarkLigPos subtable */ - typename Types::template OffsetTo + typename Types::template LOffsetTo ligatureCoverage; /* Offset to Ligature Coverage * table--from beginning of MarkLigPos * subtable */ HBUINT16 classCount; /* Number of defined mark classes */ - typename Types::template OffsetTo> + typename Types::template LOffsetTo> markArray; /* Offset to MarkArray table--from * beginning of MarkLigPos subtable */ - typename Types::template OffsetTo> + typename Types::template LOffsetTo> ligatureArray; /* Offset to LigatureArray table--from * beginning of MarkLigPos subtable */ public: - DEFINE_SIZE_STATIC (4 + 4 * Types::size); + DEFINE_SIZE_STATIC (4 + 4 * Types::LOffset::static_size); bool sanitize (hb_sanitize_context_t *c) const { diff --git a/src/OT/Layout/GPOS/MarkMarkPosFormat1.hh b/src/OT/Layout/GPOS/MarkMarkPosFormat1.hh index 0672c9c1e..5fe3f23d8 100644 --- a/src/OT/Layout/GPOS/MarkMarkPosFormat1.hh +++ b/src/OT/Layout/GPOS/MarkMarkPosFormat1.hh @@ -12,23 +12,23 @@ struct MarkMarkPosFormat1_2 { protected: HBUINT16 format; /* Format identifier--format = 1 */ - typename Types::template OffsetTo + typename Types::template LOffsetTo mark1Coverage; /* Offset to Combining Mark1 Coverage * table--from beginning of MarkMarkPos * subtable */ - typename Types::template OffsetTo + typename Types::template LOffsetTo mark2Coverage; /* Offset to Combining Mark2 Coverage * table--from beginning of MarkMarkPos * subtable */ HBUINT16 classCount; /* Number of defined mark classes */ - typename Types::template OffsetTo> + typename Types::template LOffsetTo> mark1Array; /* Offset to Mark1Array table--from * beginning of MarkMarkPos subtable */ - typename Types::template OffsetTo> + typename Types::template LOffsetTo> mark2Array; /* Offset to Mark2Array table--from * beginning of MarkMarkPos subtable */ public: - DEFINE_SIZE_STATIC (4 + 4 * Types::size); + DEFINE_SIZE_STATIC (4 + 4 * Types::LOffset::static_size); bool sanitize (hb_sanitize_context_t *c) const { diff --git a/src/OT/Layout/GSUB/AlternateSubstFormat1.hh b/src/OT/Layout/GSUB/AlternateSubstFormat1.hh index 3b02416a9..c6ecda072 100644 --- a/src/OT/Layout/GSUB/AlternateSubstFormat1.hh +++ b/src/OT/Layout/GSUB/AlternateSubstFormat1.hh @@ -13,14 +13,14 @@ struct AlternateSubstFormat1_2 { protected: HBUINT16 format; /* Format identifier--format = 1 */ - typename Types::template OffsetTo + typename Types::template LOffsetTo coverage; /* Offset to Coverage table--from * beginning of Substitution table */ typename Types::template ArrayOf>> alternateSet; /* Array of AlternateSet tables * ordered by Coverage Index */ public: - DEFINE_SIZE_ARRAY (2 + 2 * Types::size, alternateSet); + DEFINE_SIZE_ARRAY (2 + Types::LOffset::static_size + Types::HBUINT::static_size, alternateSet); bool sanitize (hb_sanitize_context_t *c) const { diff --git a/src/OT/Layout/GSUB/LigatureSubstFormat1.hh b/src/OT/Layout/GSUB/LigatureSubstFormat1.hh index 0e6fd5268..33b6f74c9 100644 --- a/src/OT/Layout/GSUB/LigatureSubstFormat1.hh +++ b/src/OT/Layout/GSUB/LigatureSubstFormat1.hh @@ -13,14 +13,14 @@ struct LigatureSubstFormat1_2 { protected: HBUINT16 format; /* Format identifier--format = 1 */ - typename Types::template OffsetTo + typename Types::template LOffsetTo coverage; /* Offset to Coverage table--from * beginning of Substitution table */ typename Types::template ArrayOf>> ligatureSet; /* Array LigatureSet tables * ordered by Coverage Index */ public: - DEFINE_SIZE_ARRAY (2 + 2 * Types::size, ligatureSet); + DEFINE_SIZE_ARRAY (2 + Types::LOffset::static_size + Types::HBUINT::static_size, ligatureSet); bool sanitize (hb_sanitize_context_t *c) const { diff --git a/src/OT/Layout/GSUB/MultipleSubstFormat1.hh b/src/OT/Layout/GSUB/MultipleSubstFormat1.hh index bc6d9261e..fd42829da 100644 --- a/src/OT/Layout/GSUB/MultipleSubstFormat1.hh +++ b/src/OT/Layout/GSUB/MultipleSubstFormat1.hh @@ -13,14 +13,14 @@ struct MultipleSubstFormat1_2 { protected: HBUINT16 format; /* Format identifier--format = 1 */ - typename Types::template OffsetTo + typename Types::template LOffsetTo coverage; /* Offset to Coverage table--from * beginning of Substitution table */ typename Types::template ArrayOf>> sequence; /* Array of Sequence tables * ordered by Coverage Index */ public: - DEFINE_SIZE_ARRAY (2 + 2 * Types::size, sequence); + DEFINE_SIZE_ARRAY (2 + Types::LOffset::static_size + Types::HBUINT::static_size, sequence); bool sanitize (hb_sanitize_context_t *c) const { diff --git a/src/OT/Layout/GSUB/ReverseChainSingleSubstFormat1.hh b/src/OT/Layout/GSUB/ReverseChainSingleSubstFormat1.hh index c12a15c37..6b53a124c 100644 --- a/src/OT/Layout/GSUB/ReverseChainSingleSubstFormat1.hh +++ b/src/OT/Layout/GSUB/ReverseChainSingleSubstFormat1.hh @@ -12,7 +12,7 @@ struct ReverseChainSingleSubstFormat1_2 { protected: HBUINT16 format; /* Format identifier--format = 1 */ - typename Types::template OffsetTo + typename Types::template LOffsetTo coverage; /* Offset to Coverage table--from * beginning of table */ Array16Of> @@ -29,7 +29,7 @@ struct ReverseChainSingleSubstFormat1_2 substituteX; /* Array of substitute * GlyphIDs--ordered by Coverage Index */ public: - DEFINE_SIZE_MIN (6 + 2 * Types::size); + DEFINE_SIZE_MIN (6 + Types::LOffset::static_size + Types::HBUINT::static_size); bool sanitize (hb_sanitize_context_t *c) const { diff --git a/src/OT/Layout/GSUB/SingleSubstFormat1.hh b/src/OT/Layout/GSUB/SingleSubstFormat1.hh index 1cd3f9d9c..99518496f 100644 --- a/src/OT/Layout/GSUB/SingleSubstFormat1.hh +++ b/src/OT/Layout/GSUB/SingleSubstFormat1.hh @@ -12,7 +12,7 @@ struct SingleSubstFormat1_3 { protected: HBUINT16 format; /* Format identifier--format = 1 */ - typename Types::template OffsetTo + typename Types::template LOffsetTo coverage; /* Offset to Coverage table--from * beginning of Substitution table */ typename Types::HBUINT @@ -20,7 +20,7 @@ struct SingleSubstFormat1_3 * substitute GlyphID, modulo 0x10000 */ public: - DEFINE_SIZE_STATIC (2 + 2 * Types::size); + DEFINE_SIZE_STATIC (2 + Types::LOffset::static_size + Types::HBUINT::static_size); bool sanitize (hb_sanitize_context_t *c) const { diff --git a/src/OT/Layout/GSUB/SingleSubstFormat2.hh b/src/OT/Layout/GSUB/SingleSubstFormat2.hh index 831e33d9c..08af957dd 100644 --- a/src/OT/Layout/GSUB/SingleSubstFormat2.hh +++ b/src/OT/Layout/GSUB/SingleSubstFormat2.hh @@ -12,7 +12,7 @@ struct SingleSubstFormat2_4 { protected: HBUINT16 format; /* Format identifier--format = 2 */ - typename Types::template OffsetTo + typename Types::template LOffsetTo coverage; /* Offset to Coverage table--from * beginning of Substitution table */ typename Types::template ArrayOf @@ -20,7 +20,7 @@ struct SingleSubstFormat2_4 * GlyphIDs--ordered by Coverage Index */ public: - DEFINE_SIZE_ARRAY (2 + 2 * Types::size, substitute); + DEFINE_SIZE_ARRAY (2 + Types::LOffset::static_size + Types::HBUINT::static_size, substitute); bool sanitize (hb_sanitize_context_t *c) const { diff --git a/src/graph/classdef-graph.hh b/src/graph/classdef-graph.hh index c875979b7..db1c1c6e4 100644 --- a/src/graph/classdef-graph.hh +++ b/src/graph/classdef-graph.hh @@ -135,8 +135,6 @@ struct ClassDef : public OT::ClassDef struct class_def_size_estimator_t { - constexpr static unsigned coverage_base_size = 4; - template class_def_size_estimator_t (It glyph_and_class) : num_ranges_per_class (), glyphs_per_class () @@ -187,7 +185,8 @@ struct class_def_size_estimator_t unsigned coverage_size () const { unsigned glyph_size = glyph_id_size (included_glyphs); - unsigned range_size = 2 * glyph_size + OT::HBUINT16::static_size; + unsigned coverage_base_size = OT::HBUINT16::static_size + glyph_size; + unsigned range_size = 3 * glyph_size; unsigned format1_size = coverage_base_size + glyph_size * included_glyphs.get_population(); unsigned format2_size = coverage_base_size + range_size * num_glyph_ranges (included_glyphs); return hb_min(format1_size, format2_size); diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index 5053d965e..bfbd27be6 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -2472,7 +2472,7 @@ struct RuleSetOf }; template -struct RuleSet : RuleSetOf> {}; +struct RuleSet : RuleSetOf> {}; template struct ClassRuleSet : RuleSetOf> {}; @@ -2619,14 +2619,14 @@ struct ContextFormat1_4 protected: HBUINT16 format; /* Format identifier--format = 1 */ - typename Types::template OffsetTo + typename Types::template LOffsetTo coverage; /* Offset to Coverage table--from * beginning of table */ typename Types::template ArrayOf> ruleSet; /* Array of RuleSet tables * ordered by Coverage Index */ public: - DEFINE_SIZE_ARRAY (2 + 2 * Types::size, ruleSet); + DEFINE_SIZE_ARRAY (2 + Types::LOffset::static_size + Types::HBUINT::static_size, ruleSet); }; @@ -2876,17 +2876,17 @@ struct ContextFormat2_5 protected: HBUINT16 format; /* Format identifier--format = 2 */ - typename Types::template OffsetTo + typename Types::template LOffsetTo coverage; /* Offset to Coverage table--from * beginning of table */ - typename Types::template OffsetTo + typename Types::template LOffsetTo classDef; /* Offset to glyph ClassDef table--from * beginning of table */ typename Types::template ArrayOf> ruleSet; /* Array of RuleSet tables * ordered by class */ public: - DEFINE_SIZE_ARRAY (2 + 3 * Types::size, ruleSet); + DEFINE_SIZE_ARRAY (2 + 2 * Types::LOffset::static_size + Types::HBUINT::static_size, ruleSet); }; @@ -3849,14 +3849,14 @@ struct ChainContextFormat1_4 protected: HBUINT16 format; /* Format identifier--format = 1 */ - typename Types::template OffsetTo + typename Types::template LOffsetTo coverage; /* Offset to Coverage table--from * beginning of table */ typename Types::template ArrayOf> ruleSet; /* Array of ChainRuleSet tables * ordered by Coverage Index */ public: - DEFINE_SIZE_ARRAY (2 + 2 * Types::size, ruleSet); + DEFINE_SIZE_ARRAY (2 + Types::LOffset::static_size + Types::HBUINT::static_size, ruleSet); }; template @@ -4152,18 +4152,18 @@ struct ChainContextFormat2_5 protected: HBUINT16 format; /* Format identifier--format = 2 */ - typename Types::template OffsetTo + typename Types::template LOffsetTo coverage; /* Offset to Coverage table--from * beginning of table */ - typename Types::template OffsetTo + typename Types::template LOffsetTo backtrackClassDef; /* Offset to glyph ClassDef table * containing backtrack sequence * data--from beginning of table */ - typename Types::template OffsetTo + typename Types::template LOffsetTo inputClassDef; /* Offset to glyph ClassDef * table containing input sequence * data--from beginning of table */ - typename Types::template OffsetTo + typename Types::template LOffsetTo lookaheadClassDef; /* Offset to glyph ClassDef table * containing lookahead sequence * data--from beginning of table */ @@ -4171,7 +4171,7 @@ struct ChainContextFormat2_5 ruleSet; /* Array of ChainRuleSet tables * ordered by class */ public: - DEFINE_SIZE_ARRAY (4 + 4 * Types::size, ruleSet); + DEFINE_SIZE_ARRAY (4 + 4 * Types::LOffset::static_size, ruleSet); }; template