Make sure gsubgpos buffer vars are available during fallback_position

Add buffer var allocation asserts to a few key places.
This commit is contained in:
Behdad Esfahbod 2014-08-02 17:18:46 -04:00
parent 2053f369f8
commit 8f3eebf7ee
7 changed files with 26 additions and 4 deletions

View File

@ -1589,6 +1589,8 @@ GPOS::position_start (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer)
void
GPOS::position_finish (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer)
{
_hb_buffer_assert_gsubgpos_vars (buffer);
unsigned int len;
hb_glyph_position_t *pos = hb_buffer_get_glyph_positions (buffer, &len);
hb_direction_t direction = buffer->props.direction;
@ -1600,8 +1602,6 @@ GPOS::position_finish (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer)
/* Handle attachments */
for (unsigned int i = 0; i < len; i++)
fix_mark_attachment (pos, i, direction);
_hb_buffer_deallocate_gsubgpos_vars (buffer);
}

View File

@ -1338,7 +1338,7 @@ struct GSUB : GSUBGPOS
void
GSUB::substitute_start (hb_font_t *font, hb_buffer_t *buffer)
{
_hb_buffer_allocate_gsubgpos_vars (buffer);
_hb_buffer_assert_gsubgpos_vars (buffer);
const GDEF &gdef = *hb_ot_layout_from_face (font->face)->gdef;
unsigned int count = buffer->len;

View File

@ -419,6 +419,13 @@ _hb_buffer_deallocate_unicode_vars (hb_buffer_t *buffer)
HB_BUFFER_DEALLOCATE_VAR (buffer, unicode_props1);
}
static inline void
_hb_buffer_assert_unicode_vars (hb_buffer_t *buffer)
{
HB_BUFFER_ASSERT_VAR (buffer, unicode_props0);
HB_BUFFER_ASSERT_VAR (buffer, unicode_props1);
}
static inline void
_hb_buffer_allocate_gsubgpos_vars (hb_buffer_t *buffer)
{
@ -435,6 +442,14 @@ _hb_buffer_deallocate_gsubgpos_vars (hb_buffer_t *buffer)
HB_BUFFER_DEALLOCATE_VAR (buffer, glyph_props);
}
static inline void
_hb_buffer_assert_gsubgpos_vars (hb_buffer_t *buffer)
{
HB_BUFFER_ASSERT_VAR (buffer, glyph_props);
HB_BUFFER_ASSERT_VAR (buffer, lig_props);
HB_BUFFER_ASSERT_VAR (buffer, syllable);
}
/* Make sure no one directly touches our props... */
#undef unicode_props0
#undef unicode_props1

View File

@ -271,7 +271,7 @@ arabic_fallback_plan_init_unicode (arabic_fallback_plan_t *fallback_plan,
const hb_ot_shape_plan_t *plan,
hb_font_t *font)
{
ASSERT_STATIC (ARRAY_LENGTH(arabic_fallback_features) <= ARABIC_FALLBACK_MAX_LOOKUPS);
ASSERT_STATIC (ARRAY_LENGTH_CONST(arabic_fallback_features) <= ARABIC_FALLBACK_MAX_LOOKUPS);
unsigned int j = 0;
for (unsigned int i = 0; i < ARRAY_LENGTH(arabic_fallback_features) ; i++)
{

View File

@ -415,6 +415,8 @@ _hb_ot_shape_fallback_position (const hb_ot_shape_plan_t *plan,
hb_font_t *font,
hb_buffer_t *buffer)
{
_hb_buffer_assert_gsubgpos_vars (buffer);
unsigned int start = 0;
unsigned int last_cluster = buffer->info[0].cluster;
unsigned int count = buffer->len;

View File

@ -289,6 +289,8 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan,
hb_buffer_t *buffer,
hb_font_t *font)
{
_hb_buffer_assert_unicode_vars (buffer);
hb_ot_shape_normalization_mode_t mode = plan->shaper->normalization_preference;
const hb_ot_shape_normalize_context_t c = {
plan,

View File

@ -448,6 +448,7 @@ hb_ot_substitute_complex (hb_ot_shape_context_t *c)
{
hb_buffer_t *buffer = c->buffer;
_hb_buffer_allocate_gsubgpos_vars (buffer);
hb_ot_layout_substitute_start (c->font, buffer);
if (!hb_ot_layout_has_glyph_classes (c->face))
@ -636,6 +637,8 @@ hb_ot_position (hb_ot_shape_context_t *c)
if (fallback)
_hb_ot_shape_fallback_kern (c->plan, c->font, c->buffer);
_hb_buffer_deallocate_gsubgpos_vars (c->buffer);
}