From 810f5d71c71ab59f4b1257e18b81551de49f3ee5 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 18 Dec 2021 15:12:26 -0700 Subject: [PATCH] [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 --- src/hb-font.cc | 41 ++++++++++++++++++++++++++++++++++++++++- src/hb-font.h | 6 ++++++ src/hb-font.hh | 1 + 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/hb-font.cc b/src/hb-font.cc index fa8da9639..dd1a31508 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -1477,6 +1477,7 @@ DEFINE_NULL_INSTANCE (hb_font_t) = 1000, /* x_scale */ 1000, /* y_scale */ + 0., /* slant */ 1<<16, /* x_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->y_scale = parent->y_scale; + font->slant = parent->slant; font->mults_changed (); font->x_ppem = parent->x_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." * - * Since: 0.9.2 + * Since: 1.6.0 **/ float hb_font_get_ptem (hb_font_t *font) @@ -2023,6 +2025,43 @@ hb_font_get_ptem (hb_font_t *font) 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: XXX There are 72 points in an inch. + * + * 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 /* * Variations diff --git a/src/hb-font.h b/src/hb-font.h index 15dc12652..ff2e7df54 100644 --- a/src/hb-font.h +++ b/src/hb-font.h @@ -1023,6 +1023,12 @@ hb_font_set_ptem (hb_font_t *font, float ptem); HB_EXTERN float 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_font_set_variations (hb_font_t *font, const hb_variation_t *variations, diff --git a/src/hb-font.hh b/src/hb-font.hh index 1b7f445e8..248d85deb 100644 --- a/src/hb-font.hh +++ b/src/hb-font.hh @@ -109,6 +109,7 @@ struct hb_font_t int32_t x_scale; int32_t y_scale; + float slant; int64_t x_mult; int64_t y_mult;