diff options
author | Youngbok Shin <youngb.shin@samsung.com> | 2016-01-27 13:14:52 +0000 |
---|---|---|
committer | Tom Hacohen <tom@stosb.com> | 2016-02-02 10:22:09 +0000 |
commit | cd01636d76fd158a6253ab36e344781d0bfae3df (patch) | |
tree | b5e576df34f1df99a40fc0c2c2a9bec54b6f75bb | |
parent | d15d91e0da48fc589a6e38dfb9f8bca35846de70 (diff) | |
download | efl-cd01636d76fd158a6253ab36e344781d0bfae3df.tar.gz |
Evas textblock: Use a common thickness and position at a underline.
Summary:
If a underline is drawn with seperated thickness and position, it doesn't look good.
It will take the thickest and the lowest underline.
@feature
Test Plan:
Set the following markup text in Evas Textblock.
<underline=on underline_color=#fff><font_size=20>Markup text <font_size=50>with</font_size> underline tag</font_size></underline>
It shows the underline is split to 3 underlines with different thickness and positions.
Commonly, underline has to be drawn with same thickness ans position per each line.
Reviewers: woohyun, herdsman, tasn
Reviewed By: tasn
Subscribers: jpeg, raster, subodh6129, cedric
Differential Revision: https://phab.enlightenment.org/D2971
-rw-r--r-- | src/lib/evas/canvas/evas_object_textblock.c | 61 |
1 files changed, 45 insertions, 16 deletions
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c index 2c7472a400..17c37c46e6 100644 --- a/src/lib/evas/canvas/evas_object_textblock.c +++ b/src/lib/evas/canvas/evas_object_textblock.c @@ -3541,6 +3541,7 @@ _layout_line_finalize(Ctxt *c, Evas_Object_Textblock_Format *fmt) { Evas_Coord asc = 0, desc = 0; Evas_Coord maxasc = 0, maxdesc = 0; + _layout_item_ascent_descent_adjust(c->obj, &asc, &desc, it, it->format); _layout_item_max_ascent_descent_calc(c->obj, &maxasc, &maxdesc, @@ -11986,11 +11987,12 @@ evas_object_textblock_render(Evas_Object *eo_obj EINA_UNUSED, { Evas_Object_Textblock_Paragraph *par, *start = NULL; Evas_Object_Textblock_Item *itr; - Evas_Object_Textblock_Line *ln; + Evas_Object_Textblock_Line *ln, *cur_ln = NULL; Evas_Textblock_Data *o = type_private_data; Eina_List *shadows = NULL; Eina_List *glows = NULL; Eina_List *outlines = NULL; + int strikethrough_thickness, underline_thickness, underline_position; int i, j; int cx, cy, cw, ch, clip; int ca, cr, cg, cb; @@ -12430,11 +12432,9 @@ evas_object_textblock_render(Evas_Object *eo_obj EINA_UNUSED, } /* normal text and lines */ - /* Get the thickness and position, and save them for non-text items. */ - int line_thickness = - evas_common_font_instance_underline_thickness_get(NULL); - int line_position = - evas_common_font_instance_underline_position_get(NULL); + /* Get the thickness, and save it for strikethrough of non-text items. */ + strikethrough_thickness = underline_thickness = evas_common_font_instance_underline_thickness_get(NULL); + underline_position = evas_common_font_instance_underline_position_get(NULL); ENFN->context_multiplier_unset(output, context); if (obj->cur->clipper) @@ -12447,6 +12447,37 @@ evas_object_textblock_render(Evas_Object *eo_obj EINA_UNUSED, ITEM_WALK() { Evas_Object_Textblock_Text_Item *ti; + + if (cur_ln != ln) + { + Evas_Object_Textblock_Item *itrr; + + cur_ln = ln; + underline_thickness = + evas_common_font_instance_underline_thickness_get(NULL); + underline_position = + evas_common_font_instance_underline_position_get(NULL); + + EINA_INLIST_FOREACH(ln->items, itrr) + { + if (itrr->type == EVAS_TEXTBLOCK_ITEM_TEXT) + { + int fi_underline_thickness, fi_underline_position; + void *fi = _ITEM_TEXT(itrr)->text_props.font_instance; + + fi_underline_thickness = + evas_common_font_instance_underline_thickness_get(fi); + fi_underline_position = + evas_common_font_instance_underline_position_get(fi); + + if (fi_underline_thickness > underline_thickness) + underline_thickness = fi_underline_thickness; + if (fi_underline_position > underline_position) + underline_position = fi_underline_position; + } + } + } + ti = (itr->type == EVAS_TEXTBLOCK_ITEM_TEXT) ? _ITEM_TEXT(itr) : NULL; /* NORMAL TEXT */ if (ti) @@ -12454,28 +12485,26 @@ evas_object_textblock_render(Evas_Object *eo_obj EINA_UNUSED, void *fi = _ITEM_TEXT(itr)->text_props.font_instance; COLOR_SET(normal); DRAW_TEXT(0, 0); - line_thickness = + strikethrough_thickness = evas_common_font_instance_underline_thickness_get(fi); - line_position = - evas_common_font_instance_underline_position_get(fi); } /* STRIKETHROUGH */ - DRAW_FORMAT(strikethrough, (ln->h / 2), line_thickness); + DRAW_FORMAT(strikethrough, (ln->h / 2), strikethrough_thickness); /* UNDERLINE */ - DRAW_FORMAT(underline, ln->baseline + line_position, - line_thickness * itr->format->underline_height); + DRAW_FORMAT(underline, ln->baseline + underline_position, + underline_thickness * itr->format->underline_height); /* UNDERLINE DASHED */ - DRAW_FORMAT_DASHED(underline_dash, ln->baseline + line_position, - line_thickness, + DRAW_FORMAT_DASHED(underline_dash, ln->baseline + underline_position, + underline_thickness, itr->format->underline_dash_width, itr->format->underline_dash_gap); /* UNDERLINE2 */ - DRAW_FORMAT(underline2, ln->baseline + line_position + line_thickness + - line_position, line_thickness); + DRAW_FORMAT(underline2, ln->baseline + underline_position + underline_thickness + + underline_position, underline_thickness); } ITEM_WALK_END(); ENFN->context_multiplier_unset(output, context); |