Change buffer default properties to invalid

This includes HB_DIRECTION_INVALID and HB_SCRIPT_INVALID.

The INVALID will cause a "guess whatever from the text" in hb_shape().
While it's not ideal, it works better than the previous defaults at
least (HB_DIRECTION_LTR and HB_SCRIPT_COMMON).
This commit is contained in:
Behdad Esfahbod 2011-04-15 19:26:24 -04:00
parent 00bec2c969
commit c0af193c8e
4 changed files with 27 additions and 24 deletions

View File

@ -94,8 +94,6 @@ struct _hb_buffer_t {
/* Buffer contents */
unsigned int allocated; /* Length of allocated arrays */
hb_bool_t have_output; /* Whether we have an output buffer going on */
hb_bool_t have_positions; /* Whether we have positions */
hb_bool_t in_error; /* Allocation failed */
@ -104,14 +102,13 @@ struct _hb_buffer_t {
unsigned int len; /* Length of ->info and ->pos arrays */
unsigned int out_len; /* Length of ->out array if have_output */
unsigned int serial;
unsigned int allocated; /* Length of allocated arrays */
hb_glyph_info_t *info;
hb_glyph_info_t *out_info;
hb_glyph_position_t *pos;
/* Other stuff */
unsigned int serial;
/* Methods */
inline unsigned int backtrack_len (void) const

View File

@ -37,7 +37,12 @@ HB_BEGIN_DECLS
static hb_buffer_t _hb_buffer_nil = {
HB_REFERENCE_COUNT_INVALID, /* ref_count */
&_hb_unicode_funcs_nil /* unicode */
&_hb_unicode_funcs_nil, /* unicode */
{
HB_DIRECTION_INVALID,
HB_SCRIPT_INVALID,
NULL,
},
};
/* Here is how the buffer works internally:
@ -138,7 +143,7 @@ hb_buffer_create (unsigned int pre_alloc_size)
if (pre_alloc_size)
_hb_buffer_ensure (buffer, pre_alloc_size);
buffer->unicode = &_hb_unicode_funcs_nil;
hb_buffer_reset (buffer);
return buffer;
}
@ -231,19 +236,22 @@ hb_buffer_get_language (hb_buffer_t *buffer)
void
hb_buffer_reset (hb_buffer_t *buffer)
{
buffer->have_output = FALSE;
buffer->have_positions = FALSE;
buffer->in_error = FALSE;
buffer->len = 0;
buffer->out_len = 0;
buffer->i = 0;
buffer->out_info = buffer->info;
buffer->serial = 0;
hb_unicode_funcs_destroy (buffer->unicode);
buffer->unicode = _hb_buffer_nil.unicode;
buffer->props = _hb_buffer_nil.props;
hb_unicode_funcs_destroy (buffer->unicode);
buffer->unicode = _hb_buffer_nil.unicode;
buffer->have_output = FALSE;
buffer->have_positions = FALSE;
buffer->in_error = FALSE;
buffer->i = 0;
buffer->len = 0;
buffer->out_len = 0;
buffer->serial = 0;
buffer->out_info = buffer->info;
}
hb_bool_t

View File

@ -355,10 +355,8 @@ _hb_cr_text_glyphs (cairo_t *cr,
hb_buffer_add_utf8 (hb_buffer, text, len, 0, len);
if (script)
hb_buffer_set_script (hb_buffer, hb_script_from_string (script));
else
hb_buffer_set_script (hb_buffer, HB_SCRIPT_INVALID);
hb_buffer_set_direction (hb_buffer, HB_DIRECTION_INVALID);
hb_buffer_set_language (hb_buffer, hb_language_from_string (language));
if (language)
hb_buffer_set_language (hb_buffer, hb_language_from_string (language));
hb_shape (hb_font, hb_face, hb_buffer, features, num_features);

View File

@ -100,8 +100,8 @@ test_buffer_properties (Fixture *fixture, gconstpointer user_data)
{
/* TODO check unicode_funcs */
g_assert (hb_buffer_get_direction (fixture->b) == HB_DIRECTION_LTR);
g_assert (hb_buffer_get_script (fixture->b) == HB_SCRIPT_COMMON);
g_assert (hb_buffer_get_direction (fixture->b) == HB_DIRECTION_INVALID);
g_assert (hb_buffer_get_script (fixture->b) == HB_SCRIPT_INVALID);
g_assert (hb_buffer_get_language (fixture->b) == NULL);
hb_buffer_set_direction (fixture->b, HB_DIRECTION_RTL);