diff options
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common.hh')
-rw-r--r-- | Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common.hh | 72 |
1 files changed, 48 insertions, 24 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common.hh index 6572b26d86f..c0b0e3751f3 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-aat-layout-common.hh @@ -69,13 +69,15 @@ struct LookupFormat0 UnsizedArrayOf<T> arrayZ; /* Array of lookup values, indexed by glyph index. */ public: - DEFINE_SIZE_ARRAY (2, arrayZ); + DEFINE_SIZE_UNBOUNDED (2); }; template <typename T> struct LookupSegmentSingle { + enum { TerminationWordCount = 2 }; + inline int cmp (hb_codepoint_t g) const { return g < first ? -1 : g <= last ? 0 : +1 ; } @@ -134,6 +136,8 @@ struct LookupFormat2 template <typename T> struct LookupSegmentArray { + enum { TerminationWordCount = 2 }; + inline const T* get_value (hb_codepoint_t glyph_id, const void *base) const { return first <= glyph_id && glyph_id <= last ? &(base+valuesZ)[glyph_id - first] : nullptr; @@ -204,6 +208,8 @@ struct LookupFormat4 template <typename T> struct LookupSingle { + enum { TerminationWordCount = 1 }; + inline int cmp (hb_codepoint_t g) const { return glyph.cmp (g); } inline bool sanitize (hb_sanitize_context_t *c) const @@ -357,6 +363,14 @@ struct Lookup } } + inline typename T::type get_class (hb_codepoint_t glyph_id, + unsigned int num_glyphs, + unsigned int outOfRange) const + { + const T *v = get_value (glyph_id, num_glyphs); + return v ? *v : outOfRange; + } + inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); @@ -436,8 +450,10 @@ struct Entry * which ensures that data has a simple sanitize(). To be determined * if I need to remove that as well. * - * XXX Because we are a template, our DEFINE_SIZE_STATIC assertion - * wouldn't be checked. */ + * HOWEVER! Because we are a template, our DEFINE_SIZE_STATIC + * assertion wouldn't be checked, hence the line below. */ + static_assert (T::static_size, ""); + return_trace (c->check_struct (this)); } @@ -472,7 +488,7 @@ struct StateTable { typedef typename Types::HBUINT HBUINT; typedef typename Types::HBUSHORT HBUSHORT; - typedef typename Types::ClassType ClassType; + typedef typename Types::ClassTypeNarrow ClassType; enum State { @@ -630,6 +646,7 @@ struct StateTable DEFINE_SIZE_STATIC (4 * sizeof (HBUINT)); }; +template <typename HBUCHAR> struct ClassTable { inline unsigned int get_class (hb_codepoint_t glyph_id, unsigned int outOfRange) const @@ -637,6 +654,12 @@ struct ClassTable unsigned int i = glyph_id - firstGlyph; return i >= classArray.len ? outOfRange : classArray.arrayZ[i]; } + inline unsigned int get_class (hb_codepoint_t glyph_id, + unsigned int num_glyphs HB_UNUSED, + unsigned int outOfRange) const + { + return get_class (glyph_id, outOfRange); + } inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); @@ -644,7 +667,7 @@ struct ClassTable } protected: GlyphID firstGlyph; /* First glyph index included in the trimmed array. */ - ArrayOf<HBUINT8> classArray; /* The class codes (indexed by glyph index minus + ArrayOf<HBUCHAR> classArray; /* The class codes (indexed by glyph index minus * firstGlyph). */ public: DEFINE_SIZE_ARRAY (4, classArray); @@ -655,15 +678,9 @@ struct ObsoleteTypes static const bool extended = false; typedef HBUINT16 HBUINT; typedef HBUINT8 HBUSHORT; - struct ClassType : ClassTable - { - inline unsigned int get_class (hb_codepoint_t glyph_id, - unsigned int num_glyphs HB_UNUSED, - unsigned int outOfRange) const - { - return ClassTable::get_class (glyph_id, outOfRange); - } - }; + typedef ClassTable<HBUINT8> ClassTypeNarrow; + typedef ClassTable<HBUINT16> ClassTypeWide; + template <typename T> static inline unsigned int offsetToIndex (unsigned int offset, const void *base, @@ -672,6 +689,13 @@ struct ObsoleteTypes return (offset - ((const char *) array - (const char *) base)) / sizeof (T); } template <typename T> + static inline unsigned int byteOffsetToIndex (unsigned int offset, + const void *base, + const T *array) + { + return offsetToIndex (offset, base, array); + } + template <typename T> static inline unsigned int wordOffsetToIndex (unsigned int offset, const void *base, const T *array) @@ -684,16 +708,9 @@ struct ExtendedTypes static const bool extended = true; typedef HBUINT32 HBUINT; typedef HBUINT16 HBUSHORT; - struct ClassType : Lookup<HBUINT16> - { - inline unsigned int get_class (hb_codepoint_t glyph_id, - unsigned int num_glyphs, - unsigned int outOfRange) const - { - const HBUINT16 *v = get_value (glyph_id, num_glyphs); - return v ? *v : outOfRange; - } - }; + typedef Lookup<HBUINT16> ClassTypeNarrow; + typedef Lookup<HBUINT16> ClassTypeWide; + template <typename T> static inline unsigned int offsetToIndex (unsigned int offset, const void *base, @@ -702,6 +719,13 @@ struct ExtendedTypes return offset; } template <typename T> + static inline unsigned int byteOffsetToIndex (unsigned int offset, + const void *base, + const T *array) + { + return offset / 2; + } + template <typename T> static inline unsigned int wordOffsetToIndex (unsigned int offset, const void *base, const T *array) |