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.
This commit is contained in:
Tom Hacohen 2013-02-25 15:39:32 +00:00
parent 039b3da078
commit 1425b0d2dc
2 changed files with 33 additions and 13 deletions

View File

@ -820,12 +820,11 @@ _evas_object_text_layout(Evas_Object *eo_obj, Evas_Object_Text *o, Eina_Unicode
} }
if (itr && (itr != start_ellip_it)) 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, o->font,
&itr->text_props, &itr->text_props,
ellipsis_coord - advance, ellipsis_coord - advance,
0, 0);
NULL, NULL, NULL, NULL);
if (cut > 0) if (cut > 0)
{ {
start_ellip_it->text_pos = itr->text_pos; 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. */ /* 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, o->font,
&itr->text_props, &itr->text_props,
ellip_frame - advance, ellip_frame - advance,
0, 0);
NULL, NULL, NULL, NULL);
if (cut >= 0) if (cut >= 0)
{ {
end_ellip_it->text_pos = itr->text_pos + cut; end_ellip_it->text_pos = itr->text_pos + cut;

View File

@ -166,14 +166,10 @@ START_TEST(evas_text_evas)
} }
END_TEST 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(); evas_object_text_ellipsis_set(to, ellipsis);
const char *buf = "נסיון בלה בלה בלה בלה";
const char *font = TEST_FONT_NAME;
Evas_Font_Size size = 14;
evas_object_text_ellipsis_set(to, 0.0);
evas_object_move(to, 0, 0); evas_object_move(to, 0, 0);
evas_object_resize(to, 500, 500); evas_object_resize(to, 500, 500);
evas_object_text_font_set(to, font, size); 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. */ /* If it's gotten way too small, it means we have an issue. */
fail_if(w < 100); 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(); END_TEXT_TEST();
} }