[wasm-api] Implement font_get_face

This commit is contained in:
Behdad Esfahbod 2023-02-23 09:25:05 -07:00
parent 9f4dc2e103
commit fd1f7f46f4
2 changed files with 16 additions and 3 deletions

View File

@ -25,7 +25,7 @@
#ifndef HB_WASM_API_HH
#define HB_WASM_API_HH
#include "hb.h"
#include "hb.hh"
#include <wasm_export.h>
@ -41,9 +41,14 @@
#undef HB_WASM_BEGIN_DECLS
#undef HB_WASM_END_DECLS
#define module_inst wasm_runtime_get_module_inst (exec_env)
#include "hb-wasm-font.hh"
#undef module_inst
static void debugprint(wasm_exec_env_t exec_env, char *the_string, uint8_t len) {
printf("%*s", len, the_string);
}

View File

@ -33,9 +33,17 @@ namespace wasm {
face_t
font_get_face (HB_WASM_EXEC_ENV
font_t)
font_t fontref)
{
hb_font_t *font;
if (unlikely (!wasm_externref_ref2obj (fontref, (void **) &font)))
return 0;
hb_face_t *face = hb_font_get_face (font);
uint32_t faceref = 0;
(void) wasm_externref_obj2ref (module_inst, face, &faceref);
return faceref;
}