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

This commit is contained in:
Tom Hacohen 2014-08-20 15:03:12 +01:00
parent c8814e49ac
commit 841191d907
2 changed files with 27 additions and 14 deletions

View File

@ -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);
/* 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)
/* 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,
par->rendered = EINA_TRUE;
if (par->is_bidi)
_layout_update_bidi_props(o, par);
/* Clear the bidi props because we don't need them anymore. */
if (par->bidi_props)
par->bidi_props = NULL;
(void) o;
/* calculates items width in current paragraph */
@ -4678,6 +4669,14 @@ _layout_par(Ctxt *c)
c->y = c->par->y;
if (c->par->is_bidi)
_layout_update_bidi_props(c->o, c->par);
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)
if (c->par->bidi_props)
c->par->bidi_props = NULL;
return ret;

View File

@ -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. */