[layout] Fix comparison of GlyphID and hb_codepoint_t
authorBehdad Esfahbod <behdad@behdad.org>
Sat, 21 Feb 2015 09:50:01 +0000 (12:50 +0300)
committerBehdad Esfahbod <behdad@behdad.org>
Wed, 25 Feb 2015 23:43:34 +0000 (15:43 -0800)
Before, the IntType::cmp functions providing this and was truncating
the hb_codepoint_t to 16bits before comparison.  I have no idea how
this was never discovered, and I'm too lazy to try to reproduce this
with Pango (which uses non-16bit codepoint numbers for missing glyphs).

src/hb-open-type-private.hh

index 0989a8b..75a0f56 100644 (file)
@@ -660,7 +660,10 @@ struct Tag : ULONG
 DEFINE_NULL_DATA (Tag, "    ");
 
 /* Glyph index number, same as uint16 (length = 16 bits) */
-typedef USHORT GlyphID;
+struct GlyphID : USHORT {
+  static inline int cmp (const GlyphID *a, const GlyphID *b) { return b->USHORT::cmp (*a); }
+  inline int cmp (hb_codepoint_t a) const { return (int) a - (int) *this; }
+};
 
 /* Script/language-system/feature index */
 struct Index : USHORT {