[HB] Cleanup buffer

This commit is contained in:
Behdad Esfahbod 2009-05-25 03:39:11 -04:00
parent 347f0b8621
commit 88a5f5a49b
5 changed files with 25 additions and 102 deletions

View File

@ -48,7 +48,7 @@ HB_INTERNAL HB_Error
_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);

View File

@ -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_INTERNAL HB_Error
_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 @@ _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
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 @@ _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
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);

View File

@ -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 @@ struct Sequence
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 @@ struct Ligature
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);

View File

@ -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 \

View File

@ -575,74 +575,3 @@ hb_ot_layout_position_lookup (hb_ot_layout_t *layout,
{
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;
}