[font] Add public API for slant

Not hooked up internally to anything.

New API:

+ hb_font_set_synthetic_slant()
+ hb_font_get_synthetic_slant()

Part of fixing https://github.com/harfbuzz/harfbuzz/issues/3196
This commit is contained in:
Behdad Esfahbod 2021-12-18 15:12:26 -07:00
parent 067f90a820
commit 810f5d71c7
3 changed files with 47 additions and 1 deletions

View File

@ -1477,6 +1477,7 @@ DEFINE_NULL_INSTANCE (hb_font_t) =
1000, /* x_scale */ 1000, /* x_scale */
1000, /* y_scale */ 1000, /* y_scale */
0., /* slant */
1<<16, /* x_mult */ 1<<16, /* x_mult */
1<<16, /* y_mult */ 1<<16, /* y_mult */
@ -1578,6 +1579,7 @@ hb_font_create_sub_font (hb_font_t *parent)
font->x_scale = parent->x_scale; font->x_scale = parent->x_scale;
font->y_scale = parent->y_scale; font->y_scale = parent->y_scale;
font->slant = parent->slant;
font->mults_changed (); font->mults_changed ();
font->x_ppem = parent->x_ppem; font->x_ppem = parent->x_ppem;
font->y_ppem = parent->y_ppem; font->y_ppem = parent->y_ppem;
@ -2015,7 +2017,7 @@ hb_font_set_ptem (hb_font_t *font,
* *
* Return value: Point size. A value of zero means "not set." * Return value: Point size. A value of zero means "not set."
* *
* Since: 0.9.2 * Since: 1.6.0
**/ **/
float float
hb_font_get_ptem (hb_font_t *font) hb_font_get_ptem (hb_font_t *font)
@ -2023,6 +2025,43 @@ hb_font_get_ptem (hb_font_t *font)
return font->ptem; return font->ptem;
} }
/**
* hb_font_set_synthetic_slant:
* @font: #hb_font_t to work upon
* @ptem: font size in points.
*
* Sets the XXX "point size" of a font. By default is zero.
*
* <note>Note: XXX There are 72 points in an inch.</note>
*
* Since: REPLACEME
**/
HB_EXTERN void
hb_font_set_synthetic_slant (hb_font_t *font, float slant)
{
if (hb_object_is_immutable (font))
return;
font->slant = slant;
font->mults_changed ();
}
/**
* hb_font_get_synthetic_slant:
* @font: #hb_font_t to work upon
*
* Fetches the "point size" of a font.
*
* Return value: XXX Point size. By default is zero.
*
* Since: REPLACEME
**/
HB_EXTERN float
hb_font_get_synthetic_slant (hb_font_t *font)
{
return font->slant;
}
#ifndef HB_NO_VAR #ifndef HB_NO_VAR
/* /*
* Variations * Variations

View File

@ -1023,6 +1023,12 @@ hb_font_set_ptem (hb_font_t *font, float ptem);
HB_EXTERN float HB_EXTERN float
hb_font_get_ptem (hb_font_t *font); hb_font_get_ptem (hb_font_t *font);
HB_EXTERN void
hb_font_set_synthetic_slant (hb_font_t *font, float slant);
HB_EXTERN float
hb_font_get_synthetic_slant (hb_font_t *font);
HB_EXTERN void HB_EXTERN void
hb_font_set_variations (hb_font_t *font, hb_font_set_variations (hb_font_t *font,
const hb_variation_t *variations, const hb_variation_t *variations,

View File

@ -109,6 +109,7 @@ struct hb_font_t
int32_t x_scale; int32_t x_scale;
int32_t y_scale; int32_t y_scale;
float slant;
int64_t x_mult; int64_t x_mult;
int64_t y_mult; int64_t y_mult;