summaryrefslogtreecommitdiff
path: root/src/lib/evas/common/evas_font_default_walk.x
blob: 40d11bcf009d7647bb0c0f7a3b4a4cd23d0ba903 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#ifndef _EVAS_FONT_DEFAULT_WALK_X
#define _EVAS_FONT_DEFAULT_WALK_X
/* Macros for text walking */

/**
 * @def EVAS_FONT_WALK_TEXT_INIT
 * @internal
 * This macro defines the variables that will later be used with the following
 * macros, and by font handling functions.
 * @see EVAS_FONT_WALK_TEXT_START
 * @see EVAS_FONT_WALK_TEXT_WORK
 * @see EVAS_FONT_WALK_TEXT_END
 */
# define EVAS_FONT_WALK_TEXT_INIT() \
        int _pen_x = 0, _pen_y = 0; \
        Evas_Coord _start_pen = (text_props->info && \
              (text_props->start > 0)) ? \
           text_props->info->glyph[text_props->start - 1].pen_after : 0 ; \
        size_t char_index; \
        (void) _pen_x; /* Sometimes it won't be used */ \
        (void) _pen_y; /* Sometimes it won't be used */

/* Visual walk helper macros */
#ifdef OT_SUPPORT
#define _EVAS_FONT_WALK_TEXT_START() \
        Evas_Font_OT_Info *_ot_itr = (text_props->info) ? \
           text_props->info->ot + text_props->start : NULL; \
        if (!_ot_itr) break; \
        for (char_index = 0 ; char_index < text_props->len ; char_index++, _glyph_itr++, _ot_itr++) \
          {
#else
#define _EVAS_FONT_WALK_TEXT_START() \
        for (char_index = 0 ; char_index < text_props->len ; char_index++, _glyph_itr++) \
          {
#endif

/**
 * @def EVAS_FONT_WALK_TEXT_START
 * @internal
 * This runs through the text in visual order while updating char_index,
 * which is the current index in the text.
 * Does not end with a ;
 * Take a look at EVAS_FONT_WALK_X_OFF and the like.
 * @see EVAS_FONT_WALK_TEXT_INIT
 * @see EVAS_FONT_WALK_TEXT_WORK
 * @see EVAS_FONT_WALK_TEXT_END
 */
#define EVAS_FONT_WALK_TEXT_START() \
   do \
     { \
        Evas_Font_Glyph_Info *_glyph_itr = (text_props->info) ? \
           text_props->info->glyph + text_props->start : NULL; \
        if (!_glyph_itr) break; \
        _EVAS_FONT_WALK_TEXT_START()

/*FIXME: doc */
#ifdef OT_SUPPORT
# define EVAS_FONT_WALK_X_OFF \
             (EVAS_FONT_ROUND_26_6_TO_INT(EVAS_FONT_OT_X_OFF_GET(*_ot_itr)))
# define EVAS_FONT_WALK_Y_OFF \
             (EVAS_FONT_ROUND_26_6_TO_INT(EVAS_FONT_OT_Y_OFF_GET(*_ot_itr)))
# define EVAS_FONT_WALK_POS \
             (EVAS_FONT_OT_POS_GET(*_ot_itr) - text_props->text_offset)
# define EVAS_FONT_WALK_POS_NEXT \
              ((!EVAS_FONT_WALK_IS_LAST) ? \
               EVAS_FONT_OT_POS_GET(*(_ot_itr + 1)) - \
                text_props->text_offset : \
               EVAS_FONT_WALK_POS \
              )
# define EVAS_FONT_WALK_POS_PREV \
             ((char_index > 0) ? \
             EVAS_FONT_OT_POS_GET(*(_ot_itr - 1)) - \
              text_props->text_offset : \
              EVAS_FONT_WALK_POS \
             )
#else
# define EVAS_FONT_WALK_X_OFF 0
# define EVAS_FONT_WALK_Y_OFF 0
# define EVAS_FONT_WALK_POS \
              ((text_props->bidi_dir == EVAS_BIDI_DIRECTION_RTL) ? \
               (text_props->len - char_index - 1) : \
               (char_index))
# define EVAS_FONT_WALK_POS_NEXT \
             ((!EVAS_FONT_WALK_IS_LAST) ? \
              ((text_props->bidi_dir == EVAS_BIDI_DIRECTION_RTL) ? \
               text_props->len - char_index - 2 \
               : (char_index + 1)) : \
              EVAS_FONT_WALK_POS)
# define EVAS_FONT_WALK_POS_PREV \
             ((char_index > 0) ? \
              ((text_props->bidi_dir == EVAS_BIDI_DIRECTION_RTL) ? \
               text_props->len - char_index \
               : (char_index - 1)) : \
              EVAS_FONT_WALK_POS)
#endif


#define EVAS_FONT_WALK_IS_VISIBLE (_glyph_itr->index != 0)
#define EVAS_FONT_WALK_X_BEAR (_glyph_itr->x_bear)
#define EVAS_FONT_WALK_Y_BEAR (_glyph_itr->y_bear)
#define EVAS_FONT_WALK_X_ADV ((_glyph_itr > text_props->info->glyph) ? \
      _glyph_itr->pen_after - (_glyph_itr - 1)->pen_after : \
      _glyph_itr->pen_after)
#define EVAS_FONT_WALK_WIDTH (_glyph_itr->width)

#define EVAS_FONT_WALK_INDEX (_glyph_itr->index)
#define EVAS_FONT_WALK_PEN_X (_pen_x)
#define EVAS_FONT_WALK_PEN_X_AFTER (_glyph_itr->pen_after - _start_pen)
#define EVAS_FONT_WALK_PEN_Y (EVAS_FONT_ROUND_26_6_TO_INT(_pen_y))
#define EVAS_FONT_WALK_Y_ADV (0)
#define EVAS_FONT_WALK_IS_LAST \
             (char_index + 1 == text_props->len)
#define EVAS_FONT_WALK_IS_FIRST \
             (char_index == 0)
#define EVAS_FONT_WALK_LEN (text_props->len)

/**
 * @def EVAS_FONT_WALK_TEXT_WORK
 * @internal
 * This macro actually updates the values mentioned in EVAS_FONT_WALK_TEXT_START
 * according to the current positing in the walk.
 * @see EVAS_FONT_WALK_TEXT_START
 * @see EVAS_FONT_WALK_TEXT_INIT
 * @see EVAS_FONT_WALK_TEXT_END
 */
#define EVAS_FONT_WALK_TEXT_WORK() do {} while(0)

/**
 * @def EVAS_FONT_WALK_TEXT_END
 * @internal
 * Closes EVAS_FONT_WALK_TEXT_START, needs to end with a ;
 * @see EVAS_FONT_WALK_TEXT_START
 * @see EVAS_FONT_WALK_TEXT_INIT
 * @see EVAS_FONT_WALK_TEXT_WORK
 */
#define EVAS_FONT_WALK_TEXT_END() \
             if (EVAS_FONT_WALK_IS_VISIBLE) \
               { \
                  _pen_x = _glyph_itr->pen_after - _start_pen; \
               } \
          } \
     } \
   while(0)

#endif