[font] Keep font-space to user-space multiplier

Part of https://github.com/harfbuzz/harfbuzz/issues/1801
This commit is contained in:
Behdad Esfahbod 2019-07-05 13:52:09 -07:00
parent df6edcd44c
commit b847769292
2 changed files with 16 additions and 2 deletions

View File

@ -1300,6 +1300,8 @@ DEFINE_NULL_INSTANCE (hb_font_t) =
1000, /* x_scale */
1000, /* y_scale */
1<<16, /* x_mult */
1<<16, /* y_mult */
0, /* x_ppem */
0, /* y_ppem */
@ -1330,6 +1332,7 @@ _hb_font_create (hb_face_t *face)
font->klass = hb_font_funcs_get_empty ();
font->data.init0 (font);
font->x_scale = font->y_scale = hb_face_get_upem (face);
font->x_mult = font->y_mult = 1 << 16;
return font;
}
@ -1603,6 +1606,7 @@ hb_font_set_face (hb_font_t *font,
hb_face_make_immutable (face);
font->face = hb_face_reference (face);
font->mults_changed ();
hb_face_destroy (old);
}
@ -1712,6 +1716,7 @@ hb_font_set_scale (hb_font_t *font,
font->x_scale = x_scale;
font->y_scale = y_scale;
font->mults_changed ();
}
/**

View File

@ -107,8 +107,10 @@ struct hb_font_t
hb_font_t *parent;
hb_face_t *face;
int x_scale;
int y_scale;
int32_t x_scale;
int32_t y_scale;
int64_t x_mult;
int64_t y_mult;
unsigned int x_ppem;
unsigned int y_ppem;
@ -607,6 +609,13 @@ struct hb_font_t
return false;
}
void mults_changed ()
{
signed upem = face->get_upem ();
x_mult = ((int64_t) x_scale << 16) / upem;
y_mult = ((int64_t) y_scale << 16) / upem;
}
hb_position_t em_scale (int16_t v, int scale)
{
signed upem = face->get_upem ();