src/hb-font.cc | 6 +++++- test/api/test-font.c | 34 +++++++++++++++++++++++----------- 2 files changed, 28 insertions(+), 12 deletions(-)
New commits: commit 88da7bba9fa4665b33f5bfcd45add7443097eaf3 Author: Behdad Esfahbod <beh...@behdad.org> Date: Fri Oct 2 14:38:20 2015 +0100 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". diff --git a/src/hb-font.cc b/src/hb-font.cc index 94dbcdf..058d7ec 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -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; } diff --git a/test/api/test-font.c b/test/api/test-font.c index 6c23062..5afc885 100644 --- a/test/api/test-font.c +++ b/test/api/test-font.c @@ -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); commit 1866e17114b41d565eb066e7d9393c2ff3e0a12b Author: Behdad Esfahbod <beh...@behdad.org> Date: Fri Oct 2 14:21:29 2015 +0100 Make hb_font_create_sub_font() NOT make parent immutable We don't rely on that. However, whenever hb_font_make_immutable() is called, it makes its parenting chain immutable. diff --git a/src/hb-font.cc b/src/hb-font.cc index 94045e3..94dbcdf 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -885,7 +885,6 @@ hb_font_create_sub_font (hb_font_t *parent) if (unlikely (hb_object_is_inert (font))) return font; - hb_font_make_immutable (parent); font->parent = hb_font_reference (parent); font->x_scale = parent->x_scale; @@ -1035,6 +1034,9 @@ hb_font_make_immutable (hb_font_t *font) if (unlikely (hb_object_is_inert (font))) return; + if (font->parent) + hb_font_make_immutable (font->parent); + font->immutable = true; } diff --git a/test/api/test-font.c b/test/api/test-font.c index 2fc0631..6c23062 100644 --- a/test/api/test-font.c +++ b/test/api/test-font.c @@ -290,9 +290,22 @@ test_fontfuncs_subclassing (void) x = hb_font_get_glyph_h_advance (font1, 2); g_assert_cmpint (x, ==, 0); - + /* creating sub-font doesn't make the parent font immutable; + * making a font immutable however makes it's lineage immutable. + */ font2 = hb_font_create_sub_font (font1); + font3 = hb_font_create_sub_font (font2); + g_assert (!hb_font_is_immutable (font1)); + g_assert (!hb_font_is_immutable (font2)); + g_assert (!hb_font_is_immutable (font3)); + hb_font_make_immutable (font3); g_assert (hb_font_is_immutable (font1)); + g_assert (hb_font_is_immutable (font2)); + g_assert (hb_font_is_immutable (font3)); + hb_font_destroy (font2); + hb_font_destroy (font3); + + font2 = hb_font_create_sub_font (font1); hb_font_destroy (font1); /* setup font2 to override some funcs */ @@ -316,12 +329,8 @@ test_fontfuncs_subclassing (void) x = hb_font_get_glyph_h_advance (font2, 2); g_assert_cmpint (x, ==, 0); - - font3 = hb_font_create_sub_font (font2); - g_assert (hb_font_is_immutable (font2)); - hb_font_destroy (font2); - /* setup font3 to override scale */ + font3 = hb_font_create_sub_font (font2); hb_font_set_scale (font3, 20, 30); x = y = 1; _______________________________________________ HarfBuzz mailing list HarfBuzz@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/harfbuzz