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:
parent
1866e17114
commit
88da7bba9f
|
@ -861,6 +861,8 @@ hb_font_create (hb_face_t *face)
|
||||||
font->face = hb_face_reference (face);
|
font->face = hb_face_reference (face);
|
||||||
font->klass = hb_font_funcs_get_empty ();
|
font->klass = hb_font_funcs_get_empty ();
|
||||||
|
|
||||||
|
font->x_scale = font->y_scale = hb_face_get_upem (face);
|
||||||
|
|
||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,7 @@ _test_font_nil_funcs (hb_font_t *font)
|
||||||
hb_codepoint_t glyph;
|
hb_codepoint_t glyph;
|
||||||
hb_position_t x, y;
|
hb_position_t x, y;
|
||||||
hb_glyph_extents_t extents;
|
hb_glyph_extents_t extents;
|
||||||
|
unsigned int upem = hb_face_get_upem (hb_font_get_face (font));
|
||||||
|
|
||||||
x = y = 13;
|
x = y = 13;
|
||||||
g_assert (!hb_font_get_glyph_contour_point (font, 17, 2, &x, &y));
|
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);
|
g_assert_cmpint (y, ==, 0);
|
||||||
|
|
||||||
x = hb_font_get_glyph_h_advance (font, 17);
|
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.x_bearing = extents.y_bearing = 13;
|
||||||
extents.width = extents.height = 15;
|
extents.width = extents.height = 15;
|
||||||
|
@ -375,6 +376,7 @@ test_font_properties (void)
|
||||||
hb_font_t *subfont;
|
hb_font_t *subfont;
|
||||||
int x_scale, y_scale;
|
int x_scale, y_scale;
|
||||||
unsigned int x_ppem, y_ppem;
|
unsigned int x_ppem, y_ppem;
|
||||||
|
unsigned int upem;
|
||||||
|
|
||||||
blob = hb_blob_create (test_data, sizeof (test_data), HB_MEMORY_MODE_READONLY, NULL, NULL);
|
blob = hb_blob_create (test_data, sizeof (test_data), HB_MEMORY_MODE_READONLY, NULL, NULL);
|
||||||
face = hb_face_create (blob, 0);
|
face = hb_face_create (blob, 0);
|
||||||
|
@ -389,17 +391,18 @@ test_font_properties (void)
|
||||||
|
|
||||||
/* Check scale */
|
/* Check scale */
|
||||||
|
|
||||||
|
upem = hb_face_get_upem (hb_font_get_face (font));
|
||||||
hb_font_get_scale (font, NULL, NULL);
|
hb_font_get_scale (font, NULL, NULL);
|
||||||
x_scale = y_scale = 13;
|
x_scale = y_scale = 13;
|
||||||
hb_font_get_scale (font, &x_scale, NULL);
|
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;
|
x_scale = y_scale = 13;
|
||||||
hb_font_get_scale (font, NULL, &y_scale);
|
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;
|
x_scale = y_scale = 13;
|
||||||
hb_font_get_scale (font, &x_scale, &y_scale);
|
hb_font_get_scale (font, &x_scale, &y_scale);
|
||||||
g_assert_cmpint (x_scale, ==, 0);
|
g_assert_cmpint (x_scale, ==, upem);
|
||||||
g_assert_cmpint (y_scale, ==, 0);
|
g_assert_cmpint (y_scale, ==, upem);
|
||||||
|
|
||||||
hb_font_set_scale (font, 17, 19);
|
hb_font_set_scale (font, 17, 19);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue