[wasm-api] Wrap some of hb-font

This commit is contained in:
Simon Cozens 2023-02-23 22:18:22 +00:00 committed by Behdad Esfahbod
parent af1f41a43e
commit e0fec1dda0
3 changed files with 46 additions and 1 deletions

View File

@ -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);
}
}}

View File

@ -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

View File

@ -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