diff --git a/src/hb-wasm-api-buffer.hh b/src/hb-wasm-api-buffer.hh index a5560bc25..39c65c5cf 100644 --- a/src/hb-wasm-api-buffer.hh +++ b/src/hb-wasm-api-buffer.hh @@ -87,7 +87,7 @@ void buffer_copy_contents (HB_WASM_EXEC_ENV_COMPOUND ptr_t(buffer_t) bufferref) { - HB_RETURN_TYPE (buffer_contents_t, ret); + HB_RETURN_STRUCT (buffer_contents_t, ret); HB_REF2OBJ (buffer); if (buffer->have_output) diff --git a/src/hb-wasm-api-face.hh b/src/hb-wasm-api-face.hh index cdbc08d6d..918a08682 100644 --- a/src/hb-wasm-api-face.hh +++ b/src/hb-wasm-api-face.hh @@ -36,7 +36,7 @@ face_reference_table (HB_WASM_EXEC_ENV_COMPOUND ptr_t(face_t) faceref, tag_t table_tag) { - HB_RETURN_TYPE (blob_t, ret); + HB_RETURN_STRUCT (blob_t, ret); HB_REF2OBJ (face); hb_blob_t *blob = hb_face_reference_table (face, table_tag); diff --git a/src/hb-wasm-api-font.hh b/src/hb-wasm-api-font.hh index 2b1921cc8..ba80d6609 100644 --- a/src/hb-wasm-api-font.hh +++ b/src/hb-wasm-api-font.hh @@ -43,6 +43,20 @@ font_get_face (HB_WASM_EXEC_ENV return faceref; } +void +font_get_scale (HB_WASM_EXEC_ENV + ptr_t(font_t) fontref, + ptr_t(int32_t) x_scaleptr, + ptr_t(int32_t) y_scaleptr) +{ + HB_REF2OBJ (font); + + HB_STRUCT_TYPE(int32_t, x_scale); + HB_STRUCT_TYPE(int32_t, y_scale); + + hb_font_get_scale (font, x_scale, y_scale); +} + hb_codepoint_t font_get_glyph (HB_WASM_EXEC_ENV ptr_t(font_t) fontref, @@ -56,7 +70,6 @@ font_get_glyph (HB_WASM_EXEC_ENV return glyph; } - hb_position_t font_get_glyph_h_advance (HB_WASM_EXEC_ENV ptr_t(font_t) fontref, diff --git a/src/hb-wasm-api-list.hh b/src/hb-wasm-api-list.hh index 7a833d900..5f834dddb 100644 --- a/src/hb-wasm-api-list.hh +++ b/src/hb-wasm-api-list.hh @@ -66,6 +66,7 @@ static NativeSymbol _hb_wasm_native_symbols[] = /* font */ NATIVE_SYMBOL ("(i)i", font_get_face), + NATIVE_SYMBOL ("(iii)", font_get_scale), 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), diff --git a/src/hb-wasm-api.h b/src/hb-wasm-api.h index f7162fbe7..10bd92a74 100644 --- a/src/hb-wasm-api.h +++ b/src/hb-wasm-api.h @@ -151,6 +151,11 @@ 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 (void, font_get_scale) (HB_WASM_EXEC_ENV + ptr_t(font_t), + ptr_t(int32_t) x_scale, + ptr_t(int32_t) y_scale); + HB_WASM_API (hb_codepoint_t, font_get_glyph) (HB_WASM_EXEC_ENV ptr_t(font_t), hb_codepoint_t unicode, diff --git a/src/hb-wasm-api.hh b/src/hb-wasm-api.hh index 4fc95fd94..646f50aad 100644 --- a/src/hb-wasm-api.hh +++ b/src/hb-wasm-api.hh @@ -78,7 +78,7 @@ HB_INTERNAL extern hb_user_data_key_t _hb_wasm_ref_type_key; (void) wasm_externref_obj2ref (module_inst, obj, &obj##ref); \ } HB_STMT_END -#define HB_RETURN_TYPE(type, name) \ +#define HB_RETURN_STRUCT(type, name) \ type *_name_ptr = nullptr; \ { \ if (likely (wasm_runtime_validate_app_addr (module_inst, \ diff --git a/src/wasm-graphite/shape.cc b/src/wasm-graphite/shape.cc index a4a5e8302..08e564d18 100644 --- a/src/wasm-graphite/shape.cc +++ b/src/wasm-graphite/shape.cc @@ -86,8 +86,10 @@ shape (font_t *font, buffer_t *buffer) hb_codepoint_t *pg = gids; clusters[0].cluster = contents.info[0].cluster; unsigned int upem = face_get_upem (face); - float xscale = 10;//(float) font->x_scale / upem; - float yscale = 10;//(float) font->y_scale / upem; + int32_t font_x_scale, font_y_scale; + font_get_scale (font, &font_x_scale, &font_y_scale); + float xscale = (float) font_x_scale / upem; + float yscale = (float) font_y_scale / upem; yscale *= yscale / xscale; unsigned int curradv = 0; if (0)//HB_DIRECTION_IS_BACKWARD(buffer->props.direction))