From fd1f7f46f46cd9dba29ad4975f09f6d4073edae4 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 23 Feb 2023 09:25:05 -0700 Subject: [PATCH] [wasm-api] Implement font_get_face --- src/hb-wasm-api.hh | 7 ++++++- src/hb-wasm-font.hh | 12 ++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) 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; }