[HB] More buffer cleanup
This commit is contained in:
parent
88a5f5a49b
commit
c968fc2dc8
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
HB_BEGIN_DECLS
|
HB_BEGIN_DECLS
|
||||||
|
|
||||||
#define HB_GLYPH_PROPERTY_UNKNOWN 0xFFFF
|
#define HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN 0xFFFF
|
||||||
|
|
||||||
HB_INTERNAL void
|
HB_INTERNAL void
|
||||||
_hb_buffer_swap (hb_buffer_t *buffer);
|
_hb_buffer_swap (hb_buffer_t *buffer);
|
||||||
|
@ -41,10 +41,10 @@ _hb_buffer_swap (hb_buffer_t *buffer);
|
||||||
HB_INTERNAL void
|
HB_INTERNAL void
|
||||||
_hb_buffer_clear_output (hb_buffer_t *buffer);
|
_hb_buffer_clear_output (hb_buffer_t *buffer);
|
||||||
|
|
||||||
HB_INTERNAL HB_Error
|
HB_INTERNAL void
|
||||||
_hb_buffer_clear_positions (hb_buffer_t *buffer);
|
_hb_buffer_clear_positions (hb_buffer_t *buffer);
|
||||||
|
|
||||||
HB_INTERNAL HB_Error
|
HB_INTERNAL void
|
||||||
_hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
|
_hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
|
||||||
unsigned int num_in,
|
unsigned int num_in,
|
||||||
unsigned int num_out,
|
unsigned int num_out,
|
||||||
|
@ -52,54 +52,35 @@ _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
|
||||||
unsigned short component,
|
unsigned short component,
|
||||||
unsigned short ligID);
|
unsigned short ligID);
|
||||||
|
|
||||||
HB_INTERNAL HB_Error
|
HB_INTERNAL void
|
||||||
_hb_buffer_add_output_glyph (hb_buffer_t *buffer,
|
_hb_buffer_add_output_glyph (hb_buffer_t *buffer,
|
||||||
hb_codepoint_t glyph_index,
|
hb_codepoint_t glyph_index,
|
||||||
unsigned short component,
|
unsigned short component,
|
||||||
unsigned short ligID);
|
unsigned short ligID);
|
||||||
|
|
||||||
HB_INTERNAL HB_Error
|
HB_INTERNAL void
|
||||||
_hb_buffer_next_glyph (hb_buffer_t *buffer);
|
_hb_buffer_next_glyph (hb_buffer_t *buffer);
|
||||||
|
|
||||||
HB_INTERNAL HB_Error
|
HB_INTERNAL void
|
||||||
_hb_buffer_replace_glyph (hb_buffer_t *buffer,
|
_hb_buffer_replace_glyph (hb_buffer_t *buffer,
|
||||||
hb_codepoint_t glyph_index);
|
hb_codepoint_t glyph_index);
|
||||||
|
|
||||||
HB_INTERNAL unsigned short
|
HB_INTERNAL unsigned short
|
||||||
_hb_buffer_allocate_ligid (hb_buffer_t *buffer);
|
_hb_buffer_allocate_lig_id (hb_buffer_t *buffer);
|
||||||
|
|
||||||
|
|
||||||
/* convenience macros */
|
/* convenience macros */
|
||||||
|
|
||||||
#define IN_GLYPH(pos) (buffer->in_string[(pos)].gindex)
|
#define IN_GLYPH(pos) (buffer->in_string[(pos)].gindex)
|
||||||
#define IN_ITEM(pos) (&buffer->in_string[(pos)])
|
#define IN_INFO(pos) (&buffer->in_string[(pos)])
|
||||||
#define IN_CURGLYPH() (buffer->in_string[buffer->in_pos].gindex)
|
#define IN_CURGLYPH() (buffer->in_string[buffer->in_pos].gindex)
|
||||||
#define IN_CURITEM() (&buffer->in_string[buffer->in_pos])
|
#define IN_CURINFO() (&buffer->in_string[buffer->in_pos])
|
||||||
#define IN_PROPERTIES(pos) (buffer->in_string[(pos)].properties)
|
#define IN_PROPERTIES(pos) (buffer->in_string[(pos)].properties)
|
||||||
#define IN_LIGID(pos) (buffer->in_string[(pos)].ligID)
|
#define IN_LIGID(pos) (buffer->in_string[(pos)].ligID)
|
||||||
#define IN_COMPONENT(pos) (buffer->in_string[(pos)].component)
|
#define IN_COMPONENT(pos) (buffer->in_string[(pos)].component)
|
||||||
#define POSITION(pos) (&buffer->positions[(pos)])
|
#define POSITION(pos) (&buffer->positions[(pos)])
|
||||||
#define CURPOSITION() (&buffer->positions[buffer->in_pos])
|
#define CURPOSITION() (&buffer->positions[buffer->in_pos])
|
||||||
#define OUT_GLYPH(pos) (buffer->out_string[(pos)].gindex)
|
#define OUT_GLYPH(pos) (buffer->out_string[(pos)].gindex)
|
||||||
#define OUT_ITEM(pos) (&buffer->out_string[(pos)])
|
#define OUT_INFO(pos) (&buffer->out_string[(pos)])
|
||||||
|
|
||||||
#define CHECK_Property (layout, index, flags, properties) \
|
|
||||||
({unsigned int _p; error = _hb_ot_layout_check_glyph_property((layout), (index), (flags), (&_p)) \
|
|
||||||
? HB_Err_Ok : HB_Err_Not_Covered, *(properties) = _p; error;})
|
|
||||||
|
|
||||||
#define ADD_String (buffer, num_in, num_out, glyph_data, component, ligID) \
|
|
||||||
((error = _hb_buffer_add_output_glyphs ((buffer), \
|
|
||||||
(num_in), (num_out), \
|
|
||||||
(glyph_data), (component), (ligID) \
|
|
||||||
)) != HB_Err_Ok)
|
|
||||||
#define ADD_Glyph (buffer, glyph_index, component, ligID) \
|
|
||||||
((error = _hb_buffer_add_output_glyph ((buffer), \
|
|
||||||
(glyph_index), (component), (ligID) \
|
|
||||||
)) != HB_Err_Ok)
|
|
||||||
#define REPLACE_Glyph (buffer, glyph_index) \
|
|
||||||
((error = _hb_buffer_replace_glyph ((buffer), (glyph_index))) != HB_Err_Ok)
|
|
||||||
#define COPY_Glyph (buffer) \
|
|
||||||
((error = _hb_buffer_next_glyph (buffer)) != HB_Err_Ok)
|
|
||||||
|
|
||||||
HB_END_DECLS
|
HB_END_DECLS
|
||||||
|
|
||||||
|
|
134
src/hb-buffer.c
134
src/hb-buffer.c
|
@ -56,19 +56,17 @@
|
||||||
* to in_string (FALSE) or alt_string (TRUE).
|
* to in_string (FALSE) or alt_string (TRUE).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* XXX err handling */
|
||||||
|
|
||||||
/* Internal API */
|
/* Internal API */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
hb_buffer_ensure (hb_buffer_t *buffer,
|
hb_buffer_ensure (hb_buffer_t *buffer, unsigned int size)
|
||||||
unsigned int size)
|
|
||||||
{
|
{
|
||||||
unsigned int new_allocated = buffer->allocated;
|
unsigned int new_allocated = buffer->allocated;
|
||||||
/* XXX err handling */
|
|
||||||
|
|
||||||
if (size > new_allocated)
|
if (size > new_allocated)
|
||||||
{
|
{
|
||||||
HB_Error error;
|
|
||||||
|
|
||||||
while (size > new_allocated)
|
while (size > new_allocated)
|
||||||
new_allocated += (new_allocated >> 1) + 8;
|
new_allocated += (new_allocated >> 1) + 8;
|
||||||
|
|
||||||
|
@ -97,8 +95,8 @@ hb_buffer_ensure (hb_buffer_t *buffer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static HB_Error
|
static void
|
||||||
hb_buffer_duplicate_out_buffer (HB_Buffer buffer)
|
hb_buffer_duplicate_out_buffer (hb_buffer_t *buffer)
|
||||||
{
|
{
|
||||||
if (!buffer->alt_string)
|
if (!buffer->alt_string)
|
||||||
buffer->alt_string = malloc (buffer->allocated * sizeof (buffer->alt_string[0]));
|
buffer->alt_string = malloc (buffer->allocated * sizeof (buffer->alt_string[0]));
|
||||||
|
@ -106,8 +104,14 @@ hb_buffer_duplicate_out_buffer (HB_Buffer buffer)
|
||||||
buffer->out_string = buffer->alt_string;
|
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;
|
buffer->separate_out = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
return HB_Err_Ok;
|
static void
|
||||||
|
hb_buffer_ensure_separate (hb_buffer_t *buffer, unsigned int size)
|
||||||
|
{
|
||||||
|
hb_buffer_ensure (buffer, size);
|
||||||
|
if ( !buffer->separate_out )
|
||||||
|
hb_buffer_duplicate_out_buffer (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Public API */
|
/* Public API */
|
||||||
|
@ -132,7 +136,7 @@ hb_buffer_new (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
hb_buffer_free (HB_Buffer buffer)
|
hb_buffer_free (hb_buffer_t *buffer)
|
||||||
{
|
{
|
||||||
free (buffer->in_string);
|
free (buffer->in_string);
|
||||||
free (buffer->alt_string);
|
free (buffer->alt_string);
|
||||||
|
@ -141,7 +145,7 @@ hb_buffer_free (HB_Buffer buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
hb_buffer_clear (HB_Buffer buffer)
|
hb_buffer_clear (hb_buffer_t *buffer)
|
||||||
{
|
{
|
||||||
buffer->in_length = 0;
|
buffer->in_length = 0;
|
||||||
buffer->out_length = 0;
|
buffer->out_length = 0;
|
||||||
|
@ -149,7 +153,7 @@ hb_buffer_clear (HB_Buffer buffer)
|
||||||
buffer->out_pos = 0;
|
buffer->out_pos = 0;
|
||||||
buffer->out_string = buffer->in_string;
|
buffer->out_string = buffer->in_string;
|
||||||
buffer->separate_out = FALSE;
|
buffer->separate_out = FALSE;
|
||||||
buffer->max_ligID = 0;
|
buffer->max_lig_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -158,8 +162,7 @@ hb_buffer_add_glyph (hb_buffer_t *buffer,
|
||||||
unsigned int properties,
|
unsigned int properties,
|
||||||
unsigned int cluster)
|
unsigned int cluster)
|
||||||
{
|
{
|
||||||
HB_Error error;
|
hb_glyph_info_t *glyph;
|
||||||
HB_GlyphItem glyph;
|
|
||||||
|
|
||||||
hb_buffer_ensure (buffer, buffer->in_length + 1);
|
hb_buffer_ensure (buffer, buffer->in_length + 1);
|
||||||
|
|
||||||
|
@ -169,7 +172,7 @@ hb_buffer_add_glyph (hb_buffer_t *buffer,
|
||||||
glyph->cluster = cluster;
|
glyph->cluster = cluster;
|
||||||
glyph->component = 0;
|
glyph->component = 0;
|
||||||
glyph->ligID = 0;
|
glyph->ligID = 0;
|
||||||
glyph->gproperty = HB_GLYPH_PROPERTY_UNKNOWN;
|
glyph->gproperty = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
|
||||||
|
|
||||||
buffer->in_length++;
|
buffer->in_length++;
|
||||||
}
|
}
|
||||||
|
@ -177,7 +180,7 @@ hb_buffer_add_glyph (hb_buffer_t *buffer,
|
||||||
/* HarfBuzz-Internal API */
|
/* HarfBuzz-Internal API */
|
||||||
|
|
||||||
HB_INTERNAL void
|
HB_INTERNAL void
|
||||||
_hb_buffer_clear_output (HB_Buffer buffer)
|
_hb_buffer_clear_output (hb_buffer_t *buffer)
|
||||||
{
|
{
|
||||||
buffer->out_length = 0;
|
buffer->out_length = 0;
|
||||||
buffer->out_pos = 0;
|
buffer->out_pos = 0;
|
||||||
|
@ -185,41 +188,41 @@ _hb_buffer_clear_output (HB_Buffer buffer)
|
||||||
buffer->separate_out = FALSE;
|
buffer->separate_out = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
HB_INTERNAL HB_Error
|
HB_INTERNAL void
|
||||||
_hb_buffer_clear_positions (HB_Buffer buffer)
|
_hb_buffer_clear_positions (hb_buffer_t *buffer)
|
||||||
{
|
{
|
||||||
_hb_buffer_clear_output (buffer);
|
_hb_buffer_clear_output (buffer);
|
||||||
|
|
||||||
if (!buffer->positions)
|
if (HB_UNLIKELY (!buffer->positions))
|
||||||
buffer->positions = malloc (buffer->allocated * sizeof (buffer->positions[0]));
|
{
|
||||||
|
buffer->positions = calloc (buffer->allocated, sizeof (buffer->positions[0]));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
memset (buffer->positions, 0, sizeof (buffer->positions[0]) * buffer->in_length);
|
memset (buffer->positions, 0, sizeof (buffer->positions[0]) * buffer->in_length);
|
||||||
|
|
||||||
return HB_Err_Ok;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HB_INTERNAL void
|
HB_INTERNAL void
|
||||||
_hb_buffer_swap (HB_Buffer buffer)
|
_hb_buffer_swap (hb_buffer_t *buffer)
|
||||||
{
|
{
|
||||||
HB_GlyphItem tmp_string;
|
unsigned int tmp;
|
||||||
int tmp_length;
|
|
||||||
int tmp_pos;
|
|
||||||
|
|
||||||
if (buffer->separate_out)
|
if (buffer->separate_out)
|
||||||
{
|
{
|
||||||
|
hb_glyph_info_t *tmp_string;
|
||||||
tmp_string = buffer->in_string;
|
tmp_string = buffer->in_string;
|
||||||
buffer->in_string = buffer->out_string;
|
buffer->in_string = buffer->out_string;
|
||||||
buffer->out_string = tmp_string;
|
buffer->out_string = tmp_string;
|
||||||
buffer->alt_string = buffer->out_string;
|
buffer->alt_string = buffer->out_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp_length = buffer->in_length;
|
tmp = buffer->in_length;
|
||||||
buffer->in_length = buffer->out_length;
|
buffer->in_length = buffer->out_length;
|
||||||
buffer->out_length = tmp_length;
|
buffer->out_length = tmp;
|
||||||
|
|
||||||
tmp_pos = buffer->in_pos;
|
tmp = buffer->in_pos;
|
||||||
buffer->in_pos = buffer->out_pos;
|
buffer->in_pos = buffer->out_pos;
|
||||||
buffer->out_pos = tmp_pos;
|
buffer->out_pos = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The following function copies `num_out' elements from `glyph_data'
|
/* The following function copies `num_out' elements from `glyph_data'
|
||||||
|
@ -241,7 +244,7 @@ _hb_buffer_swap (HB_Buffer buffer)
|
||||||
|
|
||||||
The cluster value for the glyph at position buffer->in_pos is used
|
The cluster value for the glyph at position buffer->in_pos is used
|
||||||
for all replacement glyphs */
|
for all replacement glyphs */
|
||||||
HB_INTERNAL HB_Error
|
HB_INTERNAL void
|
||||||
_hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
|
_hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
|
||||||
unsigned int num_in,
|
unsigned int num_in,
|
||||||
unsigned int num_out,
|
unsigned int num_out,
|
||||||
|
@ -249,66 +252,67 @@ _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
|
||||||
unsigned short component,
|
unsigned short component,
|
||||||
unsigned short ligID)
|
unsigned short ligID)
|
||||||
{
|
{
|
||||||
HB_Error error;
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned int properties;
|
unsigned int properties;
|
||||||
unsigned int cluster;
|
unsigned int cluster;
|
||||||
|
|
||||||
hb_buffer_ensure( buffer, buffer->out_pos + num_out );
|
hb_buffer_ensure_separate (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;
|
properties = buffer->in_string[buffer->in_pos].properties;
|
||||||
cluster = buffer->in_string[buffer->in_pos].cluster;
|
cluster = buffer->in_string[buffer->in_pos].cluster;
|
||||||
if ( component == 0xFFFF )
|
if (component == 0xFFFF)
|
||||||
component = buffer->in_string[buffer->in_pos].component;
|
component = buffer->in_string[buffer->in_pos].component;
|
||||||
if ( ligID == 0xFFFF )
|
if (ligID == 0xFFFF)
|
||||||
ligID = buffer->in_string[buffer->in_pos].ligID;
|
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_glyph_info_t *info = &buffer->out_string[buffer->out_pos + i];
|
||||||
|
|
||||||
item->gindex = hb_be_uint16_t (glyph_data_be[i]);
|
info->gindex = hb_be_uint16_t (glyph_data_be[i]);
|
||||||
item->properties = properties;
|
info->properties = properties;
|
||||||
item->cluster = cluster;
|
info->cluster = cluster;
|
||||||
item->component = component;
|
info->component = component;
|
||||||
item->ligID = ligID;
|
info->ligID = ligID;
|
||||||
item->gproperty = HB_GLYPH_PROPERTY_UNKNOWN;
|
info->gproperty = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer->in_pos += num_in;
|
buffer->in_pos += num_in;
|
||||||
buffer->out_pos += num_out;
|
buffer->out_pos += num_out;
|
||||||
|
|
||||||
buffer->out_length = buffer->out_pos;
|
buffer->out_length = buffer->out_pos;
|
||||||
|
|
||||||
return HB_Err_Ok;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HB_INTERNAL HB_Error
|
HB_INTERNAL void
|
||||||
_hb_buffer_add_output_glyph (hb_buffer_t *buffer,
|
_hb_buffer_add_output_glyph (hb_buffer_t *buffer,
|
||||||
hb_codepoint_t glyph_index,
|
hb_codepoint_t glyph_index,
|
||||||
unsigned short component,
|
unsigned short component,
|
||||||
unsigned short ligID)
|
unsigned short ligID)
|
||||||
{
|
{
|
||||||
uint16_t glyph_data = hb_be_uint16_t (glyph_index);
|
hb_glyph_info_t *info;
|
||||||
|
|
||||||
return _hb_buffer_add_output_glyphs (buffer, 1, 1,
|
hb_buffer_ensure_separate (buffer, buffer->out_pos + 1);
|
||||||
&glyph_data, component, ligID);
|
|
||||||
|
info = &buffer->out_string[buffer->out_pos];
|
||||||
|
*info = buffer->in_string[buffer->in_pos];
|
||||||
|
|
||||||
|
info->gindex = glyph_index;
|
||||||
|
if (component != 0xFFFF)
|
||||||
|
info->component = component;
|
||||||
|
if (ligID != 0xFFFF)
|
||||||
|
info->ligID = ligID;
|
||||||
|
info->gproperty = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
|
||||||
|
|
||||||
|
buffer->in_pos++;
|
||||||
|
buffer->out_pos++;
|
||||||
|
|
||||||
|
buffer->out_length = buffer->out_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
HB_INTERNAL HB_Error
|
HB_INTERNAL void
|
||||||
_hb_buffer_next_glyph (HB_Buffer buffer)
|
_hb_buffer_next_glyph (hb_buffer_t *buffer)
|
||||||
{
|
{
|
||||||
HB_Error error;
|
|
||||||
|
|
||||||
if (buffer->separate_out)
|
if (buffer->separate_out)
|
||||||
{
|
{
|
||||||
hb_buffer_ensure (buffer, buffer->out_pos + 1);
|
hb_buffer_ensure (buffer, buffer->out_pos + 1);
|
||||||
|
@ -319,11 +323,9 @@ _hb_buffer_next_glyph (HB_Buffer buffer)
|
||||||
buffer->in_pos++;
|
buffer->in_pos++;
|
||||||
buffer->out_pos++;
|
buffer->out_pos++;
|
||||||
buffer->out_length = buffer->out_pos;
|
buffer->out_length = buffer->out_pos;
|
||||||
|
|
||||||
return HB_Err_Ok;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HB_INTERNAL HB_Error
|
HB_INTERNAL void
|
||||||
_hb_buffer_replace_glyph (hb_buffer_t *buffer,
|
_hb_buffer_replace_glyph (hb_buffer_t *buffer,
|
||||||
hb_codepoint_t glyph_index)
|
hb_codepoint_t glyph_index)
|
||||||
{
|
{
|
||||||
|
@ -339,12 +341,10 @@ _hb_buffer_replace_glyph (hb_buffer_t *buffer,
|
||||||
{
|
{
|
||||||
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 unsigned short
|
HB_INTERNAL unsigned short
|
||||||
_hb_buffer_allocate_ligid (hb_buffer_t *buffer)
|
_hb_buffer_allocate_lig_id (hb_buffer_t *buffer)
|
||||||
{
|
{
|
||||||
return ++buffer->max_ligID;
|
return ++buffer->max_lig_id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,16 +34,16 @@ HB_BEGIN_DECLS
|
||||||
|
|
||||||
/* XXX Hide structs? */
|
/* XXX Hide structs? */
|
||||||
|
|
||||||
typedef struct HB_GlyphItemRec_ {
|
typedef struct _hb_glyph_info_t {
|
||||||
hb_codepoint_t gindex;
|
hb_codepoint_t gindex;
|
||||||
unsigned int properties;
|
unsigned int properties;
|
||||||
unsigned int cluster;
|
unsigned int cluster;
|
||||||
unsigned short component;
|
unsigned short component;
|
||||||
unsigned short ligID;
|
unsigned short ligID;
|
||||||
unsigned short gproperty;
|
unsigned short gproperty;
|
||||||
} HB_GlyphItemRec, *HB_GlyphItem;
|
} hb_glyph_info_t;
|
||||||
|
|
||||||
typedef struct HB_PositionRec_ {
|
typedef struct _hb_glyph_position_t {
|
||||||
hb_position_t x_pos;
|
hb_position_t x_pos;
|
||||||
hb_position_t y_pos;
|
hb_position_t y_pos;
|
||||||
hb_position_t x_advance;
|
hb_position_t x_advance;
|
||||||
|
@ -57,7 +57,7 @@ typedef struct HB_PositionRec_ {
|
||||||
short cursive_chain; /* character to which this connects,
|
short cursive_chain; /* character to which this connects,
|
||||||
may be positive or negative; used
|
may be positive or negative; used
|
||||||
only internally */
|
only internally */
|
||||||
} HB_PositionRec, *HB_Position;
|
} hb_glyph_position_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _hb_buffer_t {
|
typedef struct _hb_buffer_t {
|
||||||
|
@ -68,13 +68,13 @@ typedef struct _hb_buffer_t {
|
||||||
unsigned int in_pos;
|
unsigned int in_pos;
|
||||||
unsigned int out_pos;
|
unsigned int out_pos;
|
||||||
|
|
||||||
hb_bool_t separate_out;
|
hb_bool_t separate_out;
|
||||||
HB_GlyphItem in_string;
|
hb_glyph_info_t *in_string;
|
||||||
HB_GlyphItem out_string;
|
hb_glyph_info_t *out_string;
|
||||||
HB_GlyphItem alt_string;
|
hb_glyph_info_t *alt_string;
|
||||||
HB_Position positions;
|
hb_glyph_position_t *positions;
|
||||||
unsigned int max_ligID;
|
unsigned int max_lig_id;
|
||||||
} HB_BufferRec, *HB_Buffer, hb_buffer_t;
|
} hb_buffer_t;
|
||||||
|
|
||||||
hb_buffer_t *
|
hb_buffer_t *
|
||||||
hb_buffer_new (void);
|
hb_buffer_new (void);
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
#include "hb-ot-layout-gsubgpos-private.h"
|
#include "hb-ot-layout-gsubgpos-private.h"
|
||||||
|
|
||||||
|
#define HB_OT_LAYOUT_GPOS_NO_LAST ((unsigned int) -1)
|
||||||
|
|
||||||
/* Shared Tables: ValueRecord, Anchor Table, and MarkArray */
|
/* Shared Tables: ValueRecord, Anchor Table, and MarkArray */
|
||||||
|
|
||||||
|
@ -55,10 +56,10 @@ struct ValueFormat : USHORT
|
||||||
return _hb_popcount32 ((unsigned int) *this);
|
return _hb_popcount32 ((unsigned int) *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
const void apply_value (hb_ot_layout_t *layout,
|
const void apply_value (hb_ot_layout_t *layout,
|
||||||
const char *base,
|
const char *base,
|
||||||
const Value *values,
|
const Value *values,
|
||||||
HB_Position glyph_pos) const
|
hb_glyph_position_t *glyph_pos) const
|
||||||
{
|
{
|
||||||
unsigned int x_ppem, y_ppem;
|
unsigned int x_ppem, y_ppem;
|
||||||
hb_16dot16_t x_scale, y_scale;
|
hb_16dot16_t x_scale, y_scale;
|
||||||
|
@ -379,7 +380,7 @@ struct PairPosFormat1
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
unsigned int j = buffer->in_pos + 1;
|
unsigned int j = buffer->in_pos + 1;
|
||||||
while (!_hb_ot_layout_check_glyph_property (layout, IN_ITEM (j), lookup_flag, &property))
|
while (!_hb_ot_layout_check_glyph_property (layout, IN_INFO (j), lookup_flag, &property))
|
||||||
{
|
{
|
||||||
if (HB_UNLIKELY (j == end))
|
if (HB_UNLIKELY (j == end))
|
||||||
return false;
|
return false;
|
||||||
|
@ -444,7 +445,7 @@ struct PairPosFormat2
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
unsigned int j = buffer->in_pos + 1;
|
unsigned int j = buffer->in_pos + 1;
|
||||||
while (!_hb_ot_layout_check_glyph_property (layout, IN_ITEM (j), lookup_flag, &property))
|
while (!_hb_ot_layout_check_glyph_property (layout, IN_INFO (j), lookup_flag, &property))
|
||||||
{
|
{
|
||||||
if (HB_UNLIKELY (j == end))
|
if (HB_UNLIKELY (j == end))
|
||||||
return false;
|
return false;
|
||||||
|
@ -664,7 +665,7 @@ struct CursivePosFormat1
|
||||||
|
|
||||||
struct hb_ot_layout_t::gpos_info_t *gpi = &layout->gpos_info;
|
struct hb_ot_layout_t::gpos_info_t *gpi = &layout->gpos_info;
|
||||||
hb_codepoint_t last_pos = gpi->last;
|
hb_codepoint_t last_pos = gpi->last;
|
||||||
gpi->last = HB_OT_GPOS_NO_LAST;
|
gpi->last = HB_OT_LAYOUT_GPOS_NO_LAST;
|
||||||
|
|
||||||
/* We don't handle mark glyphs here. */
|
/* We don't handle mark glyphs here. */
|
||||||
if (property == HB_OT_LAYOUT_GLYPH_CLASS_MARK)
|
if (property == HB_OT_LAYOUT_GLYPH_CLASS_MARK)
|
||||||
|
@ -678,7 +679,7 @@ struct CursivePosFormat1
|
||||||
|
|
||||||
hb_position_t entry_x, entry_y, exit_x, exit_y;
|
hb_position_t entry_x, entry_y, exit_x, exit_y;
|
||||||
|
|
||||||
if (last_pos == HB_OT_GPOS_NO_LAST || !record.entryAnchor)
|
if (last_pos == HB_OT_LAYOUT_GPOS_NO_LAST || !record.entryAnchor)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
(this+record.entryAnchor).get_anchor (layout, IN_CURGLYPH (), &entry_x, &entry_y);
|
(this+record.entryAnchor).get_anchor (layout, IN_CURGLYPH (), &entry_x, &entry_y);
|
||||||
|
@ -816,7 +817,7 @@ struct MarkBasePosFormat1
|
||||||
unsigned int index = base_index * classCount + mark_class;
|
unsigned int index = base_index * classCount + mark_class;
|
||||||
(&base_array+base_array.matrix[index]).get_anchor (layout, IN_GLYPH (j), &base_x, &base_y);
|
(&base_array+base_array.matrix[index]).get_anchor (layout, IN_GLYPH (j), &base_x, &base_y);
|
||||||
|
|
||||||
HB_Position o = POSITION (buffer->in_pos);
|
hb_glyph_position_t *o = POSITION (buffer->in_pos);
|
||||||
o->x_pos = base_x - mark_x;
|
o->x_pos = base_x - mark_x;
|
||||||
o->y_pos = base_y - mark_y;
|
o->y_pos = base_y - mark_y;
|
||||||
o->x_advance = 0;
|
o->x_advance = 0;
|
||||||
|
@ -960,7 +961,7 @@ struct MarkLigPosFormat1
|
||||||
unsigned int index = comp_index * classCount + mark_class;
|
unsigned int index = comp_index * classCount + mark_class;
|
||||||
(&lig_attach+lig_attach.matrix[index]).get_anchor (layout, IN_GLYPH (j), &lig_x, &lig_y);
|
(&lig_attach+lig_attach.matrix[index]).get_anchor (layout, IN_GLYPH (j), &lig_x, &lig_y);
|
||||||
|
|
||||||
HB_Position o = POSITION (buffer->in_pos);
|
hb_glyph_position_t *o = POSITION (buffer->in_pos);
|
||||||
o->x_pos = lig_x - mark_x;
|
o->x_pos = lig_x - mark_x;
|
||||||
o->y_pos = lig_y - mark_y;
|
o->y_pos = lig_y - mark_y;
|
||||||
o->x_advance = 0;
|
o->x_advance = 0;
|
||||||
|
@ -1076,7 +1077,7 @@ struct MarkMarkPosFormat1
|
||||||
unsigned int index = mark2_index * classCount + mark1_class;
|
unsigned int index = mark2_index * classCount + mark1_class;
|
||||||
(&mark2_array+mark2_array.matrix[index]).get_anchor (layout, IN_GLYPH (j), &mark2_x, &mark2_y);
|
(&mark2_array+mark2_array.matrix[index]).get_anchor (layout, IN_GLYPH (j), &mark2_x, &mark2_y);
|
||||||
|
|
||||||
HB_Position o = POSITION (buffer->in_pos);
|
hb_glyph_position_t *o = POSITION (buffer->in_pos);
|
||||||
o->x_pos = mark2_x - mark1_x;
|
o->x_pos = mark2_x - mark1_x;
|
||||||
o->y_pos = mark2_y - mark1_y;
|
o->y_pos = mark2_y - mark1_y;
|
||||||
o->x_advance = 0;
|
o->x_advance = 0;
|
||||||
|
@ -1257,7 +1258,7 @@ struct PosLookup : Lookup
|
||||||
unsigned int lookup_flag = get_flag ();
|
unsigned int lookup_flag = get_flag ();
|
||||||
unsigned int property;
|
unsigned int property;
|
||||||
|
|
||||||
if (!_hb_ot_layout_check_glyph_property (layout, IN_CURITEM (), lookup_flag, &property))
|
if (!_hb_ot_layout_check_glyph_property (layout, IN_CURINFO (), lookup_flag, &property))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < get_subtable_count (); i++)
|
for (unsigned int i = 0; i < get_subtable_count (); i++)
|
||||||
|
@ -1276,7 +1277,7 @@ struct PosLookup : Lookup
|
||||||
if (HB_UNLIKELY (!buffer->in_length))
|
if (HB_UNLIKELY (!buffer->in_length))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
layout->gpos_info.last = HB_OT_GPOS_NO_LAST; /* no last valid glyph for cursive pos. */
|
layout->gpos_info.last = HB_OT_LAYOUT_GPOS_NO_LAST; /* no last valid glyph for cursive pos. */
|
||||||
|
|
||||||
buffer->in_pos = 0;
|
buffer->in_pos = 0;
|
||||||
while (buffer->in_pos < buffer->in_length)
|
while (buffer->in_pos < buffer->in_length)
|
||||||
|
@ -1292,7 +1293,7 @@ struct PosLookup : Lookup
|
||||||
done = false;
|
done = false;
|
||||||
/* Contrary to properties defined in GDEF, user-defined properties
|
/* Contrary to properties defined in GDEF, user-defined properties
|
||||||
will always stop a possible cursive positioning. */
|
will always stop a possible cursive positioning. */
|
||||||
layout->gpos_info.last = HB_OT_GPOS_NO_LAST;
|
layout->gpos_info.last = HB_OT_LAYOUT_GPOS_NO_LAST;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!done)
|
if (!done)
|
||||||
|
|
|
@ -303,7 +303,7 @@ struct Ligature
|
||||||
|
|
||||||
for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++)
|
for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++)
|
||||||
{
|
{
|
||||||
while (!_hb_ot_layout_check_glyph_property (layout, IN_ITEM (j), lookup_flag, &property))
|
while (!_hb_ot_layout_check_glyph_property (layout, IN_INFO (j), lookup_flag, &property))
|
||||||
{
|
{
|
||||||
if (HB_UNLIKELY (j + count - i == end))
|
if (HB_UNLIKELY (j + count - i == end))
|
||||||
return false;
|
return false;
|
||||||
|
@ -330,10 +330,10 @@ struct Ligature
|
||||||
1, (const uint16_t *) &ligGlyph,
|
1, (const uint16_t *) &ligGlyph,
|
||||||
0xFFFF,
|
0xFFFF,
|
||||||
IN_LIGID (buffer->in_pos) ?
|
IN_LIGID (buffer->in_pos) ?
|
||||||
0xFFFF : _hb_buffer_allocate_ligid (buffer));
|
0xFFFF : _hb_buffer_allocate_lig_id (buffer));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned int lig_id = _hb_buffer_allocate_ligid (buffer);
|
unsigned int lig_id = _hb_buffer_allocate_lig_id (buffer);
|
||||||
_hb_buffer_add_output_glyph (buffer, ligGlyph, 0xFFFF, lig_id);
|
_hb_buffer_add_output_glyph (buffer, ligGlyph, 0xFFFF, lig_id);
|
||||||
|
|
||||||
/* Now we must do a second loop to copy the skipped glyphs to
|
/* Now we must do a second loop to copy the skipped glyphs to
|
||||||
|
@ -345,7 +345,7 @@ struct Ligature
|
||||||
|
|
||||||
for ( i = 1; i < count; i++ )
|
for ( i = 1; i < count; i++ )
|
||||||
{
|
{
|
||||||
while (!_hb_ot_layout_check_glyph_property (layout, IN_CURITEM(), lookup_flag, &property))
|
while (!_hb_ot_layout_check_glyph_property (layout, IN_CURINFO(), lookup_flag, &property))
|
||||||
_hb_buffer_add_output_glyph (buffer, IN_CURGLYPH(), i - 1, lig_id);
|
_hb_buffer_add_output_glyph (buffer, IN_CURGLYPH(), i - 1, lig_id);
|
||||||
|
|
||||||
(buffer->in_pos)++;
|
(buffer->in_pos)++;
|
||||||
|
@ -652,7 +652,7 @@ struct SubstLookup : Lookup
|
||||||
unsigned int lookup_flag = get_flag ();
|
unsigned int lookup_flag = get_flag ();
|
||||||
unsigned int property;
|
unsigned int property;
|
||||||
|
|
||||||
if (!_hb_ot_layout_check_glyph_property (layout, IN_CURITEM (), lookup_flag, &property))
|
if (!_hb_ot_layout_check_glyph_property (layout, IN_CURINFO (), lookup_flag, &property))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < get_subtable_count (); i++)
|
for (unsigned int i = 0; i < get_subtable_count (); i++)
|
||||||
|
|
|
@ -89,7 +89,7 @@ static inline bool match_input (APPLY_ARG_DEF,
|
||||||
|
|
||||||
for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++)
|
for (i = 1, j = buffer->in_pos + 1; i < count; i++, j++)
|
||||||
{
|
{
|
||||||
while (!_hb_ot_layout_check_glyph_property (layout, IN_ITEM (j), lookup_flag, &property))
|
while (!_hb_ot_layout_check_glyph_property (layout, IN_INFO (j), lookup_flag, &property))
|
||||||
{
|
{
|
||||||
if (HB_UNLIKELY (j + count - i == end))
|
if (HB_UNLIKELY (j + count - i == end))
|
||||||
return false;
|
return false;
|
||||||
|
@ -116,7 +116,7 @@ static inline bool match_backtrack (APPLY_ARG_DEF,
|
||||||
|
|
||||||
for (unsigned int i = 0, j = buffer->out_pos - 1; i < count; i++, j--)
|
for (unsigned int i = 0, j = buffer->out_pos - 1; i < count; i++, j--)
|
||||||
{
|
{
|
||||||
while (!_hb_ot_layout_check_glyph_property (layout, OUT_ITEM (j), lookup_flag, &property))
|
while (!_hb_ot_layout_check_glyph_property (layout, OUT_INFO (j), lookup_flag, &property))
|
||||||
{
|
{
|
||||||
if (HB_UNLIKELY (j + 1 == count - i))
|
if (HB_UNLIKELY (j + 1 == count - i))
|
||||||
return false;
|
return false;
|
||||||
|
@ -144,7 +144,7 @@ static inline bool match_lookahead (APPLY_ARG_DEF,
|
||||||
|
|
||||||
for (i = 0, j = buffer->in_pos + offset; i < count; i++, j++)
|
for (i = 0, j = buffer->in_pos + offset; i < count; i++, j++)
|
||||||
{
|
{
|
||||||
while (!_hb_ot_layout_check_glyph_property (layout, OUT_ITEM (j), lookup_flag, &property))
|
while (!_hb_ot_layout_check_glyph_property (layout, OUT_INFO (j), lookup_flag, &property))
|
||||||
{
|
{
|
||||||
if (HB_UNLIKELY (j + count - i == end))
|
if (HB_UNLIKELY (j + count - i == end))
|
||||||
return false;
|
return false;
|
||||||
|
@ -182,7 +182,7 @@ static inline bool apply_lookup (APPLY_ARG_DEF,
|
||||||
* Should be easy for in_place ones at least. */
|
* Should be easy for in_place ones at least. */
|
||||||
for (unsigned int i = 0; i < count; i++)
|
for (unsigned int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
while (!_hb_ot_layout_check_glyph_property (layout, IN_CURITEM (), lookup_flag, &property))
|
while (!_hb_ot_layout_check_glyph_property (layout, IN_CURINFO (), lookup_flag, &property))
|
||||||
{
|
{
|
||||||
if (HB_UNLIKELY (buffer->in_pos == end))
|
if (HB_UNLIKELY (buffer->in_pos == end))
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -83,15 +83,10 @@ _hb_ot_layout_set_glyph_property (hb_ot_layout_t *layout,
|
||||||
unsigned int property);
|
unsigned int property);
|
||||||
|
|
||||||
HB_INTERNAL hb_bool_t
|
HB_INTERNAL hb_bool_t
|
||||||
_hb_ot_layout_check_glyph_property (hb_ot_layout_t *layout,
|
_hb_ot_layout_check_glyph_property (hb_ot_layout_t *layout,
|
||||||
HB_GlyphItem gitem,
|
hb_glyph_info_t *ginfo,
|
||||||
unsigned int lookup_flags,
|
unsigned int lookup_flags,
|
||||||
unsigned int *property);
|
unsigned int *property);
|
||||||
|
|
||||||
/* XXX */
|
|
||||||
void
|
|
||||||
hb_buffer_ensure (hb_buffer_t *buffer,
|
|
||||||
unsigned int size);
|
|
||||||
|
|
||||||
HB_END_DECLS
|
HB_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -160,22 +160,22 @@ _hb_ot_layout_get_glyph_property (hb_ot_layout_t *layout,
|
||||||
}
|
}
|
||||||
|
|
||||||
HB_INTERNAL hb_bool_t
|
HB_INTERNAL hb_bool_t
|
||||||
_hb_ot_layout_check_glyph_property (hb_ot_layout_t *layout,
|
_hb_ot_layout_check_glyph_property (hb_ot_layout_t *layout,
|
||||||
HB_GlyphItem gitem,
|
hb_glyph_info_t *ginfo,
|
||||||
unsigned int lookup_flags,
|
unsigned int lookup_flags,
|
||||||
unsigned int *property)
|
unsigned int *property)
|
||||||
{
|
{
|
||||||
hb_ot_layout_glyph_class_t basic_glyph_class;
|
hb_ot_layout_glyph_class_t basic_glyph_class;
|
||||||
unsigned int desired_attachment_class;
|
unsigned int desired_attachment_class;
|
||||||
|
|
||||||
if (gitem->gproperty == HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN)
|
if (ginfo->gproperty == HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN)
|
||||||
{
|
{
|
||||||
gitem->gproperty = *property = _hb_ot_layout_get_glyph_property (layout, gitem->gindex);
|
ginfo->gproperty = *property = _hb_ot_layout_get_glyph_property (layout, ginfo->gindex);
|
||||||
if (gitem->gproperty == HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED)
|
if (ginfo->gproperty == HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*property = gitem->gproperty;
|
*property = ginfo->gproperty;
|
||||||
|
|
||||||
/* If the glyph was found in the MarkAttachmentClass table,
|
/* If the glyph was found in the MarkAttachmentClass table,
|
||||||
* then that class value is the high byte of the result,
|
* then that class value is the high byte of the result,
|
||||||
|
|
|
@ -100,33 +100,4 @@ _hb_popcount32 (uint32_t mask)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* buffer
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* XXX */
|
|
||||||
#define HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN 0xFFFF
|
|
||||||
#define HB_OT_GPOS_NO_LAST ((unsigned int) -1)
|
|
||||||
|
|
||||||
/* XXX */
|
|
||||||
typedef enum {
|
|
||||||
/* no error */
|
|
||||||
HB_Err_Ok = 0x0000,
|
|
||||||
HB_Err_Not_Covered = 0xFFFF,
|
|
||||||
|
|
||||||
/* _hb_err() is called whenever returning the following errors,
|
|
||||||
* and in a couple places for HB_Err_Not_Covered too. */
|
|
||||||
|
|
||||||
/* programmer error */
|
|
||||||
HB_Err_Invalid_Argument = 0x1A66,
|
|
||||||
|
|
||||||
/* font error */
|
|
||||||
HB_Err_Invalid_SubTable_Format = 0x157F,
|
|
||||||
HB_Err_Invalid_SubTable = 0x1570,
|
|
||||||
HB_Err_Read_Error = 0x6EAD,
|
|
||||||
|
|
||||||
/* system error */
|
|
||||||
HB_Err_Out_Of_Memory = 0xDEAD
|
|
||||||
} HB_Error;
|
|
||||||
|
|
||||||
#endif /* HB_PRIVATE_H */
|
#endif /* HB_PRIVATE_H */
|
||||||
|
|
Loading…
Reference in New Issue