[wasm-api] Bind face_get_upem

This commit is contained in:
Behdad Esfahbod 2023-02-24 09:39:25 -07:00
parent 2d295183b8
commit 149199ee26
4 changed files with 17 additions and 2 deletions

View File

@ -50,6 +50,15 @@ face_reference_table (HB_WASM_EXEC_ENV_COMPOUND
hb_blob_destroy (blob); hb_blob_destroy (blob);
} }
unsigned
face_get_upem (HB_WASM_EXEC_ENV
ptr_t(face_t) faceref)
{
HB_REF2OBJ (face);
return hb_face_get_upem (face);
}
}} }}

View File

@ -62,6 +62,7 @@ static NativeSymbol _hb_wasm_native_symbols[] =
/* face */ /* face */
NATIVE_SYMBOL ("(iii)", face_reference_table), NATIVE_SYMBOL ("(iii)", face_reference_table),
NATIVE_SYMBOL ("(i)i", face_get_upem),
/* font */ /* font */
NATIVE_SYMBOL ("(i)i", font_get_face), NATIVE_SYMBOL ("(i)i", font_get_face),

View File

@ -140,6 +140,9 @@ HB_WASM_API_COMPOUND (blob_t, face_reference_table) (HB_WASM_EXEC_ENV_COMPOUND
ptr_t(face_t), ptr_t(face_t),
tag_t table_tag); tag_t table_tag);
HB_WASM_API (unsigned, face_get_upem) (HB_WASM_EXEC_ENV
ptr_t(face_t));
/* font */ /* font */
@ -160,6 +163,8 @@ HB_WASM_API (hb_position_t, font_get_glyph_h_advance) (HB_WASM_EXEC_ENV
HB_WASM_API (hb_position_t, font_get_glyph_v_advance) (HB_WASM_EXEC_ENV HB_WASM_API (hb_position_t, font_get_glyph_v_advance) (HB_WASM_EXEC_ENV
ptr_t(font_t), ptr_t(font_t),
hb_codepoint_t glyph); hb_codepoint_t glyph);
/* shape interface */ /* shape interface */
HB_WASM_INTERFACE (bool_t, shape) (HB_WASM_EXEC_ENV HB_WASM_INTERFACE (bool_t, shape) (HB_WASM_EXEC_ENV

View File

@ -85,7 +85,7 @@ shape (font_t *font, buffer_t *buffer)
memset (clusters, 0, sizeof (clusters[0]) * length); memset (clusters, 0, sizeof (clusters[0]) * length);
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 = 2048;//hb_face_get_upem (face); unsigned int upem = face_get_upem (face);
float xscale = 10;//(float) font->x_scale / upem; float xscale = 10;//(float) font->x_scale / upem;
float yscale = 10;//(float) font->y_scale / upem; float yscale = 10;//(float) font->y_scale / upem;
yscale *= yscale / xscale; yscale *= yscale / xscale;
@ -196,7 +196,7 @@ shape (font_t *font, buffer_t *buffer)
pPos->x_offset = gr_slot_origin_X (is) * xscale - info->var1 - curradvx + pPos->x_advance; pPos->x_offset = gr_slot_origin_X (is) * xscale - info->var1 - curradvx + pPos->x_advance;
pPos->y_offset = gr_slot_origin_Y (is) * yscale - curradvy; pPos->y_offset = gr_slot_origin_Y (is) * yscale - curradvy;
} }
//hb_buffer_reverse_clusters (buffer); //buffer_reverse_clusters (buffer);
} }
gr_seg_destroy (seg); gr_seg_destroy (seg);