summaryrefslogtreecommitdiff
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
parent039b3da078c578837cf40aab4edefdad05247e7b (diff)
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.
-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 98b3ac46d6..45f82d31f6 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
820 } 820 }
821 if (itr && (itr != start_ellip_it)) 821 if (itr && (itr != start_ellip_it))
822 { 822 {
823 int cut = 1 + ENFN->font_char_at_coords_get(ENDT, 823 int cut = 1 + ENFN->font_last_up_to_pos(ENDT,
824 o->font, 824 o->font,
825 &itr->text_props, 825 &itr->text_props,
826 ellipsis_coord - advance, 826 ellipsis_coord - advance,
827 0, 827 0);
828 NULL, NULL, NULL, NULL);
829 if (cut > 0) 828 if (cut > 0)
830 { 829 {
831 start_ellip_it->text_pos = itr->text_pos; 830 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
864 /* FIXME: We shouldn't do anything. */ 863 /* FIXME: We shouldn't do anything. */
865 } 864 }
866 865
867 int cut = ENFN->font_char_at_coords_get(ENDT, 866 int cut = ENFN->font_last_up_to_pos(ENDT,
868 o->font, 867 o->font,
869 &itr->text_props, 868 &itr->text_props,
870 ellip_frame - advance, 869 ellip_frame - advance,
871 0, 870 0);
872 NULL, NULL, NULL, NULL);
873 if (cut >= 0) 871 if (cut >= 0)
874 { 872 {
875 end_ellip_it->text_pos = itr->text_pos + cut; 873 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 861849f9d5..e0a9fad4fc 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)
166} 166}
167END_TEST 167END_TEST
168 168
169START_TEST(evas_text_ellipsis) 169static void
170_test_ellipsis(Evas_Object *to, const char *buf, const char *font, Evas_Font_Size size, double ellipsis)
170{ 171{
171 START_TEXT_TEST(); 172 evas_object_text_ellipsis_set(to, ellipsis);
172 const char *buf = "נסיון בלה בלה בלה בלה";
173 const char *font = TEST_FONT_NAME;
174 Evas_Font_Size size = 14;
175
176 evas_object_text_ellipsis_set(to, 0.0);
177 evas_object_move(to, 0, 0); 173 evas_object_move(to, 0, 0);
178 evas_object_resize(to, 500, 500); 174 evas_object_resize(to, 500, 500);
179 evas_object_text_font_set(to, font, size); 175 evas_object_text_font_set(to, font, size);
@@ -191,7 +187,33 @@ START_TEST(evas_text_ellipsis)
191 /* If it's gotten way too small, it means we have an issue. */ 187 /* If it's gotten way too small, it means we have an issue. */
192 fail_if(w < 100); 188 fail_if(w < 100);
193 } 189 }
190}
191
192START_TEST(evas_text_ellipsis)
193{
194 START_TEXT_TEST();
195 const char *buf = "נסיון בלה בלה בלה בלה";
196 const char *font = TEST_FONT_NAME;
197 Evas_Font_Size size = 14;
198
199 /* Test various ellipsis types. */
200
201 /* RTL */
202 _test_ellipsis(to, buf, font, size, 0.0);
203 _test_ellipsis(to, buf, font, size, 0.5);
204 _test_ellipsis(to, buf, font, size, 1.0);
205
206 /* BiDi */
207 buf = "Test נסיון בלה בלה בלה";
208 _test_ellipsis(to, buf, font, size, 0.0);
209 _test_ellipsis(to, buf, font, size, 0.5);
210 _test_ellipsis(to, buf, font, size, 1.0);
194 211
212 /* LTR */
213 buf = "Test test test test test";
214 _test_ellipsis(to, buf, font, size, 0.0);
215 _test_ellipsis(to, buf, font, size, 0.5);
216 _test_ellipsis(to, buf, font, size, 1.0);
195 217
196 END_TEXT_TEST(); 218 END_TEXT_TEST();
197} 219}