Add hb_font_[sg]et_ptem() to set/get point size on font

New API:
hb_font_set_ptem()
hb_font_get_ptem()

Needed for hb-coretext optical sizing:
https://github.com/behdad/harfbuzz/issues/360
This commit is contained in:
Behdad Esfahbod 2017-10-11 11:47:47 +02:00
parent 3f9370d9e5
commit b57f18da70
4 changed files with 57 additions and 1 deletions

View File

@ -246,6 +246,7 @@ hb_font_get_nominal_glyph
hb_font_get_nominal_glyph_func_t
hb_font_get_parent
hb_font_get_ppem
hb_font_get_ptem
hb_font_get_scale
hb_font_get_user_data
hb_font_get_variation_glyph
@ -261,6 +262,7 @@ hb_font_set_funcs
hb_font_set_funcs_data
hb_font_set_parent
hb_font_set_ppem
hb_font_set_ptem
hb_font_set_scale
hb_font_set_user_data
hb_variation_t

View File

@ -108,6 +108,8 @@ struct hb_font_t {
unsigned int x_ppem;
unsigned int y_ppem;
float ptem;
/* Font variation coordinates. */
unsigned int num_coords;
int *coords;
@ -123,7 +125,8 @@ struct hb_font_t {
DIRTY_FUNCS = 0x0004,
DIRTY_SCALE = 0x0008,
DIRTY_PPEM = 0x0010,
DIRTY_VARIATIONS = 0x0020,
DIRTY_PTEM = 0x0020,
DIRTY_VARIATIONS = 0x0040,
} dirty;
struct hb_shaper_data_t shaper_data;

View File

@ -1157,6 +1157,7 @@ hb_font_create_sub_font (hb_font_t *parent)
font->y_scale = parent->y_scale;
font->x_ppem = parent->x_ppem;
font->y_ppem = parent->y_ppem;
font->ptem = parent->ptem;
font->num_coords = parent->num_coords;
if (!font->num_coords)
@ -1199,6 +1200,7 @@ hb_font_get_empty (void)
0, /* x_ppem */
0, /* y_ppem */
-1, /* ptem */
0, /* num_coords */
NULL, /* coords */
@ -1597,6 +1599,45 @@ hb_font_get_ppem (hb_font_t *font,
if (y_ppem) *y_ppem = font->y_ppem;
}
/**
* hb_font_set_ptem:
* @font: a font.
* @ptem:
*
* Sets "point size" of the font.
*
* Since: 1.6.0
**/
void
hb_font_set_ptem (hb_font_t *font, float ptem)
{
if (font->immutable)
return;
if (font->ptem == ptem)
return;
font->dirty |= font->DIRTY_PTEM;
font->ptem = ptem;
}
/**
* hb_font_get_ptem:
* @font: a font.
*
* Gets the "point size" of the font. A value of -1 means unset.
*
* Return value: Point size.
*
* Since: 0.9.2
**/
float
hb_font_get_ptem (hb_font_t *font)
{
return font->ptem;
}
/*
* Variations
*/

View File

@ -607,6 +607,16 @@ hb_font_get_ppem (hb_font_t *font,
unsigned int *x_ppem,
unsigned int *y_ppem);
/*
* Point size per EM. Used for optical-sizing in CoreText.
* A -1 means "not set".
*/
HB_EXTERN void
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_variations (hb_font_t *font,
const hb_variation_t *variations,