Default font scale to face upem

Makes for a better default and avoids nasty inheritance issues.
See mailing list thread "Default hb_font_t scale".
This commit is contained in:
Behdad Esfahbod 2015-10-02 14:38:20 +01:00
parent 1866e17114
commit 88da7bba9f
2 changed files with 10 additions and 5 deletions

View File

@ -861,6 +861,8 @@ hb_font_create (hb_face_t *face)
font->face = hb_face_reference (face);
font->klass = hb_font_funcs_get_empty ();
font->x_scale = font->y_scale = hb_face_get_upem (face);
return font;
}

View File

@ -115,6 +115,7 @@ _test_font_nil_funcs (hb_font_t *font)
hb_codepoint_t glyph;
hb_position_t x, y;
hb_glyph_extents_t extents;
unsigned int upem = hb_face_get_upem (hb_font_get_face (font));
x = y = 13;
g_assert (!hb_font_get_glyph_contour_point (font, 17, 2, &x, &y));
@ -122,7 +123,7 @@ _test_font_nil_funcs (hb_font_t *font)
g_assert_cmpint (y, ==, 0);
x = hb_font_get_glyph_h_advance (font, 17);
g_assert_cmpint (x, ==, 0);
g_assert_cmpint (x, ==, upem);
extents.x_bearing = extents.y_bearing = 13;
extents.width = extents.height = 15;
@ -375,6 +376,7 @@ test_font_properties (void)
hb_font_t *subfont;
int x_scale, y_scale;
unsigned int x_ppem, y_ppem;
unsigned int upem;
blob = hb_blob_create (test_data, sizeof (test_data), HB_MEMORY_MODE_READONLY, NULL, NULL);
face = hb_face_create (blob, 0);
@ -389,17 +391,18 @@ test_font_properties (void)
/* Check scale */
upem = hb_face_get_upem (hb_font_get_face (font));
hb_font_get_scale (font, NULL, NULL);
x_scale = y_scale = 13;
hb_font_get_scale (font, &x_scale, NULL);
g_assert_cmpint (x_scale, ==, 0);
g_assert_cmpint (x_scale, ==, upem);
x_scale = y_scale = 13;
hb_font_get_scale (font, NULL, &y_scale);
g_assert_cmpint (y_scale, ==, 0);
g_assert_cmpint (y_scale, ==, upem);
x_scale = y_scale = 13;
hb_font_get_scale (font, &x_scale, &y_scale);
g_assert_cmpint (x_scale, ==, 0);
g_assert_cmpint (y_scale, ==, 0);
g_assert_cmpint (x_scale, ==, upem);
g_assert_cmpint (y_scale, ==, upem);
hb_font_set_scale (font, 17, 19);