#include <stdio.h>
#ifndef HB_NO_VISIBILITY
-const void * const OT::_hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {};
+const void * const _hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {};
#endif
void cbdt_callback (const uint8_t* data, unsigned int length,
void colr_cpal_rendering (cairo_font_face_t *cairo_face, unsigned int upem, unsigned int num_glyphs,
const OT::COLR *colr, const OT::CPAL *cpal)
{
- for (int i = 0; i < num_glyphs; ++i)
+ for (unsigned int i = 0; i < num_glyphs; ++i)
{
unsigned int first_layer_index, num_layers;
if (colr->get_base_glyph_record (i, &first_layer_index, &num_layers))
{
// Dump every glyph available on the font
return; // disabled for now
- for (int i = 0; i < num_glyphs; ++i)
+ for (unsigned int i = 0; i < num_glyphs; ++i)
{
cairo_text_extents_t extents;
cairo_glyph_t glyph = {0};
#include "hb-open-type-private.hh"
#ifndef HB_NO_VISIBILITY
-const void * const OT::_hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {};
+const void * const _hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {};
#endif
template <typename Type, int Bytes> struct LEInt;
{
const NE_TYPEINFO& next = OT::StructAfter<NE_TYPEINFO> (*this);
if (type_id == 0)
- return OT::Null (NE_TYPEINFO);
+ return Null (NE_TYPEINFO);
return next;
}
{
if (idx < count)
return resources[idx].get_font (base, shift);
- return OT::Null (LE_FONTINFO16);
+ return Null (LE_FONTINFO16);
}
inline unsigned int get_count () const
return_trace (false);
const NE_TYPEINFO* n = &chain;
- while (n != &OT::Null (NE_TYPEINFO) && c->check_struct (n) && n->get_type_id () != 0)
+ while (n != &Null (NE_TYPEINFO) && c->check_struct (n) && n->get_type_id () != 0)
{
if (n->get_type_id () == NE_TYPEINFO::FONT)
return_trace (n->sanitize (c, base, alignmentShiftCount));
inline const NE_TYPEINFO& get_fonts_entry () const
{
const NE_TYPEINFO* n = &chain;
- while (n != &OT::Null (NE_TYPEINFO) && n->get_type_id () != 0)
+ while (n != &Null (NE_TYPEINFO) && n->get_type_id () != 0)
{
if (n->get_type_id () == NE_TYPEINFO::FONT)
return *n;
n = &n->next();
}
- return OT::Null (NE_TYPEINFO);
+ return Null (NE_TYPEINFO);
}
protected:
inline const NE_RESOURCE_TABLE& get_resource_table () const
{
if (magic != 0x454E) // Only NE containers are support for now, NE == 0x454E
- return OT::Null (NE_RESOURCE_TABLE);
+ return Null (NE_RESOURCE_TABLE);
return this+rsrctab;
}
{
if (blob)
*blob = hb_blob_get_empty ();
- return OT::Null(AAT::ankr);
+ return Null(AAT::ankr);
}
hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
const AAT::ankr& ankr = *(layout->ankr.get ());
{
if (blob)
*blob = hb_blob_get_empty ();
- return OT::Null(AAT::kerx);
+ return Null(AAT::kerx);
}
hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
/* XXX this doesn't call set_num_glyphs on sanitizer. */
{
if (blob)
*blob = hb_blob_get_empty ();
- return OT::Null(AAT::morx);
+ return Null(AAT::morx);
}
hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
/* XXX this doesn't call set_num_glyphs on sanitizer. */
{
if (blob)
*blob = hb_blob_get_empty ();
- return OT::Null(AAT::trak);
+ return Null(AAT::trak);
}
hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
const AAT::trak& trak = *(layout->trak.get ());
/*
- * Null objects
- */
-
-/* Global nul-content Null pool. Enlarge as necessary. */
-
-#define HB_NULL_POOL_SIZE 264
-static_assert (HB_NULL_POOL_SIZE % sizeof (void *) == 0, "Align HB_NULL_POOL_SIZE.");
-
-#ifdef HB_NO_VISIBILITY
-static
-#else
-extern HB_INTERNAL
-#endif
-const void * const _hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)]
-#ifdef HB_NO_VISIBILITY
-= {}
-#endif
-;
-
-/* Generic nul-content Null objects. */
-template <typename Type>
-static inline const Type& Null (void) {
- static_assert (sizeof (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE.");
- return *CastP<Type> (_hb_NullPool);
-}
-
-/* Specializaiton for arbitrary-content arbitrary-sized Null objects. */
-#define DEFINE_NULL_DATA(Type, data) \
-static const char _Null##Type[sizeof (Type) + 1] = data; /* +1 is for nul-termination in data */ \
-template <> \
-/*static*/ inline const Type& Null<Type> (void) { \
- return *CastP<Type> (_Null##Type); \
-} /* The following line really exists such that we end in a place needing semicolon */ \
-static_assert (Type::min_size + 1 <= sizeof (_Null##Type), "Null pool too small. Enlarge.")
-
-/* Accessor macro. */
-#define Null(Type) Null<Type>()
-
-
-/*
* Dispatch
*/
public:
DEFINE_SIZE_STATIC (4);
};
-DEFINE_NULL_DATA (Tag, " ");
/* Glyph index number, same as uint16 (length = 16 bits) */
typedef HBUINT16 GlyphID;
struct Index : HBUINT16 {
static const unsigned int NOT_FOUND_INDEX = 0xFFFFu;
};
-DEFINE_NULL_DATA (Index, "\xff\xff");
/* Offset, Null offset = 0 */
template <typename Type>
inline void fini (void)
{
- if (instance && instance != &OT::Null(T))
+ if (instance && instance != &Null(T))
{
instance->fini();
free (instance);
{
p = (T *) calloc (1, sizeof (T));
if (unlikely (!p))
- p = const_cast<T *> (&OT::Null(T));
+ p = const_cast<T *> (&Null(T));
else
p->init (face);
if (unlikely (!hb_atomic_ptr_cmpexch (const_cast<T **>(&instance), nullptr, p)))
{
- if (p != &OT::Null(T))
+ if (p != &Null(T))
p->fini ();
goto retry;
}
if (subtable) symbol = true;
}
/* Meh. */
- if (!subtable) subtable = &OT::Null(OT::CmapSubtable);
+ if (!subtable) subtable = &Null(OT::CmapSubtable);
/* UVS subtable. */
if (!subtable_uvs)
subtable_uvs = &st->u.format14;
}
/* Meh. */
- if (!subtable_uvs) subtable_uvs = &OT::Null(OT::CmapSubtableFormat14);
+ if (!subtable_uvs) subtable_uvs = &Null(OT::CmapSubtableFormat14);
this->uvs_table = subtable_uvs;
static inline const OT::COLR&
_get_colr (hb_face_t *face)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return OT::Null(OT::COLR);
+ if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::COLR);
hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
return *(layout->colr.get ());
}
static inline const OT::CPAL&
_get_cpal (hb_face_t *face)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return OT::Null(OT::CPAL);
+ if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::CPAL);
hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
return *(layout->cpal.get ());
}
public:
DEFINE_SIZE_STATIC (6);
};
-DEFINE_NULL_DATA (RangeRecord, "\000\001");
struct IndexArray : ArrayOf<Index>
public:
DEFINE_SIZE_ARRAY (6, featureIndex);
};
-DEFINE_NULL_DATA (LangSys, "\0\0\xFF\xFF");
struct Script
{ return langSys.find_index (tag, index); }
inline bool has_default_lang_sys (void) const { return defaultLangSys != 0; }
- inline const LangSys& get_default_lang_sys (void) const { return this+defaultLangSys; }
+ inline const LangSys& get_default_lang_sys (void) const
+ {
+ if (!defaultLangSys)
+ {
+ /* This is the ONLY place where our null data is not all zeros.
+ * So, return special data instead of using the null pool. */
+ return *reinterpret_cast<const LangSys *> ("\0\0\xFF\xFF");
+ }
+ return this+defaultLangSys;
+ }
inline bool sanitize (hb_sanitize_context_t *c,
const Record<Script>::sanitize_closure_t * = nullptr) const
#ifndef HB_NO_VISIBILITY
-const void * const OT::_hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {};
+const void * const _hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {};
#endif
* https://lists.freedesktop.org/archives/harfbuzz/2016-February/005489.html
*/
if (3 == layout->gdef->get_glyph_class (5))
- layout->gdef = &OT::Null(OT::GDEF);
+ layout->gdef = &Null(OT::GDEF);
}
else if (0
/* sha1sum:96eda93f7d33e79962451c6c39a6b51ee893ce8c tahoma.ttf from Windows 8 */
* https://bugzilla.mozilla.org/show_bug.cgi?id=1279693
* https://bugzilla.mozilla.org/show_bug.cgi?id=1279875
*/
- layout->gdef = &OT::Null(OT::GDEF);
+ layout->gdef = &Null(OT::GDEF);
}
}
// static inline const OT::BASE&
// _get_base (hb_face_t *face)
// {
-// if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return OT::Null(OT::BASE);
+// if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::BASE);
// hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
// return *(layout->base.get ());
// }
static inline const OT::GDEF&
_get_gdef (hb_face_t *face)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return OT::Null(OT::GDEF);
+ if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GDEF);
return *hb_ot_layout_from_face (face)->gdef;
}
static inline const OT::GSUB&
_get_gsub (hb_face_t *face)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return OT::Null(OT::GSUB);
+ if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GSUB);
return *hb_ot_layout_from_face (face)->gsub;
}
static inline const OT::GPOS&
_get_gpos (hb_face_t *face)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return OT::Null(OT::GPOS);
+ if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GPOS);
return *hb_ot_layout_from_face (face)->gpos;
}
switch (table_tag) {
case HB_OT_TAG_GSUB: return _get_gsub (face);
case HB_OT_TAG_GPOS: return _get_gpos (face);
- default: return OT::Null(OT::GSUBGPOS);
+ default: return Null(OT::GSUBGPOS);
}
}
hb_bool_t
hb_ot_layout_has_substitution (hb_face_t *face)
{
- return &_get_gsub (face) != &OT::Null(OT::GSUB);
+ return &_get_gsub (face) != &Null(OT::GSUB);
}
/**
hb_bool_t
hb_ot_layout_has_positioning (hb_face_t *face)
{
- return &_get_gpos (face) != &OT::Null(OT::GPOS);
+ return &_get_gpos (face) != &Null(OT::GPOS);
}
void
// hb_bool_t
// hb_ot_base_has_data (hb_face_t *face)
// {
-// return &_get_base (face) != &OT::Null(OT::BASE);
+// return &_get_base (face) != &Null(OT::BASE);
// }
static inline const OT::MATH&
_get_math (hb_face_t *face)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return OT::Null(OT::MATH);
+ if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::MATH);
hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
return *(layout->math.get ());
}
hb_bool_t
hb_ot_math_has_data (hb_face_t *face)
{
- return &_get_math (face) != &OT::Null(OT::MATH);
+ return &_get_math (face) != &Null(OT::MATH);
}
/**
static inline const OT::fvar&
_get_fvar (hb_face_t *face)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return OT::Null(OT::fvar);
+ if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::fvar);
hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
return *(layout->fvar.get ());
}
static inline const OT::avar&
_get_avar (hb_face_t *face)
{
- if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return OT::Null(OT::avar);
+ if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::avar);
hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
return *(layout->avar.get ());
}
hb_bool_t
hb_ot_var_has_data (hb_face_t *face)
{
- return &_get_fvar (face) != &OT::Null(OT::fvar);
+ return &_get_fvar (face) != &Null(OT::fvar);
}
/**
#endif
+/*
+ * Null objects
+ */
+
+/* Global nul-content Null pool. Enlarge as necessary. */
+
+#define HB_NULL_POOL_SIZE 264
+static_assert (HB_NULL_POOL_SIZE % sizeof (void *) == 0, "Align HB_NULL_POOL_SIZE.");
+
+#ifdef HB_NO_VISIBILITY
+static
+#else
+extern HB_INTERNAL
+#endif
+const void * const _hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)]
+#ifdef HB_NO_VISIBILITY
+= {}
+#endif
+;
+
+/* Generic nul-content Null objects. */
+template <typename Type>
+static inline const Type& Null (void) {
+ static_assert (sizeof (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE.");
+ return *reinterpret_cast<const Type *> (_hb_NullPool);
+}
+#define Null(Type) Null<Type>()
+
+
#endif /* HB_PRIVATE_HH */
#if !defined(HB_NO_VISIBILITY) && !defined(HB_SUBSET_BUILTIN)
-const void * const OT::_hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {};
+const void * const _hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {};
#endif
hb_tag_t tag = TableType::tableTag;
hb_bool_t result = false;
- if (table != &OT::Null(TableType))
+ if (table != &Null(TableType))
{
result = table->subset(plan);
} else {
using namespace OT;
#ifndef HB_NO_VISIBILITY
-const void * const OT::_hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {};
+const void * const _hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {};
#endif
int