From 9e8a9b846ec24e9124d61706272a0e5fa58d7a24 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 17 Oct 2018 21:41:25 -0700 Subject: [PATCH] [aat] Another try at fixing Lookup null objects... Ugly as hell, and don't even understand why some bits are needed. But the logic is sound. --- src/hb-aat-layout-common.hh | 23 ++++++++++++++++++++--- src/hb-static.cc | 4 ++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/hb-aat-layout-common.hh b/src/hb-aat-layout-common.hh index 37f6d03cf..741e5020d 100644 --- a/src/hb-aat-layout-common.hh +++ b/src/hb-aat-layout-common.hh @@ -291,10 +291,27 @@ struct Lookup LookupFormat8 format8; } u; public: - DEFINE_SIZE_MIN (0); /* 0 min size, makes sure this cannot be used on null pool, - * because Format0 has unbounded size depending on num_glyphs. - * We cannot define custom null bytes for a template :(. */ + DEFINE_SIZE_UNION (2, format); }; +/* Lookup 0 has unbounded size (dependant on num_glyphs). So we need to defined + * special NULL objects for Lookup<> objects, but since it's template our macros + * don't work. So we have to hand-code them here. UGLY. */ +} /* Close namespace. */ +/* Ugly hand-coded null objects for template Lookup<> :(. */ +extern HB_INTERNAL const unsigned char _hb_Null_AAT_Lookup[2]; +template <> +/*static*/ inline const AAT::Lookup& Null > (void) { + return *reinterpret_cast *> (_hb_Null_AAT_Lookup); +} +template <> +/*static*/ inline const AAT::Lookup& Null > (void) { + return *reinterpret_cast *> (_hb_Null_AAT_Lookup); +} +template <> +/*static*/ inline const AAT::Lookup>& Null> > (void) { + return *reinterpret_cast> *> (_hb_Null_AAT_Lookup); +} +namespace AAT { /* diff --git a/src/hb-static.cc b/src/hb-static.cc index 5112d77be..0b92443e7 100644 --- a/src/hb-static.cc +++ b/src/hb-static.cc @@ -41,6 +41,10 @@ hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_ 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}; +/* Hand-coded because Lookup is a template. + * Not sure why I need the extern "C" :(. + * Sad. */ +extern "C" HB_INTERNAL const unsigned char _hb_Null_AAT_Lookup[2] = {0xFF, 0xFF}; void