[wasm-api] Bind font_get_scale
This commit is contained in:
parent
149199ee26
commit
23b58b5667
|
@ -87,7 +87,7 @@ void
|
||||||
buffer_copy_contents (HB_WASM_EXEC_ENV_COMPOUND
|
buffer_copy_contents (HB_WASM_EXEC_ENV_COMPOUND
|
||||||
ptr_t(buffer_t) bufferref)
|
ptr_t(buffer_t) bufferref)
|
||||||
{
|
{
|
||||||
HB_RETURN_TYPE (buffer_contents_t, ret);
|
HB_RETURN_STRUCT (buffer_contents_t, ret);
|
||||||
HB_REF2OBJ (buffer);
|
HB_REF2OBJ (buffer);
|
||||||
|
|
||||||
if (buffer->have_output)
|
if (buffer->have_output)
|
||||||
|
|
|
@ -36,7 +36,7 @@ face_reference_table (HB_WASM_EXEC_ENV_COMPOUND
|
||||||
ptr_t(face_t) faceref,
|
ptr_t(face_t) faceref,
|
||||||
tag_t table_tag)
|
tag_t table_tag)
|
||||||
{
|
{
|
||||||
HB_RETURN_TYPE (blob_t, ret);
|
HB_RETURN_STRUCT (blob_t, ret);
|
||||||
HB_REF2OBJ (face);
|
HB_REF2OBJ (face);
|
||||||
|
|
||||||
hb_blob_t *blob = hb_face_reference_table (face, table_tag);
|
hb_blob_t *blob = hb_face_reference_table (face, table_tag);
|
||||||
|
|
|
@ -43,6 +43,20 @@ font_get_face (HB_WASM_EXEC_ENV
|
||||||
return faceref;
|
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
|
hb_codepoint_t
|
||||||
font_get_glyph (HB_WASM_EXEC_ENV
|
font_get_glyph (HB_WASM_EXEC_ENV
|
||||||
ptr_t(font_t) fontref,
|
ptr_t(font_t) fontref,
|
||||||
|
@ -56,7 +70,6 @@ font_get_glyph (HB_WASM_EXEC_ENV
|
||||||
return glyph;
|
return glyph;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
hb_position_t
|
hb_position_t
|
||||||
font_get_glyph_h_advance (HB_WASM_EXEC_ENV
|
font_get_glyph_h_advance (HB_WASM_EXEC_ENV
|
||||||
ptr_t(font_t) fontref,
|
ptr_t(font_t) fontref,
|
||||||
|
|
|
@ -66,6 +66,7 @@ static NativeSymbol _hb_wasm_native_symbols[] =
|
||||||
|
|
||||||
/* font */
|
/* font */
|
||||||
NATIVE_SYMBOL ("(i)i", font_get_face),
|
NATIVE_SYMBOL ("(i)i", font_get_face),
|
||||||
|
NATIVE_SYMBOL ("(iii)", font_get_scale),
|
||||||
NATIVE_SYMBOL ("(iii)i", font_get_glyph),
|
NATIVE_SYMBOL ("(iii)i", font_get_glyph),
|
||||||
NATIVE_SYMBOL ("(ii)i", font_get_glyph_h_advance),
|
NATIVE_SYMBOL ("(ii)i", font_get_glyph_h_advance),
|
||||||
NATIVE_SYMBOL ("(ii)i", font_get_glyph_v_advance),
|
NATIVE_SYMBOL ("(ii)i", font_get_glyph_v_advance),
|
||||||
|
|
|
@ -151,6 +151,11 @@ typedef struct font_t font_t;
|
||||||
HB_WASM_API (ptr_t(face_t), font_get_face) (HB_WASM_EXEC_ENV
|
HB_WASM_API (ptr_t(face_t), font_get_face) (HB_WASM_EXEC_ENV
|
||||||
ptr_t(font_t));
|
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
|
HB_WASM_API (hb_codepoint_t, font_get_glyph) (HB_WASM_EXEC_ENV
|
||||||
ptr_t(font_t),
|
ptr_t(font_t),
|
||||||
hb_codepoint_t unicode,
|
hb_codepoint_t unicode,
|
||||||
|
|
|
@ -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); \
|
(void) wasm_externref_obj2ref (module_inst, obj, &obj##ref); \
|
||||||
} HB_STMT_END
|
} HB_STMT_END
|
||||||
|
|
||||||
#define HB_RETURN_TYPE(type, name) \
|
#define HB_RETURN_STRUCT(type, name) \
|
||||||
type *_name_ptr = nullptr; \
|
type *_name_ptr = nullptr; \
|
||||||
{ \
|
{ \
|
||||||
if (likely (wasm_runtime_validate_app_addr (module_inst, \
|
if (likely (wasm_runtime_validate_app_addr (module_inst, \
|
||||||
|
|
|
@ -86,8 +86,10 @@ shape (font_t *font, buffer_t *buffer)
|
||||||
hb_codepoint_t *pg = gids;
|
hb_codepoint_t *pg = gids;
|
||||||
clusters[0].cluster = contents.info[0].cluster;
|
clusters[0].cluster = contents.info[0].cluster;
|
||||||
unsigned int upem = face_get_upem (face);
|
unsigned int upem = face_get_upem (face);
|
||||||
float xscale = 10;//(float) font->x_scale / upem;
|
int32_t font_x_scale, font_y_scale;
|
||||||
float yscale = 10;//(float) font->y_scale / upem;
|
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;
|
yscale *= yscale / xscale;
|
||||||
unsigned int curradv = 0;
|
unsigned int curradv = 0;
|
||||||
if (0)//HB_DIRECTION_IS_BACKWARD(buffer->props.direction))
|
if (0)//HB_DIRECTION_IS_BACKWARD(buffer->props.direction))
|
||||||
|
|
Loading…
Reference in New Issue