From e0fec1dda01f1060dd474537dcbe5084ef46a88f Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Thu, 23 Feb 2023 22:18:22 +0000 Subject: [PATCH] [wasm-api] Wrap some of hb-font --- src/hb-wasm-api-font.hh | 31 +++++++++++++++++++++++++++++++ src/hb-wasm-api-list.hh | 5 ++++- src/hb-wasm-api.h | 11 +++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/hb-wasm-api-font.hh b/src/hb-wasm-api-font.hh index e495e8acd..2b1921cc8 100644 --- a/src/hb-wasm-api-font.hh +++ b/src/hb-wasm-api-font.hh @@ -43,6 +43,37 @@ font_get_face (HB_WASM_EXEC_ENV return faceref; } +hb_codepoint_t +font_get_glyph (HB_WASM_EXEC_ENV + ptr_t(font_t) fontref, + hb_codepoint_t unicode, + hb_codepoint_t variation_selector) +{ + HB_REF2OBJ (font); + hb_codepoint_t glyph; + + hb_font_get_glyph (font, unicode, variation_selector, &glyph); + return glyph; +} + + +hb_position_t +font_get_glyph_h_advance (HB_WASM_EXEC_ENV + ptr_t(font_t) fontref, + hb_codepoint_t glyph) +{ + HB_REF2OBJ (font); + return hb_font_get_glyph_h_advance (font, glyph); +} + +hb_position_t +font_get_glyph_v_advance (HB_WASM_EXEC_ENV + ptr_t(font_t) fontref, + hb_codepoint_t glyph) +{ + HB_REF2OBJ (font); + return hb_font_get_glyph_v_advance (font, glyph); +} }} diff --git a/src/hb-wasm-api-list.hh b/src/hb-wasm-api-list.hh index 14a1f60ab..df39ad17b 100644 --- a/src/hb-wasm-api-list.hh +++ b/src/hb-wasm-api-list.hh @@ -62,7 +62,10 @@ static NativeSymbol _hb_wasm_native_symbols[] = NATIVE_SYMBOL ("(iii)", face_reference_table), /* font */ - NATIVE_SYMBOL ("(i)i", font_get_face), + NATIVE_SYMBOL ("(i)i", font_get_face), + NATIVE_SYMBOL ("(iii)i", font_get_glyph), + NATIVE_SYMBOL ("(ii)i", font_get_glyph_h_advance), + NATIVE_SYMBOL ("(ii)i", font_get_glyph_v_advance), /* debug */ #ifdef HB_DEBUG_WASM diff --git a/src/hb-wasm-api.h b/src/hb-wasm-api.h index 1adb4e2c6..66d5b64c0 100644 --- a/src/hb-wasm-api.h +++ b/src/hb-wasm-api.h @@ -140,7 +140,18 @@ typedef struct font_t font_t; HB_WASM_API (ptr_t(face_t), font_get_face) (HB_WASM_EXEC_ENV ptr_t(font_t)); +HB_WASM_API (hb_codepoint_t, font_get_glyph) (HB_WASM_EXEC_ENV + ptr_t(font_t), + hb_codepoint_t unicode, + hb_codepoint_t variation_selector); +HB_WASM_API (hb_position_t, font_get_glyph_h_advance) (HB_WASM_EXEC_ENV + ptr_t(font_t), + hb_codepoint_t glyph); + +HB_WASM_API (hb_position_t, font_get_glyph_v_advance) (HB_WASM_EXEC_ENV + ptr_t(font_t), + hb_codepoint_t glyph); /* shape interface */ HB_WASM_INTERFACE (bool_t, shape) (HB_WASM_EXEC_ENV