From 2ade3fa90212687b0d0ce61c878511b4220be4a9 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Thu, 13 Dec 2012 10:36:00 +0000 Subject: [PATCH] evas: fix case when we were in the middle of a charactere. SVN revision: 80811 --- src/lib/evas/canvas/evas_object_text.c | 3 ++- src/lib/evas/common/evas_text_utils.c | 5 +++-- src/lib/evas/common/evas_text_utils.h | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib/evas/canvas/evas_object_text.c b/src/lib/evas/canvas/evas_object_text.c index 5fbf9ee8ad..d2cc1a5383 100644 --- a/src/lib/evas/canvas/evas_object_text.c +++ b/src/lib/evas/canvas/evas_object_text.c @@ -639,7 +639,8 @@ _layout_text_item_trim(Evas_Object_Protected_Data *obj, Evas_Object_Text *o, Eva memset(&new_text_props, 0, sizeof (new_text_props)); - evas_common_text_props_split(&ti->text_props, &new_text_props, idx); + while (!evas_common_text_props_split(&ti->text_props, &new_text_props, idx)) + idx--; if (want_start) { evas_common_text_props_content_unref(&new_text_props); diff --git a/src/lib/evas/common/evas_text_utils.c b/src/lib/evas/common/evas_text_utils.c index 9182512b8d..eb4fc27b13 100644 --- a/src/lib/evas/common/evas_text_utils.c +++ b/src/lib/evas/common/evas_text_utils.c @@ -245,7 +245,7 @@ evas_common_text_props_index_find(const Evas_Text_Props *props, int _cutoff) /* Won't work in the middle of ligatures, assumes cutoff < len. * Also won't work in the middle of indic words, should handle that in a * smart way. */ -EAPI void +EAPI Eina_Bool evas_common_text_props_split(Evas_Text_Props *base, Evas_Text_Props *ext, int _cutoff) { @@ -262,7 +262,7 @@ evas_common_text_props_split(Evas_Text_Props *base, else { ERR("Couldn't find the cutoff position. Is it inside a cluster?"); - return; + return EINA_FALSE; } #else cutoff = (size_t) _cutoff; @@ -299,6 +299,7 @@ evas_common_text_props_split(Evas_Text_Props *base, base->text_len = (ext->text_offset - base->text_offset); PROPS_CHANGE(base); PROPS_CHANGE(ext); + return EINA_TRUE; } /* Won't work in the middle of ligatures */ diff --git a/src/lib/evas/common/evas_text_utils.h b/src/lib/evas/common/evas_text_utils.h index 2b1caf1d87..3f615699f8 100644 --- a/src/lib/evas/common/evas_text_utils.h +++ b/src/lib/evas/common/evas_text_utils.h @@ -95,7 +95,7 @@ evas_common_text_props_cluster_prev(const Evas_Text_Props *props, int pos); EAPI int evas_common_text_props_index_find(const Evas_Text_Props *props, int _cutoff); -EAPI void +EAPI Eina_Bool evas_common_text_props_split(Evas_Text_Props *base, Evas_Text_Props *ext, int cutoff); EAPI void