/* Internal API */
-/*static XXX */ HB_Error
-hb_buffer_ensure( HB_Buffer buffer,
- HB_UInt size )
+/*static XXX */ void
+hb_buffer_ensure (hb_buffer_t *buffer,
+ unsigned int size)
{
HB_UInt new_allocated = buffer->allocated;
+ /* XXX err handling */
if (size > new_allocated)
{
while (size > new_allocated)
new_allocated += (new_allocated >> 1) + 8;
- if ( buffer->positions )
- {
- if ( REALLOC_ARRAY( buffer->positions, new_allocated, HB_PositionRec ) )
- return error;
- }
+ if (buffer->positions)
+ buffer->positions = realloc (buffer->positions, new_allocated * sizeof (buffer->positions[0]));
- if ( REALLOC_ARRAY( buffer->in_string, new_allocated, HB_GlyphItemRec ) )
- return error;
+ buffer->in_string = realloc (buffer->in_string, new_allocated * sizeof (buffer->in_string[0]));
- if ( buffer->separate_out )
+ if (buffer->separate_out)
{
- if ( REALLOC_ARRAY( buffer->alt_string, new_allocated, HB_GlyphItemRec ) )
- return error;
-
+ 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 )
+ if (buffer->alt_string)
{
- if ( REALLOC_ARRAY( buffer->alt_string, new_allocated, HB_GlyphItemRec ) )
- return error;
+ free (buffer->alt_string);
+ buffer->alt_string = NULL;
}
}
buffer->allocated = new_allocated;
}
-
- return HB_Err_Ok;
}
static HB_Error
-hb_buffer_duplicate_out_buffer( HB_Buffer buffer )
+hb_buffer_duplicate_out_buffer (HB_Buffer buffer)
{
- if ( !buffer->alt_string )
- {
- HB_Error error;
-
- if ( ALLOC_ARRAY( buffer->alt_string, buffer->allocated, HB_GlyphItemRec ) )
- return error;
- }
+ if (!buffer->alt_string)
+ buffer->alt_string = malloc (buffer->allocated * sizeof (buffer->alt_string[0]));
buffer->out_string = buffer->alt_string;
- memcpy( buffer->out_string, buffer->in_string, buffer->out_length * sizeof (buffer->out_string[0]) );
+ memcpy (buffer->out_string, buffer->in_string, buffer->out_length * sizeof (buffer->out_string[0]));
buffer->separate_out = TRUE;
return HB_Err_Ok;
/* Public API */
-HB_Error
-hb_buffer_new( HB_Buffer *pbuffer )
+hb_buffer_t *
+hb_buffer_new (void)
{
- HB_Buffer buffer;
- HB_Error error;
-
- if ( ALLOC( buffer, sizeof( HB_BufferRec ) ) )
- return error;
+ hb_buffer_t *buffer;
+
+ buffer = malloc (sizeof (hb_buffer_t));
+ if (HB_UNLIKELY (!buffer))
+ return NULL;
buffer->allocated = 0;
buffer->in_string = NULL;
buffer->alt_string = NULL;
buffer->positions = NULL;
- hb_buffer_clear( buffer );
+ hb_buffer_clear (buffer);
- *pbuffer = buffer;
-
- return HB_Err_Ok;
+ return buffer;
}
void
-hb_buffer_free( HB_Buffer buffer )
+hb_buffer_free (HB_Buffer buffer)
{
- FREE( buffer->in_string );
- FREE( buffer->alt_string );
- buffer->out_string = NULL;
- FREE( buffer->positions );
- FREE( buffer );
+ free (buffer->in_string);
+ free (buffer->alt_string);
+ free (buffer->positions);
+ free (buffer);
}
void
-hb_buffer_clear( HB_Buffer buffer )
+hb_buffer_clear (HB_Buffer buffer)
{
buffer->in_length = 0;
buffer->out_length = 0;
buffer->max_ligID = 0;
}
-HB_Error
-hb_buffer_add_glyph( HB_Buffer buffer,
+void
+hb_buffer_add_glyph (HB_Buffer buffer,
HB_UInt glyph_index,
HB_UInt properties,
- HB_UInt cluster )
+ HB_UInt cluster)
{
HB_Error error;
HB_GlyphItem glyph;
- error = hb_buffer_ensure( buffer, buffer->in_length + 1 );
- if ( error )
- return error;
+ hb_buffer_ensure (buffer, buffer->in_length + 1);
glyph = &buffer->in_string[buffer->in_length];
glyph->gindex = glyph_index;
glyph->component = 0;
glyph->ligID = 0;
glyph->gproperty = HB_GLYPH_PROPERTY_UNKNOWN;
-
- buffer->in_length++;
- return HB_Err_Ok;
+ buffer->in_length++;
}
/* HarfBuzz-Internal API */
HB_INTERNAL void
-_hb_buffer_clear_output( HB_Buffer buffer )
+_hb_buffer_clear_output (HB_Buffer buffer)
{
buffer->out_length = 0;
buffer->out_pos = 0;
}
HB_INTERNAL HB_Error
-_hb_buffer_clear_positions( HB_Buffer buffer )
+_hb_buffer_clear_positions (HB_Buffer buffer)
{
_hb_buffer_clear_output (buffer);
- if ( !buffer->positions )
- {
- HB_Error error;
-
- if ( ALLOC_ARRAY( buffer->positions, buffer->allocated, HB_PositionRec ) )
- return error;
- }
+ if (!buffer->positions)
+ buffer->positions = malloc (buffer->allocated * sizeof (buffer->positions[0]));
memset (buffer->positions, 0, sizeof (buffer->positions[0]) * buffer->in_length);
}
HB_INTERNAL void
-_hb_buffer_swap( HB_Buffer buffer )
+_hb_buffer_swap (HB_Buffer buffer)
{
HB_GlyphItem tmp_string;
int tmp_length;
int tmp_pos;
- if ( buffer->separate_out )
+ if (buffer->separate_out)
{
tmp_string = buffer->in_string;
buffer->in_string = buffer->out_string;
The cluster value for the glyph at position buffer->in_pos is used
for all replacement glyphs */
HB_INTERNAL HB_Error
-_hb_buffer_add_output_glyphs( HB_Buffer buffer,
+_hb_buffer_add_output_glyphs (HB_Buffer buffer,
HB_UShort num_in,
HB_UShort num_out,
HB_UShort *glyph_data,
HB_UShort component,
- HB_UShort ligID )
+ HB_UShort ligID)
{
HB_Error error;
HB_UShort i;
HB_UInt properties;
HB_UInt cluster;
- error = hb_buffer_ensure( buffer, buffer->out_pos + num_out );
- if ( error )
- return error;
+ hb_buffer_ensure (buffer, buffer->out_pos + num_out);
- 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];
}
HB_INTERNAL HB_Error
-_hb_buffer_add_output_glyph( HB_Buffer buffer,
+_hb_buffer_add_output_glyph (HB_Buffer buffer,
HB_UInt glyph_index,
HB_UShort component,
- HB_UShort ligID )
+ HB_UShort ligID)
{
HB_UShort glyph_data = glyph_index;
- return _hb_buffer_add_output_glyphs ( buffer, 1, 1,
- &glyph_data, component, ligID );
+ return _hb_buffer_add_output_glyphs (buffer, 1, 1,
+ &glyph_data, component, ligID);
}
HB_INTERNAL HB_Error
-_hb_buffer_next_glyph ( HB_Buffer buffer )
+_hb_buffer_next_glyph (HB_Buffer buffer)
{
HB_Error error;
- if ( buffer->separate_out )
+ if (buffer->separate_out)
{
- error = hb_buffer_ensure( buffer, buffer->out_pos + 1 );
- if ( error )
- return error;
+ hb_buffer_ensure (buffer, buffer->out_pos + 1);
buffer->out_string[buffer->out_pos] = buffer->in_string[buffer->in_pos];
}
}
HB_INTERNAL HB_Error
-_hb_buffer_replace_glyph( HB_Buffer buffer,
- HB_UInt glyph_index )
+_hb_buffer_replace_glyph (HB_Buffer buffer,
+ HB_UInt glyph_index)
{
- if ( !buffer->separate_out )
+ if (!buffer->separate_out)
{
buffer->out_string[buffer->out_pos].gindex = glyph_index;
}
else
{
- return _hb_buffer_add_output_glyph( buffer, glyph_index, 0xFFFF, 0xFFFF );
+ return _hb_buffer_add_output_glyph (buffer, glyph_index, 0xFFFF, 0xFFFF);
}
return HB_Err_Ok;
}
HB_INTERNAL HB_UShort
-_hb_buffer_allocate_ligid( HB_Buffer buffer )
+_hb_buffer_allocate_ligid (HB_Buffer buffer)
{
return ++buffer->max_ligID;
}
#ifndef HARFBUZZ_BUFFER_H
#define HARFBUZZ_BUFFER_H
-#include "harfbuzz-global.h"
+#include "hb-common.h"
-HB_BEGIN_HEADER
+HB_BEGIN_DECLS();
typedef struct HB_GlyphItemRec_ {
- HB_UInt gindex;
- HB_UInt properties;
- HB_UInt cluster;
- HB_UShort component;
- HB_UShort ligID;
- HB_UShort gproperty;
+ hb_codepoint_t gindex;
+ unsigned int properties;
+ unsigned int cluster;
+ unsigned short component;
+ unsigned short ligID;
+ unsigned short gproperty;
} HB_GlyphItemRec, *HB_GlyphItem;
typedef struct HB_PositionRec_ {
- HB_Fixed x_pos;
- HB_Fixed y_pos;
- HB_Fixed x_advance;
- HB_Fixed y_advance;
- HB_UShort back; /* number of glyphs to go back
- for drawing current glyph */
- HB_Bool new_advance; /* if set, the advance width values are
- absolute, i.e., they won't be
- added to the original glyph's value
- but rather replace them. */
- HB_Short cursive_chain; /* character to which this connects,
- may be positive or negative; used
- only internally */
+ hb_position_t x_pos;
+ hb_position_t y_pos;
+ hb_position_t x_advance;
+ hb_position_t y_advance;
+ unsigned short back; /* number of glyphs to go back
+ for drawing current glyph */
+ hb_bool_t new_advance; /* if set, the advance width values are
+ absolute, i.e., they won't be
+ added to the original glyph's value
+ but rather replace them. */
+ short cursive_chain; /* character to which this connects,
+ may be positive or negative; used
+ only internally */
} HB_PositionRec, *HB_Position;
-typedef struct HB_BufferRec_{
- HB_UInt allocated;
+typedef struct _hb_buffer_t {
+ unsigned int allocated;
- HB_UInt in_length;
- HB_UInt out_length;
- HB_UInt in_pos;
- HB_UInt out_pos;
+ unsigned int in_length;
+ unsigned int out_length;
+ unsigned int in_pos;
+ unsigned int out_pos;
- HB_Bool separate_out;
+ hb_bool_t separate_out;
HB_GlyphItem in_string;
HB_GlyphItem out_string;
HB_GlyphItem alt_string;
HB_Position positions;
- HB_UShort max_ligID;
-} HB_BufferRec, *HB_Buffer;
+ unsigned int max_ligID;
+} HB_BufferRec, *HB_Buffer, hb_buffer_t;
-HB_Error
-hb_buffer_new( HB_Buffer *buffer );
+hb_buffer_t *
+hb_buffer_new (void);
void
-hb_buffer_free( HB_Buffer buffer );
+hb_buffer_free (hb_buffer_t *buffer);
void
-hb_buffer_clear( HB_Buffer buffer );
+hb_buffer_clear (hb_buffer_t *buffer);
-HB_Error
-hb_buffer_add_glyph( HB_Buffer buffer,
- HB_UInt glyph_index,
- HB_UInt properties,
- HB_UInt cluster );
+void
+hb_buffer_add_glyph (hb_buffer_t *buffer,
+ hb_codepoint_t glyph_index,
+ unsigned int properties,
+ unsigned int cluster);
-HB_END_HEADER
+HB_END_DECLS();
#endif /* HARFBUZZ_BUFFER_H */