From 841191d907f7addec4ab8613ddae81f1767f4836 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 20 Aug 2014 15:03:12 +0100 Subject: [PATCH] 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 --- src/lib/evas/canvas/evas_object_textblock.c | 35 ++++++++++++--------- src/tests/evas/evas_test_textblock.c | 6 ++++ 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 fb59cee003..47163ccc2b 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) _layout_item_ascent_descent_adjust(c->obj, &c->ascent, &c->descent, NULL, fmt); +#ifdef BIDI_SUPPORT + _layout_line_reorder(c->ln); +#endif + /* Adjust all the item sizes according to the final line size, * and update the x positions of all the items of the line. */ EINA_INLIST_FOREACH(c->ln->items, it) @@ -4442,6 +4446,7 @@ _layout_paragraph_reorder_lines(Evas_Object_Textblock_Paragraph *par) } #endif +/* Don't do much for the meanwhile. */ static inline void _layout_paragraph_render(Evas_Textblock_Data *o, Evas_Object_Textblock_Paragraph *par) @@ -4450,21 +4455,7 @@ _layout_paragraph_render(Evas_Textblock_Data *o, return; par->rendered = EINA_TRUE; -#ifdef BIDI_SUPPORT - if (par->is_bidi) - { - _layout_update_bidi_props(o, par); - _layout_paragraph_reorder_lines(par); - /* Clear the bidi props because we don't need them anymore. */ - if (par->bidi_props) - { - evas_bidi_paragraph_props_unref(par->bidi_props); - par->bidi_props = NULL; - } - } -#else (void) o; -#endif } /* calculates items width in current paragraph */ @@ -4678,6 +4669,14 @@ _layout_par(Ctxt *c) c->y = c->par->y; + +#ifdef BIDI_SUPPORT + if (c->par->is_bidi) + { + _layout_update_bidi_props(c->o, c->par); + } +#endif + it = _ITEM(eina_list_data_get(c->par->logical_items)); _layout_line_new(c, it->format); /* We walk on our own because we want to be able to add items from @@ -4950,6 +4949,14 @@ end: if (line_breaks) free(line_breaks); +#ifdef BIDI_SUPPORT + if (c->par->bidi_props) + { + evas_bidi_paragraph_props_unref(c->par->bidi_props); + c->par->bidi_props = NULL; + } +#endif + return ret; } diff --git a/src/tests/evas/evas_test_textblock.c b/src/tests/evas/evas_test_textblock.c index 78d83ef25f..e7d8cc969e 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) (nw != oldnw + 8) || (nh != oldnh)); } + evas_object_resize(tb, 1000, 1000); + evas_object_textblock_text_markup_set(tb, "\u200fHello שלום"); + evas_object_textblock_size_formatted_get(tb, &w, NULL); + evas_object_textblock_size_native_get(tb, &nw, NULL); + ck_assert_int_eq(nw, w); + /* FIXME: There is a lot more to be done. */ END_TB_TEST(); }