[HB] Cleanup buffer
diff --git a/src/hb-buffer-private.h b/src/hb-buffer-private.h
index 6225f70..13bbe12 100644
--- a/src/hb-buffer-private.h
+++ b/src/hb-buffer-private.h
@@ -48,7 +48,7 @@
_hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
unsigned int num_in,
unsigned int num_out,
- unsigned short *glyph_data,
+ const uint16_t *glyph_data_be,
unsigned short component,
unsigned short ligID);
diff --git a/src/hb-buffer.c b/src/hb-buffer.c
index 05d5123..dad2c7d 100644
--- a/src/hb-buffer.c
+++ b/src/hb-buffer.c
@@ -27,6 +27,8 @@
#include "hb-buffer-private.h"
+#include <string.h>
+
/* Here is how the buffer works internally:
*
* There are two string pointers: in_string and out_string. They
@@ -56,7 +58,7 @@
/* Internal API */
-/*static XXX */ void
+static void
hb_buffer_ensure (hb_buffer_t *buffer,
unsigned int size)
{
@@ -243,7 +245,7 @@
_hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
unsigned int num_in,
unsigned int num_out,
- unsigned short *glyph_data,
+ const uint16_t *glyph_data_be,
unsigned short component,
unsigned short ligID)
{
@@ -252,27 +254,28 @@
unsigned int properties;
unsigned int cluster;
- hb_buffer_ensure (buffer, buffer->out_pos + num_out);
+ hb_buffer_ensure( buffer, buffer->out_pos + num_out );
+ /* XXX */
- if (!buffer->separate_out)
+ if ( !buffer->separate_out )
{
- error = hb_buffer_duplicate_out_buffer (buffer);
- if (error)
+ error = hb_buffer_duplicate_out_buffer( buffer );
+ if ( error )
return error;
}
properties = buffer->in_string[buffer->in_pos].properties;
cluster = buffer->in_string[buffer->in_pos].cluster;
- if (component == 0xFFFF)
+ if ( component == 0xFFFF )
component = buffer->in_string[buffer->in_pos].component;
- if (ligID == 0xFFFF)
+ if ( ligID == 0xFFFF )
ligID = buffer->in_string[buffer->in_pos].ligID;
- for (i = 0; i < num_out; i++)
+ for ( i = 0; i < num_out; i++ )
{
HB_GlyphItem item = &buffer->out_string[buffer->out_pos + i];
- item->gindex = glyph_data[i];
+ item->gindex = hb_be_uint16_t (glyph_data_be[i]);
item->properties = properties;
item->cluster = cluster;
item->component = component;
@@ -288,13 +291,14 @@
return HB_Err_Ok;
}
+
HB_INTERNAL HB_Error
_hb_buffer_add_output_glyph (hb_buffer_t *buffer,
hb_codepoint_t glyph_index,
unsigned short component,
unsigned short ligID)
{
- unsigned short glyph_data = glyph_index;
+ uint16_t glyph_data = hb_be_uint16_t (glyph_index);
return _hb_buffer_add_output_glyphs (buffer, 1, 1,
&glyph_data, component, ligID);
diff --git a/src/hb-ot-layout-gsub-private.h b/src/hb-ot-layout-gsub-private.h
index c025ac5..6a2d433 100644
--- a/src/hb-ot-layout-gsub-private.h
+++ b/src/hb-ot-layout-gsub-private.h
@@ -29,16 +29,6 @@
#include "hb-ot-layout-gsubgpos-private.h"
-/* XXX */
-#include "hb-buffer-private.h"
-HB_INTERNAL HB_Error
-_hb_buffer_add_output_glyph_ids (hb_buffer_t *buffer,
- unsigned int num_in,
- unsigned int num_out,
- const GlyphID *glyph_data,
- unsigned short component,
- unsigned short ligID);
-
struct SingleSubstFormat1
{
@@ -146,9 +136,9 @@
if (HB_UNLIKELY (!substitute.len))
return false;
- _hb_buffer_add_output_glyph_ids (buffer, 1,
- substitute.len, substitute.array,
- 0xFFFF, 0xFFFF);
+ _hb_buffer_add_output_glyphs (buffer, 1,
+ substitute.len, (const uint16_t *) substitute.array,
+ 0xFFFF, 0xFFFF);
if ( _hb_ot_layout_has_new_glyph_classes (layout) )
{
@@ -336,11 +326,11 @@
if (j == buffer->in_pos + i) /* No input glyphs skipped */
/* We don't use a new ligature ID if there are no skipped
glyphs and the ligature already has an ID. */
- _hb_buffer_add_output_glyph_ids (buffer, i,
- 1, &ligGlyph,
- 0xFFFF,
- IN_LIGID (buffer->in_pos) ?
- 0xFFFF : _hb_buffer_allocate_ligid (buffer));
+ _hb_buffer_add_output_glyphs (buffer, i,
+ 1, (const uint16_t *) &ligGlyph,
+ 0xFFFF,
+ IN_LIGID (buffer->in_pos) ?
+ 0xFFFF : _hb_buffer_allocate_ligid (buffer));
else
{
unsigned int lig_id = _hb_buffer_allocate_ligid (buffer);
diff --git a/src/hb-ot-layout-gsubgpos-private.h b/src/hb-ot-layout-gsubgpos-private.h
index 2445f05..f1c16e7 100644
--- a/src/hb-ot-layout-gsubgpos-private.h
+++ b/src/hb-ot-layout-gsubgpos-private.h
@@ -27,8 +27,8 @@
#ifndef HB_OT_LAYOUT_GSUBGPOS_PRIVATE_H
#define HB_OT_LAYOUT_GSUBGPOS_PRIVATE_H
+#include "hb-buffer-private.h"
#include "hb-ot-layout-gdef-private.h"
-#include "hb-buffer-private.h" /* XXX */
#define APPLY_ARG_DEF \
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 20fc0a1..fbb9eba 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -575,74 +575,3 @@
{
return layout->gpos->position_lookup (layout, buffer, lookup_index, mask);
}
-
-
-
-/* TODO dupped, until he old code can be removed */
-
-static HB_Error
-hb_buffer_duplicate_out_buffer( HB_Buffer buffer )
-{
- if (!buffer->alt_string)
- buffer->alt_string = (HB_GlyphItemRec_ *) malloc (buffer->allocated * sizeof (buffer->out_string[0]));
-
- buffer->out_string = buffer->alt_string;
- memcpy (buffer->out_string, buffer->in_string, buffer->out_length * sizeof (buffer->out_string[0]));
- buffer->separate_out = TRUE;
-
- return HB_Err_Ok;
-}
-
-
-
-/* XXX */
-HB_INTERNAL HB_Error
-_hb_buffer_add_output_glyph_ids (hb_buffer_t *buffer,
- unsigned int num_in,
- unsigned int num_out,
- const GlyphID *glyph_data,
- unsigned short component,
- unsigned short ligID)
-{
- HB_Error error;
- unsigned int i;
- unsigned int properties;
- unsigned int cluster;
-
- hb_buffer_ensure( buffer, buffer->out_pos + num_out );
- /* XXX */
-
- if ( !buffer->separate_out )
- {
- error = hb_buffer_duplicate_out_buffer( buffer );
- if ( error )
- return error;
- }
-
- properties = buffer->in_string[buffer->in_pos].properties;
- cluster = buffer->in_string[buffer->in_pos].cluster;
- if ( component == 0xFFFF )
- component = buffer->in_string[buffer->in_pos].component;
- if ( ligID == 0xFFFF )
- ligID = buffer->in_string[buffer->in_pos].ligID;
-
- for ( i = 0; i < num_out; i++ )
- {
- HB_GlyphItem item = &buffer->out_string[buffer->out_pos + i];
-
- item->gindex = glyph_data[i];
- item->properties = properties;
- item->cluster = cluster;
- item->component = component;
- item->ligID = ligID;
- item->gproperty = HB_GLYPH_PROPERTY_UNKNOWN;
- }
-
- buffer->in_pos += num_in;
- buffer->out_pos += num_out;
-
- buffer->out_length = buffer->out_pos;
-
- return HB_Err_Ok;
-}
-