[wasm-api] Bind font_get_glyph_extents

Untested.
This commit is contained in:
Behdad Esfahbod 2023-02-24 12:20:31 -07:00
parent b3b6e8da86
commit fe557e2f21
3 changed files with 30 additions and 0 deletions

View File

@ -88,6 +88,23 @@ font_get_glyph_v_advance (HB_WASM_EXEC_ENV
return hb_font_get_glyph_v_advance (font, glyph);
}
static_assert (sizeof (glyph_extents_t) == sizeof (hb_glyph_extents_t), "");
bool_t
font_get_glyph_extents (HB_WASM_EXEC_ENV
ptr_t(font_t) fontref,
codepoint_t glyph,
ptr_t(glyph_extents_t) extentsptr)
{
HB_REF2OBJ (font);
HB_OUT_PARAM (glyph_extents_t, extents);
if (unlikely (!extents))
return false;
return hb_font_get_glyph_extents (font, glyph,
(hb_glyph_extents_t *) extents);
}
void
font_glyph_to_string (HB_WASM_EXEC_ENV
ptr_t(font_t) fontref,

View File

@ -73,6 +73,7 @@ static NativeSymbol _hb_wasm_native_symbols[] =
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),
NATIVE_SYMBOL ("(iii)i", font_get_glyph_extents),
NATIVE_SYMBOL ("(ii$*)", font_glyph_to_string),
/* shape */

View File

@ -191,6 +191,18 @@ HB_WASM_API (position_t, font_get_glyph_v_advance) (HB_WASM_EXEC_ENV
ptr_t(font_t),
codepoint_t glyph);
typedef struct {
position_t x_bearing;
position_t y_bearing;
position_t width;
position_t height;
} glyph_extents_t;
HB_WASM_API (bool_t, font_get_glyph_extents) (HB_WASM_EXEC_ENV
ptr_t(font_t),
codepoint_t glyph,
ptr_t(glyph_extents_t) extents);
HB_WASM_API (void, font_glyph_to_string) (HB_WASM_EXEC_ENV
ptr_t(font_t),
codepoint_t glyph,