Evas textblock: Apply scale factor to <linesize>, <linegap> formats 81/69781/1
authorYoungbok Shin <youngb.shin@samsung.com>
Mon, 16 May 2016 23:49:45 +0000 (08:49 +0900)
committerYoungbok Shin <youngb.shin@samsung.com>
Mon, 16 May 2016 23:49:45 +0000 (08:49 +0900)
Summary:
Font size is scaled according to scale factor.
The linesize, linegap formats also have to be scaled properly.
@fix

Test Plan:
Test cases are included.
Run "make check"

Reviewers: woohyun, Jieun, tasn, herdsman

Reviewed By: tasn

Subscribers: cedric, jpeg

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

Change-Id: I0845c013a734f0feffa203689d404de4edecd898

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

index 4fb6606..20e8675 100644 (file)
@@ -2680,7 +2680,8 @@ _layout_format_ascent_descent_adjust(const Evas_Object *eo_obj,
         descent = *maxdescent;
         if (fmt->linesize > 0)
           {
-             if ((ascent + descent) < fmt->linesize)
+             int scaled_linesize = fmt->linesize * obj->cur->scale;
+             if ((ascent + descent) < scaled_linesize)
                {
                   ascent = ((fmt->linesize * ascent) / (ascent + descent));
                   descent = fmt->linesize - ascent;
@@ -2691,7 +2692,7 @@ _layout_format_ascent_descent_adjust(const Evas_Object *eo_obj,
              descent = descent * fmt->linerelsize;
              ascent = ascent * fmt->linerelsize;
           }
-        descent += fmt->linegap;
+        descent += fmt->linegap * obj->cur->scale;
         descent += ((ascent + descent) * fmt->linerelgap);
         if (*maxascent < ascent) *maxascent = ascent;
         if (*maxdescent < descent) *maxdescent = descent;
index 090fd8e..89b88d7 100644 (file)
@@ -3169,6 +3169,7 @@ START_TEST(evas_textblock_formats)
    START_TB_TEST();
    const char *buf = "Th<b>i<font_size=15 wrap=none>s i</font_size=13>s</> a <br/> te<ps/>st<item></>.";
    const Evas_Object_Textblock_Node_Format *fnode;
+   Evas_Coord w, h, nw, nh;
    evas_object_textblock_text_markup_set(tb, buf);
 
    /* Walk from the start */
@@ -3305,7 +3306,6 @@ START_TEST(evas_textblock_formats)
 
    /* Format text nodes invalidation */
      {
-        Evas_Coord w, h, nw, nh;
         evas_object_textblock_text_markup_set(tb, "Test");
         evas_object_textblock_size_formatted_get(tb, &w, &h);
         evas_textblock_cursor_paragraph_first(cur);
@@ -3419,6 +3419,31 @@ 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);
 
+   /* Scaling Line size */
+   evas_object_scale_set(tb, 1.0);
+   evas_object_textblock_text_markup_set(tb, "<linesize=100>Line size 100</linesize>");
+   evas_object_resize(tb, 400, 400);
+   evas_object_textblock_size_formatted_get(tb, NULL, &h);
+   ck_assert_int_ge(h, 100);
+
+   evas_object_scale_set(tb, 2.0);
+   evas_object_textblock_size_formatted_get(tb, NULL, &h);
+   ck_assert_int_ge(h, 200);
+
+   /* Scaling Line gap */
+   evas_object_scale_set(tb, 1.0);
+   evas_object_textblock_text_markup_set(tb, "<linegap=100>Line gap 100</linegap>");
+   evas_object_resize(tb, 50, 400);
+   evas_object_textblock_size_formatted_get(tb, NULL, &h);
+   ck_assert_int_ge(h, 100);
+
+   evas_object_scale_set(tb, 2.0);
+   evas_object_textblock_size_formatted_get(tb, NULL, &h);
+   ck_assert_int_ge(h, 200);
+
+   /* Restore scale */
+   evas_object_scale_set(tb, 1.0);
+
    END_TB_TEST();
 }
 END_TEST