1 /* -*- c-basic-offset:2; tab-width:2; indent-tabs-mode:nil -*- */ 2 3 #ifndef __VT_OT_LAYOUT_H__ 4 #define __VT_OT_LAYOUT_H__ 5 6 #include <pobl/bl_types.h> /* u_int/u_char */ 7 8 #include "vt_font.h" 9 #include "vt_char.h" 10 11 /* 12 * XOFF 0 1 0 -5 13 * ADV 0 6 6 0 14 * ^ ^ -> Combined chars 15 * 16 * (XXX) offsets[idx] is ignored if it is greater than 0. 17 */ 18 #define OTL_IS_COMB(idx) \ 19 (xoffsets[(idx)] < 0 || (advances[(idx) - 1] == 0 && xoffsets[(idx) - 1] >= 0)) 20 21 typedef enum vt_ot_layout_attr { 22 OT_SCRIPT = 0, 23 OT_FEATURES = 1, 24 MAX_OT_ATTRS = 2, 25 26 } vt_ot_layout_attr_t; 27 28 typedef struct vt_ot_layout_state { 29 void *term; 30 u_int8_t *num_chars_array; 31 u_int16_t size; 32 33 u_int32_t *glyphs; 34 int8_t *xoffsets; 35 int8_t *yoffsets; 36 u_int8_t *advances; 37 u_int16_t num_glyphs; /* size + NULL separators */ 38 39 int substituted : 2; 40 int complex_shape : 2; 41 int has_var_width_char : 2; 42 43 } * vt_ot_layout_state_t; 44 45 void vt_set_ot_layout_attr(char *value, vt_ot_layout_attr_t attr); 46 47 char *vt_get_ot_layout_attr(vt_ot_layout_attr_t attr); 48 49 void vt_ot_layout_set_shape_func(u_int (*func1)(void *, u_int32_t *, u_int, int8_t *, int8_t *, 50 u_int8_t *, u_int32_t *, u_int32_t *, u_int, 51 const char *, const char *), 52 void *(*func2)(void *, vt_font_t)); 53 54 u_int vt_ot_layout_shape(void *font, u_int32_t *shape_glyphs, u_int32_t num_shape_glyphs, 55 int8_t *xoffsets, int8_t *yoffsets, u_int8_t *advances, u_int32_t *cmapped, 56 u_int32_t *src, u_int32_t src_len); 57 58 void *vt_ot_layout_get_font(void *term, vt_font_t font); 59 60 vt_ot_layout_state_t vt_ot_layout_new(void); 61 62 void vt_ot_layout_destroy(vt_ot_layout_state_t state); 63 64 int vt_ot_layout(vt_ot_layout_state_t state, vt_char_t *src, u_int src_len); 65 66 void vt_ot_layout_reset(vt_ot_layout_state_t state); 67 68 int vt_ot_layout_copy(vt_ot_layout_state_t dst, vt_ot_layout_state_t src, int optimize); 69 70 #endif 71