evas textblock: fixed ascent/descent calculation
authorMinwoo, Lee <minwoo47.lee@samsung.com>
Fri, 13 Nov 2015 12:17:37 +0000 (12:17 +0000)
committerTom Hacohen <tom@stosb.com>
Fri, 13 Nov 2015 12:27:59 +0000 (12:27 +0000)
Summary:
If textblock has linegap and multi language, ascent/descent calculation is
incorrect.
In _layout_format_ascent_descent_adjust(), descent is accumulated.
(for example, for a line gap of 50, the first line gap is more than 100)

Test Plan:
Textblock has "linegap=50" and multi language (ex.
        "This is a test suite for line gap -
        ഈ ലൈൻ വിടവ് ടെസ്റ്റ് ടെസ്റ്റ് ടെസ്റ്റ് ടെസ്റ്റ് ഒരു പരീക്ഷണ വെയര് ")
Added test suite in evas_test_textblock.c file.

Reviewers: tasn

Subscribers: subodh6129, cedric

Differential Revision: https://phab.enlightenment.org/D3311

src/lib/evas/canvas/evas_object_textblock.c
src/tests/evas/evas_test_textblock.c

index 05d0050..4bc0e8e 100644 (file)
@@ -2744,11 +2744,10 @@ _layout_item_ascent_descent_adjust(const Evas_Object *eo_obj,
              desc = ENFN->font_descent_get(ENDT, fmt->font.font);
           }
      }
+   if (fmt) _layout_format_ascent_descent_adjust(eo_obj, &asc, &desc, fmt);
 
    if (asc > *ascent) *ascent = asc;
    if (desc > *descent) *descent = desc;
-
-   if (fmt) _layout_format_ascent_descent_adjust(eo_obj, ascent, descent, fmt);
 }
 
 /**
index d15465c..b3017fa 100644 (file)
@@ -2970,6 +2970,27 @@ START_TEST(evas_textblock_formats)
    evas_object_textblock_text_markup_set(tb, "f<color=#f00>i</color>f");
    evas_object_textblock_size_formatted_get(tb, NULL, NULL);
 
+   /* Line gap and multi language */
+   {
+      Evas_Coord h;
+      Evas_Textblock_Style *newst;
+      buf = "This is a test suite for line gap - ഈ ലൈൻ "
+                  "വിടവ് ടെസ്റ്റ് ടെസ്റ്റ് ടെസ്റ്റ് ടെസ്റ്റ് ഒരു പരീക്ഷണ വെയര് ";
+      newst = evas_textblock_style_new();
+      fail_if(!newst);
+      evas_textblock_style_set(newst,
+            "DEFAULT='" TEST_FONT " font_size=10 color=#000 wrap=word linegap=50'"
+            "br='\n'"
+            "ps='ps'"
+            "tab='\t'");
+      evas_object_textblock_style_set(tb, newst);
+      evas_object_textblock_text_markup_set(tb, buf);
+      fail_if(strcmp(evas_object_textblock_text_markup_get(tb), buf));
+      evas_object_resize(tb, 400, 400);
+      evas_object_textblock_size_formatted_get(tb, NULL, &h);
+      fail_if(h > 150);
+   }
+
    END_TB_TEST();
 }
 END_TEST