Move unicode_funcs to buffer
authorBehdad Esfahbod <behdad@behdad.org>
Tue, 3 Nov 2009 20:15:07 +0000 (15:15 -0500)
committerBehdad Esfahbod <behdad@behdad.org>
Tue, 3 Nov 2009 20:15:07 +0000 (15:15 -0500)
TODO
src/hb-buffer-private.h
src/hb-buffer.c
src/hb-buffer.h
src/hb-font-private.h
src/hb-font.cc
src/hb-font.h

diff --git a/TODO b/TODO
index eae8951..f11dbeb 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,6 +1,5 @@
 - cmap14 support in get_glyph callback
 - Use size_t in sanitize?
-- Move unicode_funcs to buffer
 - Buffer error handling?
 
 hb-ot:
index 45cdc4d..8bd93e0 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "hb-private.h"
 #include "hb-buffer.h"
+#include "hb-unicode-private.h"
 
 HB_BEGIN_DECLS
 
@@ -69,6 +70,14 @@ ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t));
 struct _hb_buffer_t {
   hb_reference_count_t ref_count;
 
+  /* Information about how the text in the buffer should be treated */
+
+  hb_unicode_funcs_t *unicode;
+  hb_direction_t       direction;
+
+
+  /* Buffer contents */
+
   unsigned int allocated;
 
   hb_bool_t    have_output; /* weather we have an output buffer going on */
@@ -81,7 +90,8 @@ struct _hb_buffer_t {
   hb_internal_glyph_info_t     *out_string;
   hb_internal_glyph_position_t *positions;
 
-  hb_direction_t       direction;
+  /* Other stuff */
+
   unsigned int         max_lig_id;
 };
 
index 93b51e5..1b5f2fb 100644 (file)
@@ -31,7 +31,9 @@
 
 
 static hb_buffer_t _hb_buffer_nil = {
-  HB_REFERENCE_COUNT_INVALID /* ref_count */
+  HB_REFERENCE_COUNT_INVALID, /* ref_count */
+
+  &_hb_unicode_funcs_nil  /* unicode */
 };
 
 /* Here is how the buffer works internally:
@@ -84,6 +86,8 @@ hb_buffer_create (unsigned int pre_alloc_size)
   if (pre_alloc_size)
     hb_buffer_ensure(buffer, pre_alloc_size);
 
+  buffer->unicode = &_hb_unicode_funcs_nil;
+
   return buffer;
 }
 
@@ -104,12 +108,45 @@ hb_buffer_destroy (hb_buffer_t *buffer)
 {
   HB_OBJECT_DO_DESTROY (buffer);
 
+  hb_unicode_funcs_destroy (buffer->unicode);
+
   free (buffer->in_string);
   free (buffer->positions);
 
   free (buffer);
 }
 
+
+void
+hb_buffer_set_unicode_funcs (hb_buffer_t        *buffer,
+                            hb_unicode_funcs_t *unicode)
+{
+  hb_unicode_funcs_reference (unicode);
+  hb_unicode_funcs_destroy (buffer->unicode);
+  buffer->unicode = unicode;
+}
+
+hb_unicode_funcs_t *
+hb_buffer_get_unicode_funcs (hb_buffer_t        *buffer)
+{
+  return buffer->unicode;
+}
+
+void
+hb_buffer_set_direction (hb_buffer_t    *buffer,
+                        hb_direction_t  direction)
+
+{
+  buffer->direction = direction;
+}
+
+hb_direction_t
+hb_buffer_get_direction (hb_buffer_t    *buffer)
+{
+  return buffer->direction;
+}
+
+
 void
 hb_buffer_clear (hb_buffer_t *buffer)
 {
@@ -171,14 +208,6 @@ hb_buffer_add_glyph (hb_buffer_t    *buffer,
   buffer->in_length++;
 }
 
-void
-hb_buffer_set_direction (hb_buffer_t    *buffer,
-                        hb_direction_t  direction)
-
-{
-  buffer->direction = direction;
-}
-
 
 /* HarfBuzz-Internal API */
 
index b030ba9..70c87c6 100644 (file)
@@ -29,6 +29,7 @@
 #define HB_BUFFER_H
 
 #include "hb-common.h"
+#include "hb-unicode.h"
 
 HB_BEGIN_DECLS
 
@@ -81,6 +82,14 @@ hb_buffer_destroy (hb_buffer_t *buffer);
 
 
 void
+hb_buffer_set_unicode_funcs (hb_buffer_t        *buffer,
+                            hb_unicode_funcs_t *unicode_funcs);
+
+hb_unicode_funcs_t *
+hb_buffer_get_unicode_funcs (hb_buffer_t        *buffer);
+
+
+void
 hb_buffer_set_direction (hb_buffer_t    *buffer,
                         hb_direction_t  direction);
 
@@ -88,6 +97,7 @@ hb_direction_t
 hb_buffer_get_direction (hb_buffer_t *buffer);
 
 
+
 void
 hb_buffer_clear (hb_buffer_t *buffer);
 
index 8d921c7..79de5e4 100644 (file)
@@ -31,7 +31,6 @@
 
 #include "hb-font.h"
 
-#include "hb-unicode-private.h"
 #include "hb-ot-layout-private.h"
 
 HB_BEGIN_DECLS
@@ -68,8 +67,6 @@ struct _hb_face_t {
   hb_destroy_func_t    destroy;
   void                *user_data;
 
-  hb_unicode_funcs_t *unicode;
-
   hb_ot_layout_t ot_layout;
 };
 
index df3d80b..4865baa 100644 (file)
@@ -27,7 +27,6 @@
 #include "hb-private.h"
 
 #include "hb-font-private.h"
-#include "hb-unicode-private.h"
 #include "hb-open-file-private.hh"
 #include "hb-blob.h"
 
@@ -138,8 +137,6 @@ static hb_face_t _hb_face_nil = {
   NULL, /* destroy */
   NULL, /* user_data */
 
-  &_hb_unicode_funcs_nil,  /* unicode */
-
   {} /* ot_layout */
 };
 
@@ -208,23 +205,9 @@ hb_face_destroy (hb_face_t *face)
   if (face->destroy)
     face->destroy (face->user_data);
 
-  hb_unicode_funcs_destroy (face->unicode);
-
   free (face);
 }
 
-void
-hb_face_set_unicode_funcs (hb_face_t *face,
-                              hb_unicode_funcs_t *unicode)
-{
-  if (HB_OBJECT_IS_INERT (face))
-    return;
-
-  hb_unicode_funcs_reference (unicode);
-  hb_unicode_funcs_destroy (face->unicode);
-  face->unicode = unicode;
-}
-
 hb_blob_t *
 hb_face_get_table (hb_face_t *face,
                   hb_tag_t   tag)
index e020bd8..5bce0d4 100644 (file)
@@ -29,7 +29,6 @@
 
 #include "hb-common.h"
 #include "hb-blob.h"
-#include "hb-unicode.h"
 
 HB_BEGIN_DECLS
 
@@ -61,10 +60,6 @@ hb_face_get_reference_count (hb_face_t *face);
 void
 hb_face_destroy (hb_face_t *face);
 
-void
-hb_face_set_unicode_funcs (hb_face_t *face,
-                          hb_unicode_funcs_t *unicode_funcs);
-
 hb_blob_t *
 hb_face_get_table (hb_face_t *face,
                   hb_tag_t   tag);
@@ -158,6 +153,10 @@ void
 hb_font_set_funcs (hb_font_t       *font,
                   hb_font_funcs_t *klass);
 
+hb_font_funcs_t *
+hb_font_get_funcs (hb_font_t       *font);
+
+
 /*
  * XXX
  * should we decompose this to units_per_EM and font-size?