diff --git a/legacy/evas/src/lib/engines/common/evas_font_ot.c b/legacy/evas/src/lib/engines/common/evas_font_ot.c index dbc96b9be1..6b4f91e9f2 100644 --- a/legacy/evas/src/lib/engines/common/evas_font_ot.c +++ b/legacy/evas/src/lib/engines/common/evas_font_ot.c @@ -31,10 +31,6 @@ evas_common_font_ot_cluster_size_get(const Evas_Text_Props *props, size_t char_i i++) ; right_bound = i; - if (left_bound < 0) - left_bound = 0; - if (right_bound >= (int) (props->start + props->len)) - right_bound = props->start + props->len - 1; if (right_bound == left_bound) { @@ -44,26 +40,22 @@ evas_common_font_ot_cluster_size_get(const Evas_Text_Props *props, size_t char_i { if (left_bound < 0) { - items = props->start + props->len - - props->info->ot[left_bound + 1].source_cluster; + items = props->text_offset + props->text_len - base_cluster; } else { - items = props->info->ot[left_bound].source_cluster - - props->info->ot[left_bound + 1].source_cluster; + items = props->info->ot[left_bound].source_cluster - base_cluster; } } else { - if (right_bound == (int) (props->start + props->len)) + if (right_bound > (int) (props->text_offset + props->text_len)) { - items = props->start + props->len - - props->info->ot[right_bound - 1].source_cluster; + items = props->text_offset + props->text_len - base_cluster; } else { - items = props->info->ot[right_bound].source_cluster - - props->info->ot[right_bound - 1].source_cluster; + items = props->info->ot[right_bound].source_cluster - base_cluster; } } return (items > 0) ? items : 1; diff --git a/legacy/evas/src/lib/engines/common/evas_font_query.c b/legacy/evas/src/lib/engines/common/evas_font_query.c index 6150163ee8..1bada55058 100644 --- a/legacy/evas/src/lib/engines/common/evas_font_query.c +++ b/legacy/evas/src/lib/engines/common/evas_font_query.c @@ -143,7 +143,7 @@ evas_common_font_query_char_coords(RGBA_Font *fn, const Eina_Unicode *text __UNU position = pos; /* If it's the null, choose location according to the direction. */ - if (text_props->len == position) + if (position == text_props->text_len) { /* if it's rtl then the location is the left of the string, * otherwise, the right. */ @@ -267,7 +267,7 @@ evas_common_font_query_pen_coords(RGBA_Font *fn, const Eina_Unicode *text __UNUS position = pos; /* If it's the null, choose location according to the direction. */ - if (text_props->len == position) + if (position == text_props->text_len) { /* if it's rtl then the location is the left of the string, * otherwise, the right. */ diff --git a/legacy/evas/src/lib/engines/common/evas_text_utils.c b/legacy/evas/src/lib/engines/common/evas_text_utils.c index b94e6ff728..ad1bcd247e 100644 --- a/legacy/evas/src/lib/engines/common/evas_text_utils.c +++ b/legacy/evas/src/lib/engines/common/evas_text_utils.c @@ -143,6 +143,8 @@ evas_common_text_props_split(Evas_Text_Props *base, ext->text_offset = base->text_offset + base->len; #endif } + ext->text_len = base->text_len - (ext->text_offset - base->text_offset); + base->text_len = (ext->text_offset - base->text_offset); } /* Won't work in the middle of ligatures */ @@ -161,6 +163,7 @@ evas_common_text_props_merge(Evas_Text_Props *item1, } item1->len += item2->len; + item1->text_len += item2->text_len; } EAPI Eina_Bool @@ -325,6 +328,7 @@ evas_common_text_props_content_create(void *_fn, const Eina_Unicode *text, } text_props->len = len; #endif + text_props->text_len = len; text_props->info->refcount = 1; return EINA_TRUE; } diff --git a/legacy/evas/src/lib/engines/common/evas_text_utils.h b/legacy/evas/src/lib/engines/common/evas_text_utils.h index 47ab8afec9..e4907ab97b 100644 --- a/legacy/evas/src/lib/engines/common/evas_text_utils.h +++ b/legacy/evas/src/lib/engines/common/evas_text_utils.h @@ -16,6 +16,7 @@ struct _Evas_Text_Props size_t start; size_t len; size_t text_offset; /* The text offset from the start of the info */ + size_t text_len; /* The length of the original text */ Evas_BiDi_Props bidi; Evas_Script_Type script; Evas_Text_Props_Info *info;