From 89018068cd4e247d556d42a501a7ffa8e6c9ef52 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 22 Jul 2021 11:59:23 -0700 Subject: [PATCH] [fvar] Centralize axis finding logic Part of fixing https://github.com/harfbuzz/harfbuzz/issues/1673 --- src/hb-ot-var-fvar-table.hh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh index 63ce483a8..676e04832 100644 --- a/src/hb-ot-var-fvar-table.hh +++ b/src/hb-ot-var-fvar-table.hh @@ -211,17 +211,24 @@ struct fvar if (!axis_index) axis_index = &i; *axis_index = HB_OT_VAR_NO_AXIS_INDEX; auto axes = get_axes (); - return axes.lfind (tag, axis_index) && (axes[*axis_index].get_axis_deprecated (info), true); + return find_axis_index (tag, axis_index) && (axes[*axis_index].get_axis_deprecated (info), true); } #endif + /* Returns index of the first occurence of tag, if there are multiple ones. */ + bool + find_axis_index (hb_tag_t tag, unsigned *axis_index) const + { + auto axes = get_axes (); + /* TODO bfind() for larger array? Should then look back to find first entry for tag. */ + return axes.lfind (tag, axis_index); + } bool find_axis_info (hb_tag_t tag, hb_ot_var_axis_info_t *info) const { unsigned i; auto axes = get_axes (); - /* TODO bfind() for larger array? Should then look back to find first entry for tag. */ - return axes.lfind (tag, &i) && (axes[i].get_axis_info (i, info), true); + return find_axis_index (tag, &i) && (axes[i].get_axis_info (i, info), true); } int normalize_axis_value (unsigned int axis_index, float v) const