From a685bfe8fc93ac1886a708687ea6fa7aa0b7c8c4 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 30 Dec 2018 20:24:21 -0500 Subject: [PATCH] Separate GlyphID from HBUINT16 For stricter enforcement. --- src/hb-dsalgs.hh | 8 ++++---- src/hb-open-type.hh | 2 +- src/hb-ot-layout-common.hh | 2 +- src/hb-ot-shape-complex-arabic-fallback.hh | 8 ++++++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh index 1d102c3..a7d9616 100644 --- a/src/hb-dsalgs.hh +++ b/src/hb-dsalgs.hh @@ -497,8 +497,8 @@ static inline void hb_sort_r(void *base, size_t nel, size_t width, } -template static inline void -hb_stable_sort (T *array, unsigned int len, int(*compar)(const T *, const T *), T2 *array2) +template 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; } } diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index 7edd953..a47eb74 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -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 { diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index 14cb0be..921fb88 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -1208,7 +1208,7 @@ struct ClassDefFormat1 } bool serialize (hb_serialize_context_t *c, - hb_array_t glyphs, + hb_array_t glyphs, hb_array_t klasses) { TRACE_SERIALIZE (this); diff --git a/src/hb-ot-shape-complex-arabic-fallback.hh b/src/hb-ot-shape-complex-arabic-fallback.hh index 2a1f2f8..74eebc5 100644 --- a/src/hb-ot-shape-complex-arabic-fallback.hh +++ b/src/hb-ot-shape-complex-arabic-fallback.hh @@ -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++) -- 2.7.4