From e3caf8d50a2c033039c2609b7bf6ebae302741a7 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 6 Jul 2022 13:11:53 -0600 Subject: [PATCH] [>64k:layout] Templatize SingleSubst --- src/OT/Layout/GSUB/SingleSubst.hh | 6 +++--- src/OT/Layout/GSUB/SingleSubstFormat1.hh | 10 ++++++---- src/OT/Layout/GSUB/SingleSubstFormat2.hh | 9 +++++---- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/OT/Layout/GSUB/SingleSubst.hh b/src/OT/Layout/GSUB/SingleSubst.hh index 38ffc6ac5..49d894f50 100644 --- a/src/OT/Layout/GSUB/SingleSubst.hh +++ b/src/OT/Layout/GSUB/SingleSubst.hh @@ -13,9 +13,9 @@ struct SingleSubst { protected: union { - HBUINT16 format; /* Format identifier */ - SingleSubstFormat1 format1; - SingleSubstFormat2 format2; + HBUINT16 format; /* Format identifier */ + SingleSubstFormat1_3 format1; + SingleSubstFormat2_4 format2; } u; public: diff --git a/src/OT/Layout/GSUB/SingleSubstFormat1.hh b/src/OT/Layout/GSUB/SingleSubstFormat1.hh index 57d13539c..82084585e 100644 --- a/src/OT/Layout/GSUB/SingleSubstFormat1.hh +++ b/src/OT/Layout/GSUB/SingleSubstFormat1.hh @@ -7,18 +7,20 @@ namespace OT { namespace Layout { namespace GSUB_impl { -struct SingleSubstFormat1 +template +struct SingleSubstFormat1_3 { protected: HBUINT16 format; /* Format identifier--format = 1 */ - Offset16To + typename Types::template OffsetTo coverage; /* Offset to Coverage table--from * beginning of Substitution table */ - HBUINT16 deltaGlyphID; /* Add to original GlyphID to get + typename Types::HBUINT + deltaGlyphID; /* Add to original GlyphID to get * substitute GlyphID, modulo 0x10000 */ public: - DEFINE_SIZE_STATIC (6); + DEFINE_SIZE_STATIC (2 + 2 * Types::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 4f954ae2f..57cc0ba4c 100644 --- a/src/OT/Layout/GSUB/SingleSubstFormat2.hh +++ b/src/OT/Layout/GSUB/SingleSubstFormat2.hh @@ -7,19 +7,20 @@ namespace OT { namespace Layout { namespace GSUB_impl { -struct SingleSubstFormat2 +template +struct SingleSubstFormat2_4 { protected: HBUINT16 format; /* Format identifier--format = 2 */ - Offset16To + typename Types::template OffsetTo coverage; /* Offset to Coverage table--from * beginning of Substitution table */ - Array16Of + Array16Of substitute; /* Array of substitute * GlyphIDs--ordered by Coverage Index */ public: - DEFINE_SIZE_ARRAY (6, substitute); + DEFINE_SIZE_ARRAY (4 + Types::size, substitute); bool sanitize (hb_sanitize_context_t *c) const {