From e76061a7372077d063432548e2fb85db5fad8670 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 18 Feb 2022 17:27:19 -0600 Subject: [PATCH] [hb-style] Fix synthetic slant values When reporting the slant ratio of a font that has synthetic slant set, we were reporting twice the expected value. Fix that. Test included. --- src/hb-style.cc | 3 +-- test/api/test-style.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/hb-style.cc b/src/hb-style.cc index c0c5c4832..ee2ffc497 100644 --- a/src/hb-style.cc +++ b/src/hb-style.cc @@ -72,8 +72,7 @@ float hb_style_get_value (hb_font_t *font, hb_style_tag_t style_tag) { if (unlikely (style_tag == HB_STYLE_TAG_SLANT_RATIO)) - return _hb_angle_to_ratio (hb_style_get_value (font, HB_STYLE_TAG_SLANT_ANGLE)) - + font->slant; + return _hb_angle_to_ratio (hb_style_get_value (font, HB_STYLE_TAG_SLANT_ANGLE)); hb_face_t *face = font->face; diff --git a/test/api/test-style.c b/test/api/test-style.c index 73accfb35..b4f91ea36 100644 --- a/test/api/test-style.c +++ b/test/api/test-style.c @@ -147,6 +147,22 @@ test_face_user_setting (void) hb_face_destroy (face); } +static void +test_synthetic_slant (void) +{ + hb_face_t *face = hb_test_open_font_file ("fonts/AdobeVFPrototype_vsindex.otf"); + hb_font_t *font = hb_font_create (face); + + assert_cmpfloat (hb_style_get_value (font, HB_STYLE_TAG_SLANT_RATIO), 0); + + hb_font_set_synthetic_slant (font, 0.2); + + assert_cmpfloat (hb_style_get_value (font, HB_STYLE_TAG_SLANT_RATIO), 0.2); + + hb_font_destroy (font); + hb_face_destroy (face); +} + int main (int argc, char **argv) { @@ -155,6 +171,7 @@ main (int argc, char **argv) hb_test_add (test_empty_face); hb_test_add (test_regular_face); hb_test_add (test_face_user_setting); + hb_test_add (test_synthetic_slant); return hb_test_run (); }