From: Youngbok Shin Date: Mon, 16 May 2016 23:49:45 +0000 (+0900) Subject: Evas textblock: Apply scale factor to , formats X-Git-Tag: accepted/tizen/common/20160519.191115~4^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F81%2F69781%2F1;p=platform%2Fupstream%2Fefl.git Evas textblock: Apply scale factor to , formats 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 --- diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c index 4fb6606..20e8675 100644 --- a/src/lib/evas/canvas/evas_object_textblock.c +++ b/src/lib/evas/canvas/evas_object_textblock.c @@ -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; diff --git a/src/tests/evas/evas_test_textblock.c b/src/tests/evas/evas_test_textblock.c index 090fd8e..89b88d7 100644 --- a/src/tests/evas/evas_test_textblock.c +++ b/src/tests/evas/evas_test_textblock.c @@ -3169,6 +3169,7 @@ START_TEST(evas_textblock_formats) START_TB_TEST(); const char *buf = "This is a
test."; 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, "fif"); 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, "Line size 100
"); + 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, "Line gap 100
"); + 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