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 ; \
+ text_props->info->glyph[text_props->start - 1].pen_after : 0 ; \
size_t char_index; \
(void) _pen_y; /* Sometimes it won't be used */
/* Visual walk helper macros */
#ifdef OT_SUPPORT
-#define _EVAS_FONT_WALK_TEXT_VISUAL_START() \
+#define _EVAS_FONT_WALK_TEXT_START() \
Evas_Font_OT_Info *_ot_itr = (text_props->info) ? \
text_props->info->ot + text_props->start : NULL; \
for (char_index = 0 ; char_index < text_props->len ; char_index++, _glyph_itr++, _ot_itr++) \
{
#else
-#define _EVAS_FONT_WALK_TEXT_VISUAL_START() \
+#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_VISUAL_START
+ * @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.
* @see EVAS_FONT_WALK_TEXT_INIT
* @see EVAS_FONT_WALK_TEXT_WORK
* @see EVAS_FONT_WALK_TEXT_END
- * @see EVAS_FONT_WALK_TEXT_LOGICAL_START
*/
-#define EVAS_FONT_WALK_TEXT_VISUAL_START() \
+#define EVAS_FONT_WALK_TEXT_START() \
do \
{ \
Evas_Font_Glyph_Info *_glyph_itr = (text_props->info) ? \
text_props->info->glyph + text_props->start : NULL; \
- _EVAS_FONT_WALK_TEXT_VISUAL_START()
-
-/* Logical walk helper macros */
-#ifdef OT_SUPPORT
-#define _EVAS_FONT_WALK_TEXT_LOGICAL_START() \
- Evas_Font_OT_Info *_ot_itr = (text_props->info) ? \
- text_props->info->ot + text_props->start : NULL; \
- if (text_props->bidi.dir == EVAS_BIDI_DIRECTION_RTL) \
- _ot_itr += text_props->len - 1; \
- for ( ; _i > 0 ; char_index += _char_index_d, _i--, _glyph_itr += _char_index_d, _ot_itr += _char_index_d) \
- {
-#else
-#define _EVAS_FONT_WALK_TEXT_LOGICAL_START() \
- for ( ; _i > 0 ; char_index += _char_index_d, _i--, _glyph_itr += _char_index_d) \
- {
-#endif
-
-/**
- * @def EVAS_FONT_WALK_TEXT_LOGICAL_START
- * @internal
- * This runs through the text in logical 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
- * @see EVAS_FONT_WALK_TEXT_VISUAL_START
- */
-#ifdef BIDI_SUPPORT
-#define EVAS_FONT_WALK_TEXT_LOGICAL_START() \
- do \
- { \
- Evas_Font_Glyph_Info *_glyph_itr = (text_props->info) ? \
- text_props->info->glyph + text_props->start : \
- NULL; \
- int _char_index_d; \
- size_t _i; \
- _i = text_props->len; \
- if (text_props->bidi.dir == EVAS_BIDI_DIRECTION_RTL) \
- { \
- char_index = text_props->len - 1; \
- _char_index_d = -1; \
- _glyph_itr += text_props->len - 1; \
- } \
- else \
- { \
- char_index = 0; \
- _char_index_d = 1; \
- } \
- _EVAS_FONT_WALK_TEXT_LOGICAL_START()
-
-#else
-#define EVAS_FONT_WALK_TEXT_LOGICAL_START() EVAS_FONT_WALK_TEXT_VISUAL_START()
-#endif
+ _EVAS_FONT_WALK_TEXT_START()
#define EVAS_FONT_WALK_ORIG_LEN (_len)
/**
* @def EVAS_FONT_WALK_TEXT_WORK
* @internal
- * This macro actually updates the values mentioned in EVAS_FONT_WALK_TEXT_VISUAL_START
+ * 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_VISUAL_START
+ * @see EVAS_FONT_WALK_TEXT_START
* @see EVAS_FONT_WALK_TEXT_INIT
* @see EVAS_FONT_WALK_TEXT_END
*/
/**
* @def EVAS_FONT_WALK_TEXT_END
* @internal
- * Closes EVAS_FONT_WALK_TEXT_VISUAL_START, needs to end with a ;
- * @see EVAS_FONT_WALK_TEXT_VISUAL_START
+ * 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
*/
} \
while(0)
-
#endif
int prev_cluster = -1;
int found = 0, items = 1, item_pos = 1;
int last_is_visible = 0;
- EVAS_FONT_WALK_TEXT_VISUAL_START()
+ EVAS_FONT_WALK_TEXT_START()
{
EVAS_FONT_WALK_TEXT_WORK();
int prev_cluster = -1;
int found = 0, items = 1, item_pos = 1;
int last_is_visible = 0;
- EVAS_FONT_WALK_TEXT_VISUAL_START()
+ EVAS_FONT_WALK_TEXT_START()
{
EVAS_FONT_WALK_TEXT_WORK();
Evas_Coord cluster_start = 0;
int prev_cluster = -1;
int found = 0, items = 1;
- EVAS_FONT_WALK_TEXT_VISUAL_START()
+ EVAS_FONT_WALK_TEXT_START()
{
EVAS_FONT_WALK_TEXT_WORK();
if (prev_cluster != (int) EVAS_FONT_WALK_POS)
{
int asc, desc;
int ret=-1;
- EVAS_FONT_WALK_TEXT_INIT();
asc = evas_common_font_max_ascent_get(fn);
desc = evas_common_font_max_descent_get(fn);
- EVAS_FONT_WALK_TEXT_LOGICAL_START()
+#ifdef BIDI_SUPPORT
+ if (text_props->bidi.dir == EVAS_BIDI_DIRECTION_RTL)
{
- EVAS_FONT_WALK_TEXT_WORK();
- if (!EVAS_FONT_WALK_IS_VISIBLE) continue;
+ Evas_Font_Glyph_Info *gli = (text_props->info) ?
+ text_props->info->glyph + text_props->start : NULL;
+ Evas_Coord full_adv = 0, pen_x = 0, start_pen = 0;
+ int i;
- if ((x >= EVAS_FONT_WALK_PEN_X) &&
- (x <= (EVAS_FONT_WALK_PEN_X_AFTER)) && (y >= -asc) && (y <= desc))
+ if (text_props->len > 0)
{
- ret = EVAS_FONT_WALK_POS;
- goto end;
+ full_adv = gli[text_props->len - 1].pen_after;
+ if (text_props->start > 0)
+ {
+ start_pen = gli[-1].pen_after;
+ full_adv -= start_pen;
+ }
+ }
+
+ gli += text_props->len - 1;
+ for (i = text_props->len - 1 ; i >= 0 ; i--, gli--)
+ {
+ pen_x = full_adv - (gli->pen_after - start_pen);
+ /* If inivisible, skip */
+ if (gli->index == 0) continue;
+ if ((x >= pen_x) &&
+ (((i == 0) && (x <= full_adv)) ||
+ (x <= (full_adv - (gli[-1].pen_after - start_pen)))) &&
+ (y >= -asc) && (y <= desc))
+ {
+#ifdef OT_SUPPORT
+ ret = EVAS_FONT_OT_POS_GET(
+ text_props->info->ot[text_props->start + i]) -
+ text_props->text_offset;
+#else
+ ret = text_props->text_len - i - 1;
+#endif
+ goto end;
+ }
}
}
- EVAS_FONT_WALK_TEXT_END();
+ else
+#endif
+ {
+ EVAS_FONT_WALK_TEXT_INIT();
+ /* When text is not rtl, visual direction = logical direction */
+ EVAS_FONT_WALK_TEXT_START()
+ {
+ EVAS_FONT_WALK_TEXT_WORK();
+ if (!EVAS_FONT_WALK_IS_VISIBLE) continue;
+
+ if ((x >= EVAS_FONT_WALK_PEN_X) &&
+ (x <= (EVAS_FONT_WALK_PEN_X_AFTER)) &&
+ (y >= -asc) && (y <= desc))
+ {
+ ret = EVAS_FONT_WALK_POS;
+ goto end;
+ }
+ }
+ EVAS_FONT_WALK_TEXT_END();
+ }
end: