[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.
This commit is contained in:
Matthias Clasen 2022-02-18 17:27:19 -06:00 committed by Behdad Esfahbod
parent 56f11ec938
commit e76061a737
2 changed files with 18 additions and 2 deletions

View File

@ -72,8 +72,7 @@ float
hb_style_get_value (hb_font_t *font, hb_style_tag_t style_tag) hb_style_get_value (hb_font_t *font, hb_style_tag_t style_tag)
{ {
if (unlikely (style_tag == HB_STYLE_TAG_SLANT_RATIO)) if (unlikely (style_tag == HB_STYLE_TAG_SLANT_RATIO))
return _hb_angle_to_ratio (hb_style_get_value (font, HB_STYLE_TAG_SLANT_ANGLE)) return _hb_angle_to_ratio (hb_style_get_value (font, HB_STYLE_TAG_SLANT_ANGLE));
+ font->slant;
hb_face_t *face = font->face; hb_face_t *face = font->face;

View File

@ -147,6 +147,22 @@ test_face_user_setting (void)
hb_face_destroy (face); 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 int
main (int argc, char **argv) main (int argc, char **argv)
{ {
@ -155,6 +171,7 @@ main (int argc, char **argv)
hb_test_add (test_empty_face); hb_test_add (test_empty_face);
hb_test_add (test_regular_face); hb_test_add (test_regular_face);
hb_test_add (test_face_user_setting); hb_test_add (test_face_user_setting);
hb_test_add (test_synthetic_slant);
return hb_test_run (); return hb_test_run ();
} }