diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index bae2eed81..5580565f1 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -140,7 +140,6 @@ struct Tag : HBUINT32 public: DEFINE_SIZE_STATIC (4); }; -DEFINE_NULL_DATA (OT, Tag, " "); /* Glyph index number, same as uint16 (length = 16 bits) */ typedef HBUINT16 GlyphID; @@ -152,7 +151,7 @@ typedef HBUINT16 NameID; struct Index : HBUINT16 { static const unsigned int NOT_FOUND_INDEX = 0xFFFFu; }; -DEFINE_NULL_DATA (OT, Index, "\xff\xff"); +DECLARE_NULL_NAMESPACE_BYTES (OT, Index); /* Offset, Null offset = 0 */ template diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh index 2da6e315c..89d5eae49 100644 --- a/src/hb-ot-layout-common-private.hh +++ b/src/hb-ot-layout-common-private.hh @@ -173,7 +173,7 @@ struct RangeRecord public: DEFINE_SIZE_STATIC (6); }; -DEFINE_NULL_DATA (OT, RangeRecord, "\000\001"); +DECLARE_NULL_NAMESPACE_BYTES (OT, RangeRecord); struct IndexArray : ArrayOf @@ -240,8 +240,7 @@ struct LangSys public: DEFINE_SIZE_ARRAY (6, featureIndex); }; -DEFINE_NULL_DATA (OT, LangSys, "\0\0\xFF\xFF"); - +DECLARE_NULL_NAMESPACE_BYTES (OT, LangSys); struct Script { diff --git a/src/hb-private.hh b/src/hb-private.hh index 32e1edffe..d912fe332 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -391,16 +391,18 @@ static inline Type const & Null (void) { #define Null(Type) Null() /* Specializaiton for arbitrary-content arbitrary-sized Null objects. */ -#define DEFINE_NULL_DATA(Namespace, Type, data) \ +#define DECLARE_NULL_NAMESPACE_BYTES(Namespace, Type) \ } /* Close namespace. */ \ -static const char _Null##Type[sizeof (Namespace::Type) + 1] = data; /* +1 is for nul-termination in data */ \ +extern HB_INTERNAL const unsigned char _hb_Null_##Namespace##_##Type[sizeof (Namespace::Type)]; \ template <> \ /*static*/ inline const Namespace::Type& Null (void) { \ - return *reinterpret_cast (_Null##Type); \ + return *reinterpret_cast (_hb_Null_##Namespace##_##Type); \ } \ namespace Namespace { \ -/* The following line really exists such that we end in a place needing semicolon */ \ -static_assert (Namespace::Type::min_size + 1 <= sizeof (_Null##Type), "Null pool too small. Enlarge.") +static_assert (Namespace::Type::min_size <= sizeof (Type), "Null pool too small. Enlarge."); \ + +#define DEFINE_NULL_NAMESPACE_BYTES(Namespace, Type) \ +const unsigned char _hb_Null_##Namespace##_##Type[sizeof (Namespace::Type)] /* Global writable pool. Enlarge as necessary. */ diff --git a/src/hb-static.cc b/src/hb-static.cc index bd0943f53..ddecbba11 100644 --- a/src/hb-static.cc +++ b/src/hb-static.cc @@ -25,8 +25,11 @@ */ #include "hb-private.hh" -#include "hb-face-private.hh" + #include "hb-open-type-private.hh" +#include "hb-ot-layout-common-private.hh" + +#include "hb-face-private.hh" #include "hb-ot-head-table.hh" #include "hb-ot-maxp-table.hh" @@ -35,6 +38,11 @@ hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)] = {}; /*thread_local*/ hb_vector_size_impl_t _hb_CrapPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)] = {}; +DEFINE_NULL_NAMESPACE_BYTES (OT, Index) = {0xFF,0xFF}; +DEFINE_NULL_NAMESPACE_BYTES (OT, LangSys) = {0x00,0x00, 0xFF,0xFF, 0x00,0x00}; +DEFINE_NULL_NAMESPACE_BYTES (OT, RangeRecord) = {0x00,0x01, 0x00,0x00, 0x00, 0x00}; + + void hb_face_t::load_num_glyphs (void) const {