提交 f1322e52 编写于 作者: B Behdad Esfahbod

[HB] Cleanup public buffer structs

上级 6d5bb18e
......@@ -36,6 +36,36 @@ HB_BEGIN_DECLS
#define HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN 0xFFFF
typedef struct _hb_internal_glyph_info_t {
hb_codepoint_t codepoint;
uint32_t properties;
uint32_t cluster;
uint16_t component;
uint16_t lig_id;
uint32_t gproperty;
} hb_internal_glyph_info_t;
typedef struct _hb_internal_glyph_position_t {
hb_position_t x_pos;
hb_position_t y_pos;
hb_position_t x_advance;
hb_position_t y_advance;
hb_bool_t new_advance :1; /* 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 */
unsigned short back : 15; /* number of glyphs to go back
for drawing current glyph */
short cursive_chain : 16; /* character to which this connects,
may be positive or negative; used
only internally */
} hb_internal_glyph_position_t;
ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_internal_glyph_info_t));
ASSERT_STATIC (sizeof (hb_glyph_position_t) == sizeof (hb_internal_glyph_position_t));
ASSERT_STATIC (sizeof (hb_glyph_info_t) == sizeof (hb_glyph_position_t));
struct _hb_buffer_t {
hb_reference_count_t ref_count;
......@@ -46,10 +76,10 @@ struct _hb_buffer_t {
unsigned int in_pos;
unsigned int out_pos;
hb_glyph_info_t *in_string;
hb_glyph_info_t *out_string;
hb_glyph_info_t *alt_string;
hb_glyph_position_t *positions;
hb_internal_glyph_info_t *in_string;
hb_internal_glyph_info_t *out_string;
hb_internal_glyph_info_t *alt_string;
hb_internal_glyph_position_t *positions;
hb_direction_t direction;
unsigned int max_lig_id;
......@@ -88,16 +118,16 @@ _hb_buffer_allocate_lig_id (hb_buffer_t *buffer);
/* convenience macros */
#define IN_GLYPH(pos) (buffer->in_string[(pos)].gindex)
#define IN_GLYPH(pos) (buffer->in_string[(pos)].codepoint)
#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].codepoint)
#define IN_CURINFO() (&buffer->in_string[buffer->in_pos])
#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)].lig_id)
#define IN_COMPONENT(pos) (buffer->in_string[(pos)].component)
#define POSITION(pos) (&buffer->positions[(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)].codepoint)
#define OUT_INFO(pos) (&buffer->out_string[(pos)])
HB_END_DECLS
......
......@@ -29,6 +29,7 @@
#include <string.h>
static hb_buffer_t _hb_buffer_nil = {
HB_REFERENCE_COUNT_INVALID /* ref_count */
};
......@@ -158,21 +159,21 @@ hb_buffer_ensure (hb_buffer_t *buffer, unsigned int size)
void
hb_buffer_add_glyph (hb_buffer_t *buffer,
hb_codepoint_t glyph_index,
hb_codepoint_t codepoint,
unsigned int properties,
unsigned int cluster)
{
hb_glyph_info_t *glyph;
hb_internal_glyph_info_t *glyph;
hb_buffer_ensure (buffer, buffer->in_length + 1);
glyph = &buffer->in_string[buffer->in_length];
glyph->gindex = glyph_index;
glyph->codepoint = codepoint;
glyph->properties = properties;
glyph->cluster = cluster;
glyph->component = 0;
glyph->ligID = 0;
glyph->internal = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
glyph->lig_id = 0;
glyph->gproperty = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
buffer->in_length++;
}
......@@ -217,7 +218,7 @@ _hb_buffer_swap (hb_buffer_t *buffer)
if (buffer->out_string != buffer->in_string)
{
hb_glyph_info_t *tmp_string;
hb_internal_glyph_info_t *tmp_string;
tmp_string = buffer->in_string;
buffer->in_string = buffer->out_string;
buffer->out_string = tmp_string;
......@@ -243,9 +244,9 @@ _hb_buffer_swap (hb_buffer_t *buffer)
will copied `num_out' times, otherwise `component' itself will
be used to fill the `component' fields.
If `ligID' is 0xFFFF, the ligID value from buffer->in_pos
will copied `num_out' times, otherwise `ligID' itself will
be used to fill the `ligID' fields.
If `lig_id' is 0xFFFF, the lig_id value from buffer->in_pos
will copied `num_out' times, otherwise `lig_id' itself will
be used to fill the `lig_id' fields.
The properties for all replacement glyphs are taken
from the glyph at position `buffer->in_pos'.
......@@ -258,7 +259,7 @@ _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
unsigned int num_out,
const uint16_t *glyph_data_be,
unsigned short component,
unsigned short ligID)
unsigned short lig_id)
{
unsigned int i;
unsigned int properties;
......@@ -274,18 +275,18 @@ _hb_buffer_add_output_glyphs (hb_buffer_t *buffer,
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;
if (lig_id == 0xFFFF)
lig_id = buffer->in_string[buffer->in_pos].lig_id;
for (i = 0; i < num_out; i++)
{
hb_glyph_info_t *info = &buffer->out_string[buffer->out_pos + i];
info->gindex = hb_be_uint16 (glyph_data_be[i]);
hb_internal_glyph_info_t *info = &buffer->out_string[buffer->out_pos + i];
info->codepoint = hb_be_uint16 (glyph_data_be[i]);
info->properties = properties;
info->cluster = cluster;
info->component = component;
info->ligID = ligID;
info->internal = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
info->lig_id = lig_id;
info->gproperty = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
}
buffer->in_pos += num_in;
......@@ -298,9 +299,9 @@ HB_INTERNAL void
_hb_buffer_add_output_glyph (hb_buffer_t *buffer,
hb_codepoint_t glyph_index,
unsigned short component,
unsigned short ligID)
unsigned short lig_id)
{
hb_glyph_info_t *info;
hb_internal_glyph_info_t *info;
if (buffer->out_string != buffer->in_string)
{
......@@ -311,12 +312,12 @@ _hb_buffer_add_output_glyph (hb_buffer_t *buffer,
buffer->out_string[buffer->out_pos] = buffer->in_string[buffer->in_pos];
info = &buffer->out_string[buffer->out_pos];
info->gindex = glyph_index;
info->codepoint = glyph_index;
if (component != 0xFFFF)
info->component = component;
if (ligID != 0xFFFF)
info->ligID = ligID;
info->internal = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
if (lig_id != 0xFFFF)
info->lig_id = lig_id;
info->gproperty = HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN;
buffer->in_pos++;
buffer->out_pos++;
......@@ -363,7 +364,7 @@ hb_buffer_get_len (hb_buffer_t *buffer)
hb_glyph_info_t *
hb_buffer_get_glyph_infos (hb_buffer_t *buffer)
{
return buffer->in_string;
return (hb_glyph_info_t *) buffer->in_string;
}
/* Return value valid as long as buffer not modified */
......@@ -373,5 +374,5 @@ hb_buffer_get_glyph_positions (hb_buffer_t *buffer)
if (buffer->in_length && !buffer->positions)
hb_buffer_clear_positions (buffer);
return buffer->positions;
return (hb_glyph_position_t *) buffer->positions;
}
......@@ -41,15 +41,13 @@ typedef enum _hb_direction_t {
HB_DIRECTION_BTT
} hb_direction_t;
/* XXX these structs need review before we can commit to them */
typedef struct _hb_glyph_info_t {
hb_codepoint_t gindex;
unsigned int properties;
unsigned int cluster;
unsigned short component;
unsigned short ligID;
unsigned int internal;
hb_codepoint_t codepoint;
uint32_t properties;
uint32_t cluster;
uint16_t component;
uint16_t lig_id;
uint32_t internal;
} hb_glyph_info_t;
typedef struct _hb_glyph_position_t {
......@@ -57,13 +55,14 @@ typedef struct _hb_glyph_position_t {
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
/* XXX these should all be replaced by "uint32_t internal" */
hb_bool_t new_advance :1; /* 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,
unsigned short back : 15; /* number of glyphs to go back
for drawing current glyph */
short cursive_chain : 16; /* character to which this connects,
may be positive or negative; used
only internally */
} hb_glyph_position_t;
......@@ -103,7 +102,7 @@ hb_buffer_ensure (hb_buffer_t *buffer,
void
hb_buffer_add_glyph (hb_buffer_t *buffer,
hb_codepoint_t glyph_index,
hb_codepoint_t codepoint,
unsigned int properties,
unsigned int cluster);
......
......@@ -58,7 +58,7 @@ struct ValueFormat : USHORT
const void apply_value (hb_ot_layout_t *layout,
const char *base,
const Value *values,
hb_glyph_position_t *glyph_pos) const
hb_internal_glyph_position_t *glyph_pos) const
{
unsigned int x_ppem, y_ppem;
hb_16dot16_t x_scale, y_scale;
......@@ -825,7 +825,7 @@ struct MarkBasePosFormat1
unsigned int index = base_index * classCount + mark_class;
(&base_array+base_array.matrix[index]).get_anchor (layout, IN_GLYPH (j), &base_x, &base_y);
hb_glyph_position_t *o = POSITION (buffer->in_pos);
hb_internal_glyph_position_t *o = POSITION (buffer->in_pos);
o->x_pos = base_x - mark_x;
o->y_pos = base_y - mark_y;
o->x_advance = 0;
......@@ -962,7 +962,7 @@ struct MarkLigPosFormat1
unsigned int index = comp_index * classCount + mark_class;
(&lig_attach+lig_attach.matrix[index]).get_anchor (layout, IN_GLYPH (j), &lig_x, &lig_y);
hb_glyph_position_t *o = POSITION (buffer->in_pos);
hb_internal_glyph_position_t *o = POSITION (buffer->in_pos);
o->x_pos = lig_x - mark_x;
o->y_pos = lig_y - mark_y;
o->x_advance = 0;
......@@ -1077,7 +1077,7 @@ struct MarkMarkPosFormat1
unsigned int index = mark2_index * classCount + mark1_class;
(&mark2_array+mark2_array.matrix[index]).get_anchor (layout, IN_GLYPH (j), &mark2_x, &mark2_y);
hb_glyph_position_t *o = POSITION (buffer->in_pos);
hb_internal_glyph_position_t *o = POSITION (buffer->in_pos);
o->x_pos = mark2_x - mark1_x;
o->y_pos = mark2_y - mark1_y;
o->x_advance = 0;
......
......@@ -29,6 +29,7 @@
#include "hb-private.h"
#include "hb-ot-layout.h"
#include "hb-buffer-private.h"
typedef unsigned int hb_ot_layout_class_t;
......@@ -78,13 +79,13 @@ _hb_ot_layout_set_glyph_property (hb_ot_layout_t *layout,
HB_INTERNAL hb_bool_t
_hb_ot_layout_check_glyph_property (hb_ot_layout_t *layout,
hb_glyph_info_t *ginfo,
hb_internal_glyph_info_t *ginfo,
unsigned int lookup_flags,
unsigned int *property);
HB_INTERNAL hb_bool_t
_hb_ot_layout_skip_mark (hb_ot_layout_t *layout,
hb_glyph_info_t *ginfo,
hb_internal_glyph_info_t *ginfo,
unsigned int lookup_flags,
unsigned int *property);
......
......@@ -176,15 +176,15 @@ _hb_ot_layout_get_glyph_property (hb_ot_layout_t *layout,
HB_INTERNAL hb_bool_t
_hb_ot_layout_check_glyph_property (hb_ot_layout_t *layout,
hb_glyph_info_t *ginfo,
hb_internal_glyph_info_t *ginfo,
unsigned int lookup_flags,
unsigned int *property_out)
{
unsigned int property;
if (ginfo->internal == HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN)
ginfo->internal = _hb_ot_layout_get_glyph_property (layout, ginfo->gindex);
property = ginfo->internal;
if (ginfo->gproperty == HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN)
ginfo->gproperty = _hb_ot_layout_get_glyph_property (layout, ginfo->codepoint);
property = ginfo->gproperty;
if (property_out)
*property_out = property;
......@@ -200,7 +200,7 @@ _hb_ot_layout_check_glyph_property (hb_ot_layout_t *layout,
* lookup_flags has the set index.
*/
if (lookup_flags & LookupFlag::UseMarkFilteringSet)
return layout->gdef->mark_set_covers (lookup_flags >> 16, ginfo->gindex);
return layout->gdef->mark_set_covers (lookup_flags >> 16, ginfo->codepoint);
/* The second byte of lookup_flags has the meaning
* "ignore marks of attachment type different than
......@@ -215,15 +215,15 @@ _hb_ot_layout_check_glyph_property (hb_ot_layout_t *layout,
HB_INTERNAL hb_bool_t
_hb_ot_layout_skip_mark (hb_ot_layout_t *layout,
hb_glyph_info_t *ginfo,
hb_internal_glyph_info_t *ginfo,
unsigned int lookup_flags,
unsigned int *property_out)
{
unsigned int property;
if (ginfo->internal == HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN)
ginfo->internal = _hb_ot_layout_get_glyph_property (layout, ginfo->gindex);
property = ginfo->internal;
if (ginfo->gproperty == HB_BUFFER_GLYPH_PROPERTIES_UNKNOWN)
ginfo->gproperty = _hb_ot_layout_get_glyph_property (layout, ginfo->codepoint);
property = ginfo->gproperty;
if (property_out)
*property_out = property;
......@@ -235,7 +235,7 @@ _hb_ot_layout_skip_mark (hb_ot_layout_t *layout,
/* If using mark filtering sets, the high short of lookup_flags has the set index. */
if (lookup_flags & LookupFlag::UseMarkFilteringSet)
return !layout->gdef->mark_set_covers (lookup_flags >> 16, ginfo->gindex);
return !layout->gdef->mark_set_covers (lookup_flags >> 16, ginfo->codepoint);
/* The second byte of lookup_flags has the meaning "ignore marks of attachment type
* different than the attachment type specified." */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册