[wasm-api] Change face_copy_table to return success
This commit is contained in:
parent
83b9c34f0b
commit
2004528cf8
|
@ -31,22 +31,33 @@ namespace hb {
|
||||||
namespace wasm {
|
namespace wasm {
|
||||||
|
|
||||||
|
|
||||||
HB_WASM_API_COMPOUND (blob_t, face_copy_table) (HB_WASM_EXEC_ENV_COMPOUND
|
HB_WASM_API (bool_t, face_copy_table) (HB_WASM_EXEC_ENV
|
||||||
ptr_d(face_t, face),
|
ptr_d(face_t, face),
|
||||||
tag_t table_tag)
|
tag_t table_tag,
|
||||||
|
ptr_d(blob_t, blob))
|
||||||
{
|
{
|
||||||
HB_RETURN_STRUCT (blob_t, ret);
|
|
||||||
HB_REF2OBJ (face);
|
HB_REF2OBJ (face);
|
||||||
|
HB_PTR_PARAM (blob_t, blob);
|
||||||
|
if (unlikely (!blob))
|
||||||
|
return false;
|
||||||
|
|
||||||
hb_blob_t *blob = hb_face_reference_table (face, table_tag);
|
hb_blob_t *hb_blob = hb_face_reference_table (face, table_tag);
|
||||||
|
|
||||||
unsigned length;
|
unsigned length;
|
||||||
const char *data = hb_blob_get_data (blob, &length);
|
const char *data = hb_blob_get_data (hb_blob, &length);
|
||||||
|
|
||||||
ret.length = length;
|
blob->length = length;
|
||||||
ret.data = wasm_runtime_module_dup_data (module_inst, data, length);
|
blob->data = wasm_runtime_module_dup_data (module_inst, data, length);
|
||||||
|
|
||||||
hb_blob_destroy (blob);
|
hb_blob_destroy (hb_blob);
|
||||||
|
|
||||||
|
if (blob->length && !blob->data)
|
||||||
|
{
|
||||||
|
blob->length = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
HB_WASM_API (unsigned, face_get_upem) (HB_WASM_EXEC_ENV
|
HB_WASM_API (unsigned, face_get_upem) (HB_WASM_EXEC_ENV
|
||||||
|
|
|
@ -67,7 +67,7 @@ static NativeSymbol _hb_wasm_native_symbols[] =
|
||||||
NATIVE_SYMBOL ("(i)", buffer_reverse_clusters),
|
NATIVE_SYMBOL ("(i)", buffer_reverse_clusters),
|
||||||
|
|
||||||
/* face */
|
/* face */
|
||||||
NATIVE_SYMBOL ("(iii)", face_copy_table),
|
NATIVE_SYMBOL ("(iii)i", face_copy_table),
|
||||||
NATIVE_SYMBOL ("(i)i", face_get_upem),
|
NATIVE_SYMBOL ("(i)i", face_get_upem),
|
||||||
|
|
||||||
/* font */
|
/* font */
|
||||||
|
|
|
@ -173,9 +173,10 @@ HB_WASM_API (void, buffer_reverse_clusters) (HB_WASM_EXEC_ENV
|
||||||
|
|
||||||
typedef struct face_t face_t;
|
typedef struct face_t face_t;
|
||||||
|
|
||||||
HB_WASM_API_COMPOUND (blob_t, face_copy_table) (HB_WASM_EXEC_ENV_COMPOUND
|
HB_WASM_API (bool_t, face_copy_table) (HB_WASM_EXEC_ENV
|
||||||
ptr_d(face_t, face),
|
ptr_d(face_t, face),
|
||||||
tag_t table_tag);
|
tag_t table_tag,
|
||||||
|
ptr_d(blob_t, blob));
|
||||||
|
|
||||||
HB_WASM_API (unsigned, face_get_upem) (HB_WASM_EXEC_ENV
|
HB_WASM_API (unsigned, face_get_upem) (HB_WASM_EXEC_ENV
|
||||||
ptr_d(face_t, face));
|
ptr_d(face_t, face));
|
||||||
|
|
|
@ -21,7 +21,9 @@ uint32_t heap_size = 2 * 1024 * 1024;
|
||||||
static const void *copy_table (const void *data, unsigned int tag, size_t *len)
|
static const void *copy_table (const void *data, unsigned int tag, size_t *len)
|
||||||
{
|
{
|
||||||
face_t *face = (face_t *) data;
|
face_t *face = (face_t *) data;
|
||||||
blob_t blob = face_copy_table (face, tag);
|
blob_t blob;
|
||||||
|
if (!face_copy_table (face, tag, &blob))
|
||||||
|
abort ();
|
||||||
|
|
||||||
*len = blob.length;
|
*len = blob.length;
|
||||||
return blob.data;
|
return blob.data;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <hb-wasm-api.h>
|
#include <hb-wasm-api.h>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
void abort ();
|
||||||
void debugprint (const char *s);
|
void debugprint (const char *s);
|
||||||
void debugprint1 (const char *s, int32_t);
|
void debugprint1 (const char *s, int32_t);
|
||||||
void debugprint2 (const char *s, int32_t, int32_t);
|
void debugprint2 (const char *s, int32_t, int32_t);
|
||||||
|
@ -17,7 +18,9 @@ shape (void *shape_plan,
|
||||||
{
|
{
|
||||||
face_t *face = font_get_face (font);
|
face_t *face = font_get_face (font);
|
||||||
|
|
||||||
blob_t blob = face_copy_table (face, TAG ('c','m','a','p'));
|
blob_t blob;
|
||||||
|
if (!face_copy_table (face, TAG ('c','m','a','p'), &blob))
|
||||||
|
abort ();
|
||||||
|
|
||||||
debugprint1 ("cmap length", blob.length);
|
debugprint1 ("cmap length", blob.length);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue