From 1866e17114b41d565eb066e7d9393c2ff3e0a12b Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 2 Oct 2015 14:21:29 +0100 Subject: [PATCH] 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. --- src/hb-font.cc | 4 +++- test/api/test-font.c | 21 +++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) 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; -- 2.7.4