Evas font: fix width calc in last_up_to_pos
Width calculations should consider the x_bear. This has been leading to inconsistent results between wrapping calculation during layout and the final formatted size. Also, we should stop our walk only when exceeding 'x', so changed "<=" to "<". @fix
This commit is contained in:
parent
7e411ecf76
commit
4013dccda6
|
@ -823,7 +823,7 @@ evas_common_font_query_last_up_to_pos(RGBA_Font *fn, const Evas_Text_Props *text
|
|||
if ((x >= pen_x) &&
|
||||
(((i == 0) && (x <= full_adv)) ||
|
||||
(x < (full_adv - (gli[-1].pen_after - start_pen)) ||
|
||||
(x <= (pen_x + gli->width)))) &&
|
||||
(x < (pen_x + gli->x_bear + gli->width)))) &&
|
||||
(y >= -asc) && (y <= desc))
|
||||
{
|
||||
#ifdef OT_SUPPORT
|
||||
|
@ -850,8 +850,9 @@ evas_common_font_query_last_up_to_pos(RGBA_Font *fn, const Evas_Text_Props *text
|
|||
|
||||
if ((x >= EVAS_FONT_WALK_PEN_X) &&
|
||||
((x < (EVAS_FONT_WALK_PEN_X_AFTER)) ||
|
||||
(x <= (EVAS_FONT_WALK_PEN_X + _glyph_itr->width))) &&
|
||||
(y >= -asc) && (y <= desc))
|
||||
(x < (EVAS_FONT_WALK_PEN_X +
|
||||
_glyph_itr->x_bear + _glyph_itr->width))) &&
|
||||
(y >= -asc) && (y <= desc))
|
||||
{
|
||||
ret = EVAS_FONT_WALK_POS;
|
||||
goto end;
|
||||
|
|
|
@ -2210,6 +2210,20 @@ START_TEST(evas_textblock_wrapping)
|
|||
evas_object_textblock_size_formatted_get(tb, NULL, &h);
|
||||
ck_assert_int_ge(h, bh);
|
||||
|
||||
/* Check char-wrapping for small items */
|
||||
evas_object_textblock_text_markup_set(tb, "x");
|
||||
evas_object_textblock_size_native_get(tb, &bw, NULL);
|
||||
evas_object_textblock_text_markup_set(tb, "AxAx");
|
||||
evas_textblock_cursor_format_prepend(cur, "+ wrap=char");
|
||||
evas_object_textblock_size_native_get(tb, &nw, &nh);
|
||||
evas_object_resize(tb, nw - bw, nh);
|
||||
evas_object_textblock_size_formatted_get(tb, &bw, NULL);
|
||||
|
||||
evas_object_textblock_text_markup_set(tb, "A<color=#f00>x</color>Ax");
|
||||
evas_textblock_cursor_format_prepend(cur, "+ wrap=char");
|
||||
evas_object_textblock_size_formatted_get(tb, &w, NULL);
|
||||
ck_assert_int_eq(bw, w);
|
||||
|
||||
END_TB_TEST();
|
||||
}
|
||||
END_TEST
|
||||
|
|
Loading…
Reference in New Issue