summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2014-08-20 15:03:12 +0100
committerTom Hacohen <tom@stosb.com>2014-08-20 15:10:23 +0100
commit841191d907f7addec4ab8613ddae81f1767f4836 (patch)
tree41ac00fc5bf5351e71a8d7a1b7f1ae88d89f4f47
parentc8814e49accbd81b7a7e7d8dbfc25a819b9d08de (diff)
Evas textblock: Fix BiDi text cut-off at the edges.
This patch fixes an issue causing text to be cut off in some cases. The problem was that we were calculating line width and alignment before we did any bidi calculations, which in turn caused us to use the wrong text items for those calculations. Many thanks to Daniel Hirt for investigating this deeply, finding all the nitty-gritty and generally pointing me to where the problem is. Daniel also provided the test case. His patch (D1291) was close, but not enough. Fixes T1496 @Fix
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c35
-rw-r--r--src/tests/evas/evas_test_textblock.c6
2 files changed, 27 insertions, 14 deletions
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index fb59cee..47163cc 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -3316,6 +3316,10 @@ _layout_line_finalize(Ctxt *c, Evas_Object_Textblock_Format *fmt)
3316 _layout_item_ascent_descent_adjust(c->obj, &c->ascent, &c->descent, 3316 _layout_item_ascent_descent_adjust(c->obj, &c->ascent, &c->descent,
3317 NULL, fmt); 3317 NULL, fmt);
3318 3318
3319#ifdef BIDI_SUPPORT
3320 _layout_line_reorder(c->ln);
3321#endif
3322
3319 /* Adjust all the item sizes according to the final line size, 3323 /* Adjust all the item sizes according to the final line size,
3320 * and update the x positions of all the items of the line. */ 3324 * and update the x positions of all the items of the line. */
3321 EINA_INLIST_FOREACH(c->ln->items, it) 3325 EINA_INLIST_FOREACH(c->ln->items, it)
@@ -4442,6 +4446,7 @@ _layout_paragraph_reorder_lines(Evas_Object_Textblock_Paragraph *par)
4442} 4446}
4443#endif 4447#endif
4444 4448
4449/* Don't do much for the meanwhile. */
4445static inline void 4450static inline void
4446_layout_paragraph_render(Evas_Textblock_Data *o, 4451_layout_paragraph_render(Evas_Textblock_Data *o,
4447 Evas_Object_Textblock_Paragraph *par) 4452 Evas_Object_Textblock_Paragraph *par)
@@ -4450,21 +4455,7 @@ _layout_paragraph_render(Evas_Textblock_Data *o,
4450 return; 4455 return;
4451 par->rendered = EINA_TRUE; 4456 par->rendered = EINA_TRUE;
4452 4457
4453#ifdef BIDI_SUPPORT
4454 if (par->is_bidi)
4455 {
4456 _layout_update_bidi_props(o, par);
4457 _layout_paragraph_reorder_lines(par);
4458 /* Clear the bidi props because we don't need them anymore. */
4459 if (par->bidi_props)
4460 {
4461 evas_bidi_paragraph_props_unref(par->bidi_props);
4462 par->bidi_props = NULL;
4463 }
4464 }
4465#else
4466 (void) o; 4458 (void) o;
4467#endif
4468} 4459}
4469 4460
4470/* calculates items width in current paragraph */ 4461/* calculates items width in current paragraph */
@@ -4678,6 +4669,14 @@ _layout_par(Ctxt *c)
4678 4669
4679 c->y = c->par->y; 4670 c->y = c->par->y;
4680 4671
4672
4673#ifdef BIDI_SUPPORT
4674 if (c->par->is_bidi)
4675 {
4676 _layout_update_bidi_props(c->o, c->par);
4677 }
4678#endif
4679
4681 it = _ITEM(eina_list_data_get(c->par->logical_items)); 4680 it = _ITEM(eina_list_data_get(c->par->logical_items));
4682 _layout_line_new(c, it->format); 4681 _layout_line_new(c, it->format);
4683 /* We walk on our own because we want to be able to add items from 4682 /* We walk on our own because we want to be able to add items from
@@ -4950,6 +4949,14 @@ end:
4950 if (line_breaks) 4949 if (line_breaks)
4951 free(line_breaks); 4950 free(line_breaks);
4952 4951
4952#ifdef BIDI_SUPPORT
4953 if (c->par->bidi_props)
4954 {
4955 evas_bidi_paragraph_props_unref(c->par->bidi_props);
4956 c->par->bidi_props = NULL;
4957 }
4958#endif
4959
4953 return ret; 4960 return ret;
4954} 4961}
4955 4962
diff --git a/src/tests/evas/evas_test_textblock.c b/src/tests/evas/evas_test_textblock.c
index 78d83ef..e7d8cc9 100644
--- a/src/tests/evas/evas_test_textblock.c
+++ b/src/tests/evas/evas_test_textblock.c
@@ -2933,6 +2933,12 @@ START_TEST(evas_textblock_size)
2933 (nw != oldnw + 8) || (nh != oldnh)); 2933 (nw != oldnw + 8) || (nh != oldnh));
2934 } 2934 }
2935 2935
2936 evas_object_resize(tb, 1000, 1000);
2937 evas_object_textblock_text_markup_set(tb, "\u200fHello שלום");
2938 evas_object_textblock_size_formatted_get(tb, &w, NULL);
2939 evas_object_textblock_size_native_get(tb, &nw, NULL);
2940 ck_assert_int_eq(nw, w);
2941
2936 /* FIXME: There is a lot more to be done. */ 2942 /* FIXME: There is a lot more to be done. */
2937 END_TB_TEST(); 2943 END_TB_TEST();
2938} 2944}