[hb-style] Fix the sign of slant ratios
We want negative slant angles to yield positive slant ratios. Fix that. Test included.
This commit is contained in:
parent
e76061a737
commit
16b232be0e
|
@ -46,13 +46,13 @@
|
||||||
static inline float
|
static inline float
|
||||||
_hb_angle_to_ratio (float a)
|
_hb_angle_to_ratio (float a)
|
||||||
{
|
{
|
||||||
return tanf (a * float (M_PI / 180.));
|
return - tanf (a * float (M_PI / 180.));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline float
|
static inline float
|
||||||
_hb_ratio_to_angle (float r)
|
_hb_ratio_to_angle (float r)
|
||||||
{
|
{
|
||||||
return atanf (r) * float (180. / M_PI);
|
return - atanf (r) * float (180. / M_PI);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -43,8 +43,10 @@ HB_BEGIN_DECLS
|
||||||
* @HB_STYLE_TAG_SLANT_ANGLE: Used to vary between upright and slanted text. Values
|
* @HB_STYLE_TAG_SLANT_ANGLE: Used to vary between upright and slanted text. Values
|
||||||
* must be greater than -90 and less than +90. Values can be interpreted as
|
* must be greater than -90 and less than +90. Values can be interpreted as
|
||||||
* the angle, in counter-clockwise degrees, of oblique slant from whatever the
|
* the angle, in counter-clockwise degrees, of oblique slant from whatever the
|
||||||
* designer considers to be upright for that font design.
|
* designer considers to be upright for that font design. Typical right-leaning
|
||||||
|
* Italic fonts have a negative slant angle (typically around -12)
|
||||||
* @HB_STYLE_TAG_SLANT_RATIO: same as @HB_STYLE_TAG_SLANT_ANGLE expression as ratio.
|
* @HB_STYLE_TAG_SLANT_RATIO: same as @HB_STYLE_TAG_SLANT_ANGLE expression as ratio.
|
||||||
|
* Typical right-leaning Italic fonts have a positive slant ratio (typically around 0.2)
|
||||||
* @HB_STYLE_TAG_WIDTH: Used to vary width of text from narrower to wider.
|
* @HB_STYLE_TAG_WIDTH: Used to vary width of text from narrower to wider.
|
||||||
* Non-zero. Values can be interpreted as a percentage of whatever the font
|
* Non-zero. Values can be interpreted as a percentage of whatever the font
|
||||||
* designer considers “normal width” for that font design.
|
* designer considers “normal width” for that font design.
|
||||||
|
|
|
@ -161,6 +161,18 @@ test_synthetic_slant (void)
|
||||||
|
|
||||||
hb_font_destroy (font);
|
hb_font_destroy (font);
|
||||||
hb_face_destroy (face);
|
hb_face_destroy (face);
|
||||||
|
|
||||||
|
face = hb_test_open_font_file ("fonts/notosansitalic.ttf");
|
||||||
|
font = hb_font_create (face);
|
||||||
|
|
||||||
|
/* We expect a negative angle for a typical italic font,
|
||||||
|
* which should give us a positive ratio
|
||||||
|
*/
|
||||||
|
assert_cmpfloat (hb_style_get_value (font, HB_STYLE_TAG_SLANT_ANGLE), -12);
|
||||||
|
assert_cmpfloat (hb_style_get_value (font, HB_STYLE_TAG_SLANT_RATIO), 0.21);
|
||||||
|
|
||||||
|
hb_font_destroy (font);
|
||||||
|
hb_face_destroy (face);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Reference in New Issue