From a51aa951b5ad8da4ac7effc891437345e012a0ac Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Mon, 22 Jul 2019 18:35:55 +0430 Subject: [PATCH] [metrics] Fix _get_variation API to works with actual coord values --- src/hb-ot-metrics.cc | 16 ++++++++-------- src/hb-ot-metrics.h | 2 +- test/api/test-ot-metrics.c | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/hb-ot-metrics.cc b/src/hb-ot-metrics.cc index c343f6d..910d826 100644 --- a/src/hb-ot-metrics.cc +++ b/src/hb-ot-metrics.cc @@ -56,7 +56,7 @@ _hb_ot_metrics_get_position_common (hb_font_t *font, switch ((unsigned int) metrics_tag) { #ifndef HB_NO_VAR -#define GET_VAR face->table.MVAR->get_var (metrics_tag, nullptr, 0) +#define GET_VAR face->table.MVAR->get_var (metrics_tag, font->coords, font->num_coords) #else #define GET_VAR .0f #endif @@ -95,7 +95,7 @@ _get_gasp (hb_face_t *face, float *result, hb_ot_metrics_t metrics_tag) { const OT::GaspRange& range = face->table.gasp->get_gasp_range (metrics_tag - HB_TAG ('g','s','p','0')); if (&range == &Null (OT::GaspRange)) return false; - if (result) *result = range.rangeMaxPPEM + face->table.MVAR->get_var (metrics_tag, nullptr, 0); + if (result) *result = range.rangeMaxPPEM + font->face->table.MVAR->get_var (metrics_tag, font->coords, font->num_coords); return true; } #endif @@ -126,7 +126,7 @@ hb_ot_metrics_get_position (hb_font_t *font, case HB_OT_METRICS_VERTICAL_DESCENDER: case HB_OT_METRICS_VERTICAL_LINE_GAP: return _hb_ot_metrics_get_position_common (font, metrics_tag, position); #ifndef HB_NO_VAR -#define GET_VAR hb_ot_metrics_get_variation (face, metrics_tag) +#define GET_VAR hb_ot_metrics_get_variation (font, metrics_tag) #else #define GET_VAR 0 #endif @@ -168,7 +168,7 @@ hb_ot_metrics_get_position (hb_font_t *font, #ifndef HB_NO_VAR /** * hb_ot_metrics_get_variation: - * @face: + * @font: * @metrics_tag: * * Returns: @@ -176,9 +176,9 @@ hb_ot_metrics_get_position (hb_font_t *font, * Since: REPLACEME **/ float -hb_ot_metrics_get_variation (hb_face_t *face, hb_ot_metrics_t metrics_tag) +hb_ot_metrics_get_variation (hb_font_t *font, hb_ot_metrics_t metrics_tag) { - return face->table.MVAR->get_var (metrics_tag, nullptr, 0); + return font->face->table.MVAR->get_var (metrics_tag, font->coords, font->num_coords); } /** @@ -193,7 +193,7 @@ hb_ot_metrics_get_variation (hb_face_t *face, hb_ot_metrics_t metrics_tag) hb_position_t hb_ot_metrics_get_x_variation (hb_font_t *font, hb_ot_metrics_t metrics_tag) { - return font->em_scalef_x (hb_ot_metrics_get_variation (font->face, metrics_tag)); + return font->em_scalef_x (hb_ot_metrics_get_variation (font, metrics_tag)); } /** @@ -208,7 +208,7 @@ hb_ot_metrics_get_x_variation (hb_font_t *font, hb_ot_metrics_t metrics_tag) hb_position_t hb_ot_metrics_get_y_variation (hb_font_t *font, hb_ot_metrics_t metrics_tag) { - return font->em_scalef_y (hb_ot_metrics_get_variation (font->face, metrics_tag)); + return font->em_scalef_y (hb_ot_metrics_get_variation (font, metrics_tag)); } #endif diff --git a/src/hb-ot-metrics.h b/src/hb-ot-metrics.h index 611222f..4d22837 100644 --- a/src/hb-ot-metrics.h +++ b/src/hb-ot-metrics.h @@ -79,7 +79,7 @@ hb_ot_metrics_get_position (hb_font_t *font, hb_position_t *position /* OUT. May be NULL. */); HB_EXTERN float -hb_ot_metrics_get_variation (hb_face_t *face, hb_ot_metrics_t metrics_tag); +hb_ot_metrics_get_variation (hb_font_t *font, hb_ot_metrics_t metrics_tag); HB_EXTERN hb_position_t hb_ot_metrics_get_x_variation (hb_font_t *font, hb_ot_metrics_t metrics_tag); diff --git a/test/api/test-ot-metrics.c b/test/api/test-ot-metrics.c index 270de88..91dd7f5 100644 --- a/test/api/test-ot-metrics.c +++ b/test/api/test-ot-metrics.c @@ -40,7 +40,7 @@ test_ot_metrics_get (void) g_assert_cmpint (value, ==, 1000); g_assert_cmpint (hb_ot_metrics_get_x_variation (font, HB_OT_METRICS_HORIZONTAL_ASCENDER), ==, 0); g_assert_cmpint (hb_ot_metrics_get_y_variation (font, HB_OT_METRICS_HORIZONTAL_ASCENDER), ==, 0); - // g_assert_cmpint ((int) hb_ot_metrics_get_variation (face, HB_OT_METRICS_HORIZONTAL_ASCENDER), ==, 0); + // g_assert_cmpint ((int) hb_ot_metrics_get_variation (font, HB_OT_METRICS_HORIZONTAL_ASCENDER), ==, 0); hb_font_destroy (font); hb_face_destroy (face); } -- 2.7.4