From 42a2b496e428521151ff5cb07454d2e993f892cc Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod <behdad@behdad.org> Date: Wed, 28 Nov 2018 15:24:30 -0500 Subject: [PATCH] [kerx] Fix Format2 index calc again --- src/hb-aat-layout-common.hh | 14 ++++++++++++++ src/hb-aat-layout-kerx-table.hh | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/hb-aat-layout-common.hh b/src/hb-aat-layout-common.hh index 253b56fea..c0b0e3751 100644 --- a/src/hb-aat-layout-common.hh +++ b/src/hb-aat-layout-common.hh @@ -689,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) @@ -712,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) diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh index abd577b9d..7caf45d5d 100644 --- a/src/hb-aat-layout-kerx-table.hh +++ b/src/hb-aat-layout-kerx-table.hh @@ -255,7 +255,7 @@ struct KerxSubTableFormat1 unsigned int tuple_count = MAX (1u, table->header.tuple_count ()); unsigned int kern_idx = Format1EntryT::kernActionIndex (entry); - kern_idx = Types::offsetToIndex (kern_idx, &table->machine, kernAction.arrayZ); + kern_idx = Types::byteOffsetToIndex (kern_idx, &table->machine, kernAction.arrayZ); const FWORD *actions = &kernAction[kern_idx]; if (!c->sanitizer.check_array (actions, depth, tuple_count)) {