/* Internal API */
static void
-hb_buffer_ensure (hb_buffer_t *buffer, unsigned int size)
-{
- unsigned int new_allocated = buffer->allocated;
-
- if (size > new_allocated)
- {
- while (size > new_allocated)
- new_allocated += (new_allocated >> 1) + 8;
-
- if (buffer->positions)
- buffer->positions = realloc (buffer->positions, new_allocated * sizeof (buffer->positions[0]));
-
- buffer->in_string = realloc (buffer->in_string, new_allocated * sizeof (buffer->in_string[0]));
-
- if (buffer->out_string != buffer->in_string)
- {
- buffer->alt_string = realloc (buffer->alt_string, new_allocated * sizeof (buffer->alt_string[0]));
- buffer->out_string = buffer->alt_string;
- }
- else
- {
- buffer->out_string = buffer->in_string;
-
- if (buffer->alt_string)
- {
- free (buffer->alt_string);
- buffer->alt_string = NULL;
- }
- }
-
- buffer->allocated = new_allocated;
- }
-}
-
-static void
hb_buffer_ensure_separate (hb_buffer_t *buffer, unsigned int size)
{
hb_buffer_ensure (buffer, size);
/* Public API */
hb_buffer_t *
-hb_buffer_new (void)
+hb_buffer_new (unsigned int allocation_size)
{
hb_buffer_t *buffer;
hb_buffer_clear (buffer);
+ if (allocation_size)
+ hb_buffer_ensure(buffer, allocation_size);
+
return buffer;
}
}
void
+hb_buffer_ensure (hb_buffer_t *buffer, unsigned int size)
+{
+ unsigned int new_allocated = buffer->allocated;
+
+ if (size > new_allocated)
+ {
+ while (size > new_allocated)
+ new_allocated += (new_allocated >> 1) + 8;
+
+ if (buffer->positions)
+ buffer->positions = realloc (buffer->positions, new_allocated * sizeof (buffer->positions[0]));
+
+ if (buffer->out_string != buffer->in_string)
+ {
+ buffer->in_string = realloc (buffer->in_string, new_allocated * sizeof (buffer->in_string[0]));
+ buffer->alt_string = realloc (buffer->alt_string, new_allocated * sizeof (buffer->alt_string[0]));
+ buffer->out_string = buffer->alt_string;
+ }
+ else
+ {
+ buffer->in_string = realloc (buffer->in_string, new_allocated * sizeof (buffer->in_string[0]));
+ buffer->out_string = buffer->in_string;
+
+ if (buffer->alt_string)
+ {
+ free (buffer->alt_string);
+ buffer->alt_string = NULL;
+ }
+ }
+
+ buffer->allocated = new_allocated;
+ }
+}
+
+void
hb_buffer_add_glyph (hb_buffer_t *buffer,
hb_codepoint_t glyph_index,
unsigned int properties,
return layout;
}
+hb_bool_t
+hb_ot_layout_has_substitution (hb_ot_layout_t *layout)
+{
+ return layout->gsub != &Null(GSUB);
+}
+
+hb_bool_t
+hb_ot_layout_has_positioning (hb_ot_layout_t *layout)
+{
+ return layout->gpos != &Null(GPOS);
+}
+
hb_ot_layout_t *
hb_ot_layout_create_for_data (const char *font_data,
int face_index)
return layout;
}
+hb_ot_layout_t *
+hb_ot_layout_create_for_tables (const char *gdef_data,
+ const char *gsub_data,
+ const char *gpos_data)
+{
+ hb_ot_layout_t *layout;
+
+ if (HB_UNLIKELY (gdef_data == NULL && gsub_data == NULL && gpos_data == NULL))
+ return hb_ot_layout_create ();
+
+ layout = (hb_ot_layout_t *) calloc (1, sizeof (hb_ot_layout_t));
+
+ layout->gdef = &GDEF::get_for_data (gdef_data);
+ layout->gsub = &GSUB::get_for_data (gsub_data);
+ layout->gpos = &GPOS::get_for_data (gpos_data);
+
+ return layout;
+}
+
void
hb_ot_layout_destroy (hb_ot_layout_t *layout)
{
hb_ot_layout_create_for_data (const char *font_data,
int face_index);
+hb_ot_layout_t *
+hb_ot_layout_create_for_tables (const char *gdef_data,
+ const char *gsub_data,
+ const char *gpos_data);
+
void
hb_ot_layout_destroy (hb_ot_layout_t *layout);
*/
hb_bool_t
+hb_ot_layout_has_substitution (hb_ot_layout_t *layout);
+
+hb_bool_t
hb_ot_layout_substitute_lookup (hb_ot_layout_t *layout,
hb_buffer_t *buffer,
unsigned int lookup_index,
hb_ot_layout_feature_mask_t mask);
+/*
+ * GPOS
+ */
+
+hb_bool_t
+hb_ot_layout_has_positioning (hb_ot_layout_t *layout);
+
hb_bool_t
hb_ot_layout_position_lookup (hb_ot_layout_t *layout,
hb_buffer_t *buffer,