[glib] Add hb_glib_blob_create() that takes GBytes

This commit is contained in:
Behdad Esfahbod 2015-01-06 16:58:33 -08:00
parent b91904a40d
commit 0ef179e2dc
2 changed files with 14 additions and 0 deletions

View File

@ -382,3 +382,14 @@ hb_glib_get_unicode_funcs (void)
return const_cast<hb_unicode_funcs_t *> (&_hb_glib_unicode_funcs); return const_cast<hb_unicode_funcs_t *> (&_hb_glib_unicode_funcs);
} }
hb_blob_t *
hb_glib_blob_create (GBytes *gbytes)
{
gsize size = 0;
gconstpointer data = g_bytes_get_data (gbytes, &size);
return hb_blob_create ((const char *) data,
size,
HB_MEMORY_MODE_READONLY,
g_bytes_ref (gbytes),
(hb_destroy_func_t) g_bytes_unref);
}

View File

@ -46,6 +46,9 @@ hb_glib_script_from_script (hb_script_t script);
hb_unicode_funcs_t * hb_unicode_funcs_t *
hb_glib_get_unicode_funcs (void); hb_glib_get_unicode_funcs (void);
hb_blob_t *
hb_glib_blob_create (GBytes *gbytes);
HB_END_DECLS HB_END_DECLS