[pango/harfbuzz-ng: 3/57] Apply patch from Jonathan Kew



commit 59f8868cf32691cce37060b30c3d16503a003df7
Author: Behdad Esfahbod <behdad behdad org>
Date:   Tue Jul 28 15:43:34 2009 -0400

    Apply patch from Jonathan Kew

 pango/opentype/hb-buffer.c     |   75 +++++++++++++++++++++-------------------
 pango/opentype/hb-buffer.h     |    6 +++-
 pango/opentype/hb-ot-layout.cc |   31 ++++++++++++++++
 pango/opentype/hb-ot-layout.h  |   15 ++++++++
 pango/opentype/hb-private.h    |    2 +-
 5 files changed, 91 insertions(+), 38 deletions(-)
---
diff --git a/pango/opentype/hb-buffer.c b/pango/opentype/hb-buffer.c
index 308fb70..31b6c0f 100644
--- a/pango/opentype/hb-buffer.c
+++ b/pango/opentype/hb-buffer.c
@@ -53,41 +53,6 @@
 /* Internal API */
 
 static void
-hb_buffer_ensure (hb_buffer_t *buffer, unsigned int size)
-{
-  unsigned int new_allocated = buffer->allocated;
-
-  if (size > new_allocated)
-  {
-    while (size > new_allocated)
-      new_allocated += (new_allocated >> 1) + 8;
-
-    if (buffer->positions)
-      buffer->positions = realloc (buffer->positions, new_allocated * sizeof (buffer->positions[0]));
-
-    buffer->in_string = realloc (buffer->in_string, new_allocated * sizeof (buffer->in_string[0]));
-
-    if (buffer->out_string != buffer->in_string)
-    {
-      buffer->alt_string = realloc (buffer->alt_string, new_allocated * sizeof (buffer->alt_string[0]));
-      buffer->out_string = buffer->alt_string;
-    }
-    else
-    {
-      buffer->out_string = buffer->in_string;
-
-      if (buffer->alt_string)
-      {
-	free (buffer->alt_string);
-	buffer->alt_string = NULL;
-      }
-    }
-
-    buffer->allocated = new_allocated;
-  }
-}
-
-static void
 hb_buffer_ensure_separate (hb_buffer_t *buffer, unsigned int size)
 {
   hb_buffer_ensure (buffer, size);
@@ -104,7 +69,7 @@ hb_buffer_ensure_separate (hb_buffer_t *buffer, unsigned int size)
 /* Public API */
 
 hb_buffer_t *
-hb_buffer_new (void)
+hb_buffer_new (unsigned int allocation_size)
 {
   hb_buffer_t *buffer;
 
@@ -119,6 +84,9 @@ hb_buffer_new (void)
 
   hb_buffer_clear (buffer);
 
+  if (allocation_size)
+    hb_buffer_ensure(buffer, allocation_size);
+
   return buffer;
 }
 
@@ -143,6 +111,41 @@ hb_buffer_clear (hb_buffer_t *buffer)
 }
 
 void
+hb_buffer_ensure (hb_buffer_t *buffer, unsigned int size)
+{
+  unsigned int new_allocated = buffer->allocated;
+
+  if (size > new_allocated)
+  {
+    while (size > new_allocated)
+      new_allocated += (new_allocated >> 1) + 8;
+
+    if (buffer->positions)
+      buffer->positions = realloc (buffer->positions, new_allocated * sizeof (buffer->positions[0]));
+
+    if (buffer->out_string != buffer->in_string)
+    {
+      buffer->in_string = realloc (buffer->in_string, new_allocated * sizeof (buffer->in_string[0]));
+      buffer->alt_string = realloc (buffer->alt_string, new_allocated * sizeof (buffer->alt_string[0]));
+      buffer->out_string = buffer->alt_string;
+    }
+    else
+    {
+      buffer->in_string = realloc (buffer->in_string, new_allocated * sizeof (buffer->in_string[0]));
+      buffer->out_string = buffer->in_string;
+
+      if (buffer->alt_string)
+      {
+	free (buffer->alt_string);
+	buffer->alt_string = NULL;
+      }
+    }
+
+    buffer->allocated = new_allocated;
+  }
+}
+
+void
 hb_buffer_add_glyph (hb_buffer_t    *buffer,
 		     hb_codepoint_t  glyph_index,
 		     unsigned int    properties,
diff --git a/pango/opentype/hb-buffer.h b/pango/opentype/hb-buffer.h
index afdf642..197c921 100644
--- a/pango/opentype/hb-buffer.h
+++ b/pango/opentype/hb-buffer.h
@@ -76,7 +76,7 @@ typedef struct _hb_buffer_t {
 } hb_buffer_t;
 
 hb_buffer_t *
-hb_buffer_new (void);
+hb_buffer_new (unsigned int allocation_size);
 
 void
 hb_buffer_free (hb_buffer_t *buffer);
@@ -85,6 +85,10 @@ void
 hb_buffer_clear (hb_buffer_t *buffer);
 
 void
+hb_buffer_ensure (hb_buffer_t  *buffer,
+		  unsigned int  size);
+
+void
 hb_buffer_add_glyph (hb_buffer_t    *buffer,
 		     hb_codepoint_t  glyph_index,
 		     unsigned int    properties,
diff --git a/pango/opentype/hb-ot-layout.cc b/pango/opentype/hb-ot-layout.cc
index 8cff03e..143e1f3 100644
--- a/pango/opentype/hb-ot-layout.cc
+++ b/pango/opentype/hb-ot-layout.cc
@@ -56,6 +56,18 @@ hb_ot_layout_create (void)
   return layout;
 }
 
+hb_bool_t
+hb_ot_layout_has_substitution (hb_ot_layout_t *layout)
+{
+  return layout->gsub != &Null(GSUB);
+}
+
+hb_bool_t
+hb_ot_layout_has_positioning (hb_ot_layout_t *layout)
+{
+  return layout->gpos != &Null(GPOS);
+}
+
 hb_ot_layout_t *
 hb_ot_layout_create_for_data (const char *font_data,
 			      int         face_index)
@@ -77,6 +89,25 @@ hb_ot_layout_create_for_data (const char *font_data,
   return layout;
 }
 
+hb_ot_layout_t *
+hb_ot_layout_create_for_tables (const char *gdef_data,
+				const char *gsub_data,
+				const char *gpos_data)
+{
+  hb_ot_layout_t *layout;
+  
+  if (HB_UNLIKELY (gdef_data == NULL && gsub_data == NULL && gpos_data == NULL))
+    return hb_ot_layout_create ();
+  
+  layout = (hb_ot_layout_t *) calloc (1, sizeof (hb_ot_layout_t));
+  
+  layout->gdef = &GDEF::get_for_data (gdef_data);
+  layout->gsub = &GSUB::get_for_data (gsub_data);
+  layout->gpos = &GPOS::get_for_data (gpos_data);
+  
+  return layout;
+}
+
 void
 hb_ot_layout_destroy (hb_ot_layout_t *layout)
 {
diff --git a/pango/opentype/hb-ot-layout.h b/pango/opentype/hb-ot-layout.h
index 7759532..20bd1e4 100644
--- a/pango/opentype/hb-ot-layout.h
+++ b/pango/opentype/hb-ot-layout.h
@@ -45,6 +45,11 @@ hb_ot_layout_t *
 hb_ot_layout_create_for_data (const char *font_data,
 			      int         face_index);
 
+hb_ot_layout_t *
+hb_ot_layout_create_for_tables (const char *gdef_data,
+				const char *gsub_data,
+				const char *gpos_data);
+
 void
 hb_ot_layout_destroy (hb_ot_layout_t *layout);
 
@@ -232,11 +237,21 @@ hb_ot_layout_feature_get_lookup_index (hb_ot_layout_t            *layout,
  */
 
 hb_bool_t
+hb_ot_layout_has_substitution (hb_ot_layout_t *layout);
+
+hb_bool_t
 hb_ot_layout_substitute_lookup (hb_ot_layout_t              *layout,
 				hb_buffer_t                 *buffer,
 			        unsigned int                 lookup_index,
 				hb_ot_layout_feature_mask_t  mask);
 
+/*
+ * GPOS
+ */
+
+hb_bool_t
+hb_ot_layout_has_positioning (hb_ot_layout_t *layout);
+
 hb_bool_t
 hb_ot_layout_position_lookup   (hb_ot_layout_t              *layout,
 				hb_buffer_t                 *buffer,
diff --git a/pango/opentype/hb-private.h b/pango/opentype/hb-private.h
index 0d1e1a7..6698a7c 100644
--- a/pango/opentype/hb-private.h
+++ b/pango/opentype/hb-private.h
@@ -27,7 +27,7 @@
 #ifndef HB_PRIVATE_H
 #define HB_PRIVATE_H
 
-#include <hb-common.h>
+#include "hb-common.h"
 
 #include <glib.h>
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]