[HarfBuzz] harfbuzz-ng: Branch 'master'

Behdad Esfahbod behdad at kemper.freedesktop.org
Thu May 20 07:48:27 PDT 2010


 src/hb-font.cc |   35 ++++++++++++-----------------------
 1 file changed, 12 insertions(+), 23 deletions(-)

New commits:
commit 99d9ef785f108df76f80a307eaa2784685ea86ba
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu May 20 15:47:49 2010 +0100

    Write hb_face_create_for_data() in terms of hb_face_create_for_tables()
    
    Fixes lack of head_table initialization in create_for_tables() also.

diff --git a/src/hb-font.cc b/src/hb-font.cc
index c5355f6..7b58330 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -257,6 +257,9 @@ hb_face_create_for_tables (hb_get_table_func_t  get_table,
 
   face->ot_layout = _hb_ot_layout_new (face);
 
+  face->head_blob = Sanitizer<head>::sanitize (hb_face_get_table (face, HB_OT_TAG_head));
+  face->head_table = Sanitizer<head>::lock_instance (face->head_blob);
+
   return face;
 }
 
@@ -266,11 +269,6 @@ typedef struct _hb_face_for_data_closure_t {
   unsigned int  index;
 } hb_face_for_data_closure_t;
 
-static hb_face_for_data_closure_t _hb_face_for_data_closure_nil = {
-  &_hb_blob_nil,
-  0
-};
-
 static hb_face_for_data_closure_t *
 _hb_face_for_data_closure_create (hb_blob_t *blob, unsigned int index)
 {
@@ -278,7 +276,7 @@ _hb_face_for_data_closure_create (hb_blob_t *blob, unsigned int index)
 
   closure = (hb_face_for_data_closure_t *) malloc (sizeof (hb_face_for_data_closure_t));
   if (unlikely (!closure))
-    return &_hb_face_for_data_closure_nil;
+    return NULL;
 
   closure->blob = hb_blob_reference (blob);
   closure->index = index;
@@ -289,10 +287,8 @@ _hb_face_for_data_closure_create (hb_blob_t *blob, unsigned int index)
 static void
 _hb_face_for_data_closure_destroy (hb_face_for_data_closure_t *closure)
 {
-  if (likely (closure != &_hb_face_for_data_closure_nil)) {
-    hb_blob_destroy (closure->blob);
-    free (closure);
-  }
+  hb_blob_destroy (closure->blob);
+  free (closure);
 }
 
 static hb_blob_t *
@@ -316,23 +312,16 @@ hb_face_t *
 hb_face_create_for_data (hb_blob_t    *blob,
 			 unsigned int  index)
 {
-  hb_face_t *face;
-
-  if (!HB_OBJECT_DO_CREATE (hb_face_t, face))
-    return &_hb_face_nil;
-
-  face->get_table = _hb_face_for_data_get_table;
-  face->destroy = (hb_destroy_func_t) _hb_face_for_data_closure_destroy;
   hb_blob_reference (blob);
-  face->user_data = _hb_face_for_data_closure_create (Sanitizer<OpenTypeFontFile>::sanitize (blob), index);
+  hb_face_for_data_closure_t *closure = _hb_face_for_data_closure_create (Sanitizer<OpenTypeFontFile>::sanitize (blob), index);
   hb_blob_destroy (blob);
 
-  face->head_blob = Sanitizer<head>::sanitize (hb_face_get_table (face, HB_OT_TAG_head));
-  face->head_table = Sanitizer<head>::lock_instance (face->head_blob);
-
-  face->ot_layout = _hb_ot_layout_new (face);
+  if (unlikely (!closure))
+    return &_hb_face_nil;
 
-  return face;
+  return hb_face_create_for_tables (_hb_face_for_data_get_table,
+				    (hb_destroy_func_t) _hb_face_for_data_closure_destroy,
+				    closure);
 }
 
 



More information about the HarfBuzz mailing list