diff --git a/src/hb-wasm-api-font.hh b/src/hb-wasm-api-font.hh index 2956109c9..319814cea 100644 --- a/src/hb-wasm-api-font.hh +++ b/src/hb-wasm-api-font.hh @@ -88,6 +88,18 @@ font_get_glyph_v_advance (HB_WASM_EXEC_ENV return hb_font_get_glyph_v_advance (font, glyph); } +void +font_glyph_to_string (HB_WASM_EXEC_ENV + ptr_t(font_t) fontref, + codepoint_t glyph, + char *s, uint32_t size) +{ + HB_REF2OBJ (font); + + hb_font_glyph_to_string (font, glyph, s, size); +} + + }} #endif /* HB_WASM_API_FONT_HH */ diff --git a/src/hb-wasm-api-list.hh b/src/hb-wasm-api-list.hh index 5cd0ea6ea..25f02f908 100644 --- a/src/hb-wasm-api-list.hh +++ b/src/hb-wasm-api-list.hh @@ -72,6 +72,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 ("(ii$*)", font_glyph_to_string), /* shape */ NATIVE_SYMBOL ("(ii$)i", shape_with), diff --git a/src/hb-wasm-api.h b/src/hb-wasm-api.h index 45d881cd0..758f5aa86 100644 --- a/src/hb-wasm-api.h +++ b/src/hb-wasm-api.h @@ -188,6 +188,11 @@ HB_WASM_API (position_t, font_get_glyph_v_advance) (HB_WASM_EXEC_ENV ptr_t(font_t), codepoint_t glyph); +HB_WASM_API (void, font_glyph_to_string) (HB_WASM_EXEC_ENV + ptr_t(font_t), + codepoint_t glyph, + char *s, uint32_t size); + /* shape */ diff --git a/src/wasm-graphite/shape.cc b/src/wasm-graphite/shape.cc index b4da4c463..fcf87c00e 100644 --- a/src/wasm-graphite/shape.cc +++ b/src/wasm-graphite/shape.cc @@ -15,6 +15,9 @@ void *memset(void *s, int c, size_t n); void debugprint1 (char *s, int32_t); void debugprint2 (char *s, int32_t, int32_t); +__attribute__((visibility("default"))) +uint32_t heap_size = 2 * 1024 * 1024; + static const void *copy_table (const void *data, unsigned int tag, size_t *len) { face_t *face = (face_t *) data; diff --git a/src/wasm-sample/shape-fallback.cc b/src/wasm-sample/shape-fallback.cc index 344ab0e8d..11853c402 100644 --- a/src/wasm-sample/shape-fallback.cc +++ b/src/wasm-sample/shape-fallback.cc @@ -3,6 +3,7 @@ #include extern "C" { +void debugprint (const char *s); void debugprint1 (const char *s, int32_t); void debugprint2 (const char *s, int32_t, int32_t); } @@ -24,7 +25,12 @@ shape (font_t *font, buffer_t *buffer) for (unsigned i = 0; i < contents.length; i++) { - debugprint2 ("Codepoint", i, contents.info[i].codepoint); + char name[64]; + + font_glyph_to_string (font, contents.info[i].codepoint, name, sizeof (name)); + + debugprint (name); + contents.info[i].codepoint = font_get_glyph (font, contents.info[i].codepoint, 0); contents.pos[i].x_advance = font_get_glyph_h_advance (font, contents.info[i].codepoint); }