[wasm-api] Bind buffer_get_direction
This commit is contained in:
parent
a5c844a1de
commit
0a51ed31b0
|
@ -128,6 +128,16 @@ buffer_set_contents (HB_WASM_EXEC_ENV
|
|||
return true;
|
||||
}
|
||||
|
||||
direction_t
|
||||
buffer_get_direction (HB_WASM_EXEC_ENV
|
||||
ptr_t(buffer_t) bufferref)
|
||||
{
|
||||
HB_REF2OBJ (buffer);
|
||||
|
||||
return (direction_t) hb_buffer_get_direction (buffer);
|
||||
}
|
||||
|
||||
|
||||
}}
|
||||
|
||||
#endif /* HB_WASM_API_BUFFER_HH */
|
||||
|
|
|
@ -59,6 +59,7 @@ static NativeSymbol _hb_wasm_native_symbols[] =
|
|||
NATIVE_SYMBOL ("(ii)", buffer_contents_realloc),
|
||||
NATIVE_SYMBOL ("(ii)", buffer_copy_contents),
|
||||
NATIVE_SYMBOL ("(ii)i", buffer_set_contents),
|
||||
NATIVE_SYMBOL ("(i)i", buffer_get_direction),
|
||||
|
||||
/* face */
|
||||
NATIVE_SYMBOL ("(iii)", face_reference_table),
|
||||
|
|
|
@ -75,6 +75,20 @@ typedef uint32_t hb_mask_t;
|
|||
typedef uint32_t tag_t;
|
||||
#define TAG(c1,c2,c3,c4) ((tag_t)((((uint32_t)(c1)&0xFF)<<24)|(((uint32_t)(c2)&0xFF)<<16)|(((uint32_t)(c3)&0xFF)<<8)|((uint32_t)(c4)&0xFF)))
|
||||
|
||||
typedef enum {
|
||||
DIRECTION_INVALID = 0,
|
||||
DIRECTION_LTR = 4,
|
||||
DIRECTION_RTL,
|
||||
DIRECTION_TTB,
|
||||
DIRECTION_BTT
|
||||
} direction_t;
|
||||
#define DIRECTION_IS_VALID(dir) ((((unsigned int) (dir)) & ~3U) == 4)
|
||||
#define DIRECTION_IS_HORIZONTAL(dir) ((((unsigned int) (dir)) & ~1U) == 4)
|
||||
#define DIRECTION_IS_VERTICAL(dir) ((((unsigned int) (dir)) & ~1U) == 6)
|
||||
#define DIRECTION_IS_FORWARD(dir) ((((unsigned int) (dir)) & ~2U) == 4)
|
||||
#define DIRECTION_IS_BACKWARD(dir) ((((unsigned int) (dir)) & ~2U) == 5)
|
||||
#define DIRECTION_REVERSE(dir) ((direction_t) (((unsigned int) (dir)) ^ 1))
|
||||
|
||||
|
||||
/* blob */
|
||||
|
||||
|
@ -131,6 +145,9 @@ HB_WASM_API (bool_t, buffer_set_contents) (HB_WASM_EXEC_ENV
|
|||
ptr_t(buffer_t),
|
||||
ptr_t(const buffer_contents_t));
|
||||
|
||||
HB_WASM_API (direction_t, buffer_get_direction) (HB_WASM_EXEC_ENV
|
||||
ptr_t(buffer_t));
|
||||
|
||||
|
||||
/* face */
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ shape (font_t *font, buffer_t *buffer)
|
|||
blob_free (&blob);
|
||||
|
||||
buffer_contents_t contents = buffer_copy_contents (buffer);
|
||||
direction_t direction = buffer_get_direction (buffer);
|
||||
|
||||
const gr_face_ops ops = {sizeof (gr_face_ops), ©_table, nullptr};//&free_table};
|
||||
gr_face *grface = gr_make_face_with_ops (face, &ops, gr_face_preloadAll);
|
||||
|
@ -59,7 +60,7 @@ shape (font_t *font, buffer_t *buffer)
|
|||
0, // https://github.com/harfbuzz/harfbuzz/issues/3439#issuecomment-1442650148
|
||||
nullptr,
|
||||
gr_utf32, chars, contents.length,
|
||||
2/* | (buffer_get_direction (buffer) == DIRECTION_RTL ? 1 : 0)*/);
|
||||
2 | (direction == DIRECTION_RTL ? 1 : 0));
|
||||
|
||||
free (chars);
|
||||
|
||||
|
@ -92,7 +93,7 @@ shape (font_t *font, buffer_t *buffer)
|
|||
float yscale = (float) font_y_scale / upem;
|
||||
yscale *= yscale / xscale;
|
||||
unsigned int curradv = 0;
|
||||
if (0)//HB_DIRECTION_IS_BACKWARD(buffer->props.direction))
|
||||
if (DIRECTION_IS_BACKWARD (direction))
|
||||
{
|
||||
curradv = gr_slot_origin_X(gr_seg_first_slot(seg)) * xscale;
|
||||
clusters[0].advance = gr_seg_advance_X(seg) * xscale - curradv;
|
||||
|
@ -121,7 +122,7 @@ shape (font_t *font, buffer_t *buffer)
|
|||
c->num_chars = before - c->base_char;
|
||||
c->base_glyph = ic;
|
||||
c->num_glyphs = 0;
|
||||
if (0)//HB_DIRECTION_IS_BACKWARD(buffer->props.direction))
|
||||
if (DIRECTION_IS_BACKWARD (direction))
|
||||
{
|
||||
c->advance = curradv - gr_slot_origin_X(is) * xscale;
|
||||
curradv -= c->advance;
|
||||
|
@ -140,7 +141,7 @@ shape (font_t *font, buffer_t *buffer)
|
|||
clusters[ci].num_chars = after + 1 - clusters[ci].base_char;
|
||||
}
|
||||
|
||||
if (0)//HB_DIRECTION_IS_BACKWARD(buffer->props.direction))
|
||||
if (DIRECTION_IS_BACKWARD (direction))
|
||||
clusters[ci].advance += curradv;
|
||||
else
|
||||
clusters[ci].advance += gr_seg_advance_X(seg) * xscale - curradv;
|
||||
|
@ -162,7 +163,7 @@ shape (font_t *font, buffer_t *buffer)
|
|||
unsigned int currclus = 0xFFFFFFFF;
|
||||
const glyph_info_t *info = contents.info;
|
||||
glyph_position_t *pPos = contents.pos;
|
||||
if (1)//!HB_DIRECTION_IS_BACKWARD(buffer->props.direction))
|
||||
if (!DIRECTION_IS_BACKWARD (direction))
|
||||
{
|
||||
curradvx = 0;
|
||||
for (is = gr_seg_first_slot (seg); is; pPos++, ++info, is = gr_slot_next_in_segment (is))
|
||||
|
|
Loading…
Reference in New Issue