[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.
pull/3457/head
Matthias Clasen 3 years ago committed by Behdad Esfahbod
parent 56f11ec938
commit e76061a737
  1. 3
      src/hb-style.cc
  2. 17
      test/api/test-style.c

@ -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;

@ -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 ();
}

Loading…
Cancel
Save