diff --git a/src/hb-wasm-api.hh b/src/hb-wasm-api.hh index e0360d100..2bc93cb0e 100644 --- a/src/hb-wasm-api.hh +++ b/src/hb-wasm-api.hh @@ -25,7 +25,7 @@ #ifndef HB_WASM_API_HH #define HB_WASM_API_HH -#include "hb.h" +#include "hb.hh" #include @@ -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); } diff --git a/src/hb-wasm-font.hh b/src/hb-wasm-font.hh index 7fde34791..9a2272ebc 100644 --- a/src/hb-wasm-font.hh +++ b/src/hb-wasm-font.hh @@ -33,9 +33,17 @@ namespace wasm { face_t font_get_face (HB_WASM_EXEC_ENV - font_t) + font_t fontref) { - return 0; + 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; }