diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index ee76d7ed8..0038ad8b7 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -52,13 +52,19 @@ namespace OT { * Int types */ +template struct hb_signedness_int; +template <> struct hb_signedness_int { typedef unsigned int value; }; +template <> struct hb_signedness_int { typedef signed int value; }; + /* Integer types in big-endian order and no alignment requirement */ template struct IntType { typedef Type type; - inline void set (Type i) { v.set (i); } - inline operator Type (void) const { return v; } + typedef typename hb_signedness_int::value>::value wide_type; + + inline void set (wide_type i) { v.set (i); } + inline operator wide_type (void) const { return v; } inline bool operator == (const IntType &o) const { return (Type) v == (Type) o.v; } inline bool operator != (const IntType &o) const { return !(*this == o); } static inline int cmp (const IntType *a, const IntType *b) { return b->cmp (*a); } @@ -88,6 +94,8 @@ typedef IntType HBUINT16; /* 16-bit unsigned integer. */ typedef IntType HBINT16; /* 16-bit signed integer. */ typedef IntType HBUINT32; /* 32-bit unsigned integer. */ typedef IntType HBINT32; /* 32-bit signed integer. */ +/* Note: we cannot defined a signed HBINT24 because there's no corresponding C type. + * Works for unsigned, but not signed, since we rely on compiler for sign-extension. */ typedef IntType HBUINT24; /* 24-bit unsigned integer. */ /* 16-bit signed integer (HBINT16) that describes a quantity in FUnits. */