From 74f1d896f2479500d65649cf3ec86dd201f0663a Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 10 May 2011 19:39:32 -0400 Subject: [PATCH] Add hb_font_make/is_immutable() --- src/hb-font-private.hh | 2 ++ src/hb-font.cc | 26 +++++++++++++++++++++++--- src/hb-font.h | 6 ++++++ test/test-object.c | 2 +- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/hb-font-private.hh b/src/hb-font-private.hh index 683eab5..cd74e08 100644 --- a/src/hb-font-private.hh +++ b/src/hb-font-private.hh @@ -80,6 +80,8 @@ struct _hb_face_t { struct _hb_font_t { hb_object_header_t header; + hb_bool_t immutable; + hb_face_t *face; unsigned int x_scale; diff --git a/src/hb-font.cc b/src/hb-font.cc index 1e7734b..f04fadb 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -448,6 +448,8 @@ hb_face_get_upem (hb_face_t *face) static hb_font_t _hb_font_nil = { HB_OBJECT_HEADER_STATIC, + TRUE, /* immutable */ + &_hb_face_nil, 0, /* x_scale */ @@ -514,6 +516,21 @@ hb_font_get_user_data (hb_font_t *font, return hb_object_get_user_data (font, key); } +void +hb_font_make_immutable (hb_font_t *font) +{ + if (hb_object_is_inert (font)) + return; + + font->immutable = true; +} + +hb_bool_t +hb_font_is_immutable (hb_font_t *font) +{ + return font->immutable; +} + hb_face_t * hb_font_get_face (hb_font_t *font) @@ -528,7 +545,7 @@ hb_font_set_funcs (hb_font_t *font, void *user_data, hb_destroy_func_t destroy) { - if (hb_object_is_inert (font)) + if (font->immutable) return; if (font->destroy) @@ -550,6 +567,9 @@ hb_font_unset_funcs (hb_font_t *font, void **user_data, hb_destroy_func_t *destroy) { + if (font->immutable) + return; + /* None of the input arguments can be NULL. */ *klass = font->klass; @@ -569,7 +589,7 @@ hb_font_set_scale (hb_font_t *font, int x_scale, int y_scale) { - if (hb_object_is_inert (font)) + if (font->immutable) return; font->x_scale = x_scale; @@ -590,7 +610,7 @@ hb_font_set_ppem (hb_font_t *font, unsigned int x_ppem, unsigned int y_ppem) { - if (hb_object_is_inert (font)) + if (font->immutable) return; font->x_ppem = x_ppem; diff --git a/src/hb-font.h b/src/hb-font.h index e8e344d..fc3518c 100644 --- a/src/hb-font.h +++ b/src/hb-font.h @@ -225,6 +225,12 @@ void * hb_font_get_user_data (hb_font_t *font, hb_user_data_key_t *key); +void +hb_font_make_immutable (hb_font_t *font); + +hb_bool_t +hb_font_is_immutable (hb_font_t *font); + hb_face_t * hb_font_get_face (hb_font_t *font); diff --git a/test/test-object.c b/test/test-object.c index 6937280..1abe65c 100644 --- a/test/test-object.c +++ b/test/test-object.c @@ -161,8 +161,8 @@ static const object_t objects[] = { OBJECT_WITHOUT_IMMUTABILITY (buffer), OBJECT_WITHOUT_IMMUTABILITY (face), - OBJECT_WITHOUT_IMMUTABILITY (font), OBJECT_WITH_IMMUTABILITY (blob), + OBJECT_WITH_IMMUTABILITY (font), OBJECT_WITH_IMMUTABILITY (font_funcs), OBJECT_WITH_IMMUTABILITY (unicode_funcs) }; -- 2.7.4