aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2013-02-25 15:39:32 +0000
committerTom Hacohen <tom@stosb.com>2013-02-25 15:39:32 +0000
commit1425b0d2dc68aea74478bc348eb44082ae7c71f1 (patch)
treebd0c5e623d8312b565b94decaf641d9e4d651587 /src
parent039b3da078c578837cf40aab4edefdad05247e7b (diff)
downloadefl-1425b0d2dc68aea74478bc348eb44082ae7c71f1.tar.gz
efl-1425b0d2dc68aea74478bc348eb44082ae7c71f1.tar.xz
efl-1425b0d2dc68aea74478bc348eb44082ae7c71f1.zip
Evas text: Fixed a bug with the (kinda) newly added text object ellipsis.
There was a problem with bidi texts and ellipsis. The text would be trimmed according to the visual position instead of the logical.
Diffstat (limited to 'src')
-rw-r--r--src/lib/evas/canvas/evas_object_text.c10
-rw-r--r--src/tests/evas/evas_test_text.c36
2 files changed, 33 insertions, 13 deletions
diff --git a/src/lib/evas/canvas/evas_object_text.c b/src/lib/evas/canvas/evas_object_text.c
index 98b3ac46d..45f82d31f 100644
--- a/src/lib/evas/canvas/evas_object_text.c
+++ b/src/lib/evas/canvas/evas_object_text.c
@@ -820,12 +820,11 @@ _evas_object_text_layout(Evas_Object *eo_obj, Evas_Object_Text *o, Eina_Unicode
}
if (itr && (itr != start_ellip_it))
{
- int cut = 1 + ENFN->font_char_at_coords_get(ENDT,
+ int cut = 1 + ENFN->font_last_up_to_pos(ENDT,
o->font,
&itr->text_props,
ellipsis_coord - advance,
- 0,
- NULL, NULL, NULL, NULL);
+ 0);
if (cut > 0)
{
start_ellip_it->text_pos = itr->text_pos;
@@ -864,12 +863,11 @@ _evas_object_text_layout(Evas_Object *eo_obj, Evas_Object_Text *o, Eina_Unicode
/* FIXME: We shouldn't do anything. */
}
- int cut = ENFN->font_char_at_coords_get(ENDT,
+ int cut = ENFN->font_last_up_to_pos(ENDT,
o->font,
&itr->text_props,
ellip_frame - advance,
- 0,
- NULL, NULL, NULL, NULL);
+ 0);
if (cut >= 0)
{
end_ellip_it->text_pos = itr->text_pos + cut;
diff --git a/src/tests/evas/evas_test_text.c b/src/tests/evas/evas_test_text.c
index 861849f9d..e0a9fad4f 100644
--- a/src/tests/evas/evas_test_text.c
+++ b/src/tests/evas/evas_test_text.c
@@ -166,14 +166,10 @@ START_TEST(evas_text_evas)
}
END_TEST
-START_TEST(evas_text_ellipsis)
+static void
+_test_ellipsis(Evas_Object *to, const char *buf, const char *font, Evas_Font_Size size, double ellipsis)
{
- START_TEXT_TEST();
- const char *buf = "נסיון בלה בלה בלה בלה";
- const char *font = TEST_FONT_NAME;
- Evas_Font_Size size = 14;
-
- evas_object_text_ellipsis_set(to, 0.0);
+ evas_object_text_ellipsis_set(to, ellipsis);
evas_object_move(to, 0, 0);
evas_object_resize(to, 500, 500);
evas_object_text_font_set(to, font, size);
@@ -191,7 +187,33 @@ START_TEST(evas_text_ellipsis)
/* If it's gotten way too small, it means we have an issue. */
fail_if(w < 100);
}
+}
+
+START_TEST(evas_text_ellipsis)
+{
+ START_TEXT_TEST();
+ const char *buf = "נסיון בלה בלה בלה בלה";
+ const char *font = TEST_FONT_NAME;
+ Evas_Font_Size size = 14;
+
+ /* Test various ellipsis types. */
+
+ /* RTL */
+ _test_ellipsis(to, buf, font, size, 0.0);
+ _test_ellipsis(to, buf, font, size, 0.5);
+ _test_ellipsis(to, buf, font, size, 1.0);
+
+ /* BiDi */
+ buf = "Test נסיון בלה בלה בלה";
+ _test_ellipsis(to, buf, font, size, 0.0);
+ _test_ellipsis(to, buf, font, size, 0.5);
+ _test_ellipsis(to, buf, font, size, 1.0);
+ /* LTR */
+ buf = "Test test test test test";
+ _test_ellipsis(to, buf, font, size, 0.0);
+ _test_ellipsis(to, buf, font, size, 0.5);
+ _test_ellipsis(to, buf, font, size, 1.0);
END_TEXT_TEST();
}