Separate GlyphID from HBUINT16
authorBehdad Esfahbod <behdad@behdad.org>
Mon, 31 Dec 2018 01:24:21 +0000 (20:24 -0500)
committerBehdad Esfahbod <behdad@behdad.org>
Mon, 21 Jan 2019 01:12:12 +0000 (20:12 -0500)
For stricter enforcement.

src/hb-dsalgs.hh
src/hb-open-type.hh
src/hb-ot-layout-common.hh
src/hb-ot-shape-complex-arabic-fallback.hh

index 1d102c3..a7d9616 100644 (file)
@@ -497,8 +497,8 @@ static inline void hb_sort_r(void *base, size_t nel, size_t width,
 }
 
 
-template <typename T, typename T2> static inline void
-hb_stable_sort (T *array, unsigned int len, int(*compar)(const T *, const T *), T2 *array2)
+template <typename T, typename T2, typename T3> static inline void
+hb_stable_sort (T *array, unsigned int len, int(*compar)(const T2 *, const T2 *), T3 *array2)
 {
   for (unsigned int i = 1; i < len; i++)
   {
@@ -515,8 +515,8 @@ hb_stable_sort (T *array, unsigned int len, int(*compar)(const T *, const T *),
     }
     if (array2)
     {
-      T2 t = array2[i];
-      memmove (&array2[j + 1], &array2[j], (i - j) * sizeof (T2));
+      T3 t = array2[i];
+      memmove (&array2[j + 1], &array2[j], (i - j) * sizeof (T3));
       array2[j] = t;
     }
   }
index 7edd953..a47eb74 100644 (file)
@@ -151,7 +151,7 @@ struct Tag : HBUINT32
 };
 
 /* Glyph index number, same as uint16 (length = 16 bits) */
-typedef HBUINT16 GlyphID;
+struct GlyphID : HBUINT16 {};
 
 /* Script/language-system/feature index */
 struct Index : HBUINT16 {
index 14cb0be..921fb88 100644 (file)
@@ -1208,7 +1208,7 @@ struct ClassDefFormat1
   }
 
   bool serialize (hb_serialize_context_t *c,
-                 hb_array_t<const HBUINT16> glyphs,
+                 hb_array_t<const GlyphID> glyphs,
                  hb_array_t<const HBUINT16> klasses)
   {
     TRACE_SERIALIZE (this);
index 2a1f2f8..74eebc5 100644 (file)
@@ -77,7 +77,9 @@ arabic_fallback_synthesize_lookup_single (const hb_ot_shape_plan_t *plan HB_UNUS
 
   /* Bubble-sort or something equally good!
    * May not be good-enough for presidential candidate interviews, but good-enough for us... */
-  hb_stable_sort (&glyphs[0], num_glyphs, (int(*)(const OT::GlyphID*, const OT::GlyphID *)) OT::GlyphID::cmp, &substitutes[0]);
+  hb_stable_sort (&glyphs[0], num_glyphs,
+                 (int(*)(const OT::HBUINT16*, const OT::HBUINT16 *)) OT::GlyphID::cmp,
+                 &substitutes[0]);
 
 
   /* Each glyph takes four bytes max, and there's some overhead. */
@@ -123,7 +125,9 @@ arabic_fallback_synthesize_lookup_ligature (const hb_ot_shape_plan_t *plan HB_UN
     first_glyphs_indirection[num_first_glyphs] = first_glyph_idx;
     num_first_glyphs++;
   }
-  hb_stable_sort (&first_glyphs[0], num_first_glyphs, (int(*)(const OT::GlyphID*, const OT::GlyphID *)) OT::GlyphID::cmp, &first_glyphs_indirection[0]);
+  hb_stable_sort (&first_glyphs[0], num_first_glyphs,
+                 (int(*)(const OT::HBUINT16*, const OT::HBUINT16 *)) OT::GlyphID::cmp,
+                 &first_glyphs_indirection[0]);
 
   /* Now that the first-glyphs are sorted, walk again, populate ligatures. */
   for (unsigned int i = 0; i < num_first_glyphs; i++)