+/*
+ * Copyright (C) 2007,2008 Red Hat, Inc.
+ *
+ * This is part of HarfBuzz, an OpenType Layout engine library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Red Hat Author(s): Behdad Esfahbod
+ */
+
#ifndef HB_OT_LAYOUT_OPEN_PRIVATE_H
#define HB_OT_LAYOUT_OPEN_PRIVATE_H
#include "hb-private.h"
#include "hb-ot-layout.h"
-#include <glib.h>
-
-/* Macros to convert to/from BigEndian */
-#define hb_be_uint8_t
-#define hb_be_int8_t
-#define hb_be_uint16_t GUINT16_TO_BE
-#define hb_be_int16_t GINT16_TO_BE
-#define hb_be_uint32_t GUINT32_TO_BE
-#define hb_be_int32_t GINT32_TO_BE
-#define hb_be_uint64_t GUINT64_TO_BE
-#define hb_be_int64_t GINT64_TO_BE
/*
* Int types
DEFINE_LEN_AND_SIZE(Type, array, num)
#define DEFINE_INDEX_OPERATOR(Type, array, num) \
inline const Type& operator[] (unsigned int i) const { \
- if (i >= num) return Null##Type; \
+ if (HB_UNLIKELY (i >= num)) return Null##Type; \
return array[i]; \
}
DEFINE_LEN_AND_SIZE(Offset, array, num)
#define DEFINE_OFFSET_INDEX_OPERATOR(Type, array, num) \
inline const Type& operator[] (unsigned int i) const { \
- if (i >= num) return Null##Type; \
- if (!array[i]) return Null##Type; \
+ if (HB_UNLIKELY (i >= num)) return Null##Type; \
+ if (HB_UNLIKELY (!array[i])) return Null##Type; \
return *(const Type *)((const char*)this + array[i]); \
}
DEFINE_LEN_AND_SIZE(Record, array, num)
#define DEFINE_RECORD_ACCESSOR(Type, array, num) \
inline const Type& operator[] (unsigned int i) const { \
- if (i >= num) return Null##Type; \
- if (!array[i].offset) return Null##Type; \
+ if (HB_UNLIKELY (i >= num)) return Null##Type; \
+ if (HB_UNLIKELY (!array[i].offset)) return Null##Type; \
return *(const Type *)((const char*)this + array[i].offset); \
} \
inline const Tag& get_tag (unsigned int i) const { \
- if (i >= num) return NullTag; \
+ if (HB_UNLIKELY (i >= num)) return NullTag; \
return array[i].tag; \
} \
/* TODO: implement find_tag() */
#define DEFINE_LIST_ACCESSOR(Type, name) \
inline const Type##List& get_##name##_list (void) const { \
- if (!name##List) return Null##Type##List; \
+ if (HB_UNLIKELY (!name##List)) return Null##Type##List; \
return *(const Type##List *)((const char*)this + name##List); \
} \
inline const Type& get_##name (unsigned int i) const { \
#define DEFINE_ACCESSOR(Type, name, Name) \
inline const Type& name (void) const { \
- if (!Name) return Null##Type; \
+ if (HB_UNLIKELY (!Name)) return Null##Type; \
return *(const Type*)((const char*)this + Name); \
}
struct TTCHeader {
/* OpenTypeFontFaces, in no particular order */
DEFINE_OFFSET_ARRAY_TYPE (OffsetTable, offsetTable, numFonts);
+ /* XXX check version here */
private:
Tag ttcTag; /* TrueType Collection ID string: 'ttcf' */
}
}
inline const OpenTypeFontFace& operator[] (unsigned int i) const {
- if (i >= get_len ()) return NullOpenTypeFontFace;
+ if (HB_UNLIKELY (i >= get_len ())) return NullOpenTypeFontFace;
switch (tag) {
default: case TrueTypeTag: case CFFTag: return (const OffsetTable&)*this;
case TTCTag: return ((const TTCHeader&)*this)[i];
return defaultLangSys != 0;
}
inline const LangSys& get_default_language_system (void) const {
- if (!defaultLangSys)
+ if (HB_UNLIKELY (!defaultLangSys))
return NullLangSys;
return *(LangSys*)((const char*)this + defaultLangSys);
}
GlyphID gid;
gid = glyph_id;
// TODO: bsearch
- for (int i = 0; i < glyphCount; i++)
+ for (unsigned int i = 0; i < glyphCount; i++)
if (gid == glyphArray[i])
return i;
return -1;
inline int get_coverage (uint16_t glyph_id) const {
// TODO: bsearch
- for (int i = 0; i < rangeCount; i++) {
+ for (unsigned int i = 0; i < rangeCount; i++) {
int coverage = rangeRecord[i].get_coverage (glyph_id);
if (coverage >= 0)
return coverage;
static const hb_tag_t GPOSTag = HB_TAG ('G','P','O','S');
STATIC_DEFINE_GET_FOR_DATA (GSUBGPOSHeader);
+ /* XXX check version here */
DEFINE_LIST_ACCESSOR(Script, script); /* get_script_list, get_script(i) */
DEFINE_LIST_ACCESSOR(Feature, feature);/* get_feature_list, get_feature(i) */