herdsman pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=4013dccda6485312477c247cd23a01a4a0307d76

commit 4013dccda6485312477c247cd23a01a4a0307d76
Author: Daniel Hirt <daniel.h...@samsung.com>
Date:   Wed Mar 23 11:53:53 2016 +0200

    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
---
 src/lib/evas/common/evas_font_query.c |  7 ++++---
 src/tests/evas/evas_test_textblock.c  | 14 ++++++++++++++
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/lib/evas/common/evas_font_query.c 
b/src/lib/evas/common/evas_font_query.c
index 1c219ee..f435b9b 100644
--- a/src/lib/evas/common/evas_font_query.c
+++ b/src/lib/evas/common/evas_font_query.c
@@ -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;
diff --git a/src/tests/evas/evas_test_textblock.c 
b/src/tests/evas/evas_test_textblock.c
index cfa0aee..63da902 100644
--- a/src/tests/evas/evas_test_textblock.c
+++ b/src/tests/evas/evas_test_textblock.c
@@ -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

-- 


Reply via email to