xartigas pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=ba99891710a558412f0962f79993a5b9651eae59
commit ba99891710a558412f0962f79993a5b9651eae59 Author: Ali Alzyod <[email protected]> Date: Tue Feb 4 17:45:32 2020 +0100 efl.canvas.textblock: update style strings Summary: Update backing -> background_type backing_color -> background_color underline_dash_color -> underline_dashed_color underline - > underline_type strikethrough - > strikethrough_type style -> (effect_type + shadow_direction) underline_dash_width -> underline_dashed_width underline_dashed_gap -> underline_dashed_gap **+prevent unified APIs from supporting legacy style tags, and prevent legacy APIs from the ability to use new unified tags** Reviewers: zmike, woohyun, segfaultxavi, bu5hm4n, cedric Reviewed By: segfaultxavi, bu5hm4n Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8523 Differential Revision: https://phab.enlightenment.org/D11188 --- src/lib/evas/canvas/efl_canvas_textblock.eo | 65 +- src/lib/evas/canvas/evas_object_textblock.c | 1729 +++++++++++++++------------ src/tests/evas/evas_test_textblock.c | 26 +- 3 files changed, 1009 insertions(+), 811 deletions(-) diff --git a/src/lib/evas/canvas/efl_canvas_textblock.eo b/src/lib/evas/canvas/efl_canvas_textblock.eo index 2ecfd7bd8d..7d20786c5f 100644 --- a/src/lib/evas/canvas/efl_canvas_textblock.eo +++ b/src/lib/evas/canvas/efl_canvas_textblock.eo @@ -137,47 +137,47 @@ class @beta Efl.Canvas.Textblock extends Efl.Canvas.Object implements Efl.Text, - $underline_color: Color code for the text underline (See bottom for the complete list of supported codes). Default value is $[rgba(0,0,0,0)] meaning that no underline will be rendered. - Requires $underline. + Requires $underline_type. See @Efl.Text_Style.text_underline_color. - $secondary_underline_color: Color code for the secondary text underline (See bottom for the complete list - of supported codes). Only valid when $[underline=double]. + of supported codes). Only valid when $[underline_type=double]. Default value is $[rgba(0,0,0,0)] meaning that secondary underline will not be rendered. See @Efl.Text_Style.text_secondary_underline_color. - - $underline_dash_color: Color code for the dashed underline (See bottom for the complete list of supported - codes). Only valid when $[underline=dashed]. + - $underline_dashed_color: Color code for the dashed underline (See bottom for the complete list of supported + codes). Only valid when $[underline_type=dashed]. Default value is $[rgba(0,0,0,0)] meaning that dashed underline will not be rendered. See @Efl.Text_Style.text_underline_dashed_color. - $outline_color: Color code for the text outline (See bottom for the complete list of supported codes). - Only valid when the $style attribute includes an outline. + Only valid when the $effect_type attribute includes an outline. Default value is $[rgba(0,0,0,0)] meaning that no outline will be rendered. See @Efl.Text_Style.text_outline_color. - $shadow_color: Color code for the text shadow (See bottom for the complete list of supported codes). - Only valid when the $style attribute includes a shadow. + Only valid when the $effect_type attribute includes a shadow. Default value is $[rgba(0,0,0,0)] meaning that no shadow will be rendered. See @Efl.Text_Style.text_shadow_color. - $glow_color: Color code for the glow component of the text (See bottom for the complete list of supported - codes). Only valid when the $style attribute includes a glow. + codes). Only valid when the $effect_type attribute includes a glow. Default value is $[rgba(0,0,0,0)] meaning that no glow will be rendered. See @Efl.Text_Style.text_glow_color. - $secondary_glow_color: Color code for the secondary (inner) glow component of the text (See bottom for - the complete list of supported codes). Only valid when the $style attribute includes a glow. + the complete list of supported codes). Only valid when the $effect_type attribute includes a glow. Default value is $[rgba(0,0,0,0)] meaning that only the primary $glow_color will be used. See @Efl.Text_Style.text_secondary_glow_color. - - $backing_color: Color code for the background of the text (See bottom for the complete list of supported + - $background_color: Color code for the background of the text (See bottom for the complete list of supported codes). Use a fully transparent color to disable the background. - Default value is $[rgba(0,0,0,0)] meaning that no backing will be rendered. - Requires $backing. + Default value is $[rgba(0,0,0,0)] meaning that no background will be rendered. + Requires $background_type. See @Efl.Text_Style.text_background_color. - $strikethrough_color: Color code for the line striking through the text (See bottom for the complete list - of supported codes). Only valid when $[strikethrough=on] + of supported codes). Only valid when $[strikethrough_type=single] Default value is $[rgba(0,0,0,0)] meaning that no strike-through line will be rendered. See @Efl.Text_Style.text_strikethrough_color. @@ -219,34 +219,35 @@ class @beta Efl.Canvas.Textblock extends Efl.Canvas.Object implements Efl.Text, Default value is $[0]. Examples: $[right_margin=10], $[right_margin=+10], $[right_margin=reset]. - - $underline: Style of the underline. The value must be one of $off (No underlining), - $single (A single line under the text), $on (Alias for $single), $double (Two lines under the text), + - $underline_type: Style of the underline. The value must be one of $none (No underlining), + $single (A single line under the text) , $double (Two lines under the text), $dashed (A dashed line under the text). - Default value is $off. - Requires either $underline_color, $secondary_underline_color or $underline_dash_color. + Default value is $none. + Requires either $underline_color, $secondary_underline_color or $underline_dashed_color. See @Efl.Text_Style.text_underline_type. - - $strikethrough: Enables crossed-out text. Possible values are $on and $off. - Default value is $off. + - $strikethrough_type: Enables crossed-out text. Possible values are $single and $none. + Default value is $none. Requires $strikethrough_color. See @Efl.Text_Style.text_strikethrough_type. - - $backing: Enables background color for the text. Possible values are $on and $off. - Default value is $off. - Requires $backing_color. + - $background_type: Enables background color for the text. Possible values are $solid and $none. + Default value is $none. + Requires $background_color. See @Efl.Text_Style.text_background_type. - - $style: Controls a number of decorations around the text, like shadow, outline and glow, including - combinations of them. Possible values are $plain (No decoration, alias for $off and $none), + - $effect_type: Controls a number of decorations around the text, like shadow, outline and glow, including + combinations of them. Possible values are $none (No decoration), $shadow, $outline, $soft_outline, $outline_shadow, $outline_soft_shadow, $glow (alias for $soft_outline), $far_shadow, $soft_shadow and $far_soft_shadow. - All values involving a shadow accept a second parameter, separated by a comma, to indicate the shadow - direction. Valid positions are $bottom_right, $bottom, $bottom_left, $left, $top_left, $top, $top_right - and $right. - Default value is $plain. + Default value is $none. Requires either $shadow_color, $glow_color or $outline_color. - Examples: $[style=outline], $[style=shadow,bottom_right], $[style=outline_shadow,bottom]. - See @Efl.Text_Style.text_effect_type and @Efl.Text_Style.text_shadow_direction. + See @Efl.Text_Style.text_effect_type + + - $shadow_direction: Indicate the shadow direction. Valid positions are $bottom_right, $bottom, $bottom_left, $left, $top_left, $top, $top_right + and $right. + Requires either $effect_type. + See @Efl.Text_Style.text_shadow_direction. - $tab_stops: Size (in pixels) of the tab character. The value must be a number greater than one. Default value is $[32]. @@ -303,15 +304,15 @@ class @beta Efl.Canvas.Textblock extends Efl.Canvas.Object implements Efl.Text, Examples: $[replacement_char=*]. See @Efl.Text_Format.replacement_char. - - $underline_dash_width: Length (in pixels) of the dashes when $underline is $dashed. + - $underline_dashed_width: Length (in pixels) of the dashes when $underline_type is $dashed. Default value is $[6]. See @Efl.Text_Style.text_underline_dashed_width. - - $underline_dash_gap: Length (in pixels) of the gaps between the dashes when $underline is $dashed. + - $underline_dashed_gap: Length (in pixels) of the gaps between the dashes when $underline_type is $dashed. Default value is $[2]. See @Efl.Text_Style.text_underline_dashed_gap. - - $underline_height: Width (in pixels) of the single underline when $underline is $single. + - $underline_height: Width (in pixels) of the single underline when $underline_type is $single. Default value is $[1]. See @Efl.Text_Style.text_underline_height. diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c index c654822871..bc7393fff6 100644 --- a/src/lib/evas/canvas/evas_object_textblock.c +++ b/src/lib/evas/canvas/evas_object_textblock.c @@ -531,6 +531,7 @@ struct _Evas_Object_Textblock Eina_Bool wrap_changed : 1; Eina_Bool auto_styles : 1; Eina_Bool fit_in_progress : 1; + Eina_Bool is_legacy : 1; }; struct _Evas_Textblock_Selection_Iterator @@ -1400,12 +1401,14 @@ static const char *underline_colorstr = NULL; static const char *underline2_colorstr = NULL; static const char *secondary_underline_colorstr = NULL; static const char *underline_dash_colorstr = NULL; +static const char *underline_dashed_colorstr = NULL; static const char *outline_colorstr = NULL; static const char *shadow_colorstr = NULL; static const char *glow_colorstr = NULL; static const char *glow2_colorstr = NULL; static const char *secondary_glow_colorstr = NULL; static const char *backing_colorstr = NULL; +static const char *background_colorstr = NULL; static const char *strikethrough_colorstr = NULL; static const char *alignstr = NULL; static const char *valignstr = NULL; @@ -1414,9 +1417,14 @@ static const char *wrapstr = NULL; static const char *left_marginstr = NULL; static const char *right_marginstr = NULL; static const char *underlinestr = NULL; +static const char *underline_typestr = NULL; static const char *strikethroughstr = NULL; +static const char *strikethrough_typestr = NULL; static const char *backingstr = NULL; +static const char *background_typestr = NULL; static const char *stylestr = NULL; +static const char *effect_typestr = NULL; +static const char *shadow_directionstr = NULL; static const char *tabstopsstr = NULL; static const char *tab_stopsstr = NULL; static const char *linesizestr = NULL; @@ -1434,7 +1442,9 @@ static const char *ellipsisstr = NULL; static const char *passwordstr = NULL; static const char *replacement_charstr = NULL; static const char *underline_dash_widthstr = NULL; +static const char *underline_dashed_widthstr = NULL; static const char *underline_dash_gapstr = NULL; +static const char *underline_dashed_gapstr = NULL; static const char *underline_heightstr = NULL; static const char *gfx_filterstr = NULL; @@ -1595,12 +1605,14 @@ _format_command_init(void) underline2_colorstr = eina_stringshare_add("underline2_color"); secondary_underline_colorstr = eina_stringshare_add("secondary_underline_color"); underline_dash_colorstr = eina_stringshare_add("underline_dash_color"); + underline_dashed_colorstr = eina_stringshare_add("underline_dashed_color"); outline_colorstr = eina_stringshare_add("outline_color"); shadow_colorstr = eina_stringshare_add("shadow_color"); glow_colorstr = eina_stringshare_add("glow_color"); glow2_colorstr = eina_stringshare_add("glow2_color"); secondary_glow_colorstr = eina_stringshare_add("secondary_glow_color"); backing_colorstr = eina_stringshare_add("backing_color"); + background_colorstr = eina_stringshare_add("background_color"); strikethrough_colorstr = eina_stringshare_add("strikethrough_color"); alignstr = eina_stringshare_add("align"); valignstr = eina_stringshare_add("valign"); @@ -1609,9 +1621,14 @@ _format_command_init(void) left_marginstr = eina_stringshare_add("left_margin"); right_marginstr = eina_stringshare_add("right_margin"); underlinestr = eina_stringshare_add("underline"); + underline_typestr = eina_stringshare_add("underline_type"); strikethroughstr = eina_stringshare_add("strikethrough"); + strikethrough_typestr = eina_stringshare_add("strikethrough_type"); backingstr = eina_stringshare_add("backing"); + background_typestr = eina_stringshare_add("background_type"); stylestr = eina_stringshare_add("style"); + effect_typestr = eina_stringshare_add("effect_type"); + shadow_directionstr = eina_stringshare_add("shadow_direction"); tabstopsstr = eina_stringshare_add("tabstops"); tab_stopsstr = eina_stringshare_add("tab_stops"); linesizestr = eina_stringshare_add("linesize"); @@ -1629,7 +1646,9 @@ _format_command_init(void) passwordstr = eina_stringshare_add("password"); replacement_charstr = eina_stringshare_add("replacement_char"); underline_dash_widthstr = eina_stringshare_add("underline_dash_width"); + underline_dashed_widthstr = eina_stringshare_add("underline_dashed_width"); underline_dash_gapstr = eina_stringshare_add("underline_dash_gap"); + underline_dashed_gapstr = eina_stringshare_add("underline_dashed_gap"); underline_heightstr = eina_stringshare_add("underline_height"); gfx_filterstr = eina_stringshare_add("gfx_filter"); // FIXME: bg, fg filters } @@ -1658,12 +1677,14 @@ _format_command_shutdown(void) eina_stringshare_del(underline2_colorstr); eina_stringshare_del(secondary_underline_colorstr); eina_stringshare_del(underline_dash_colorstr); + eina_stringshare_del(underline_dashed_colorstr); eina_stringshare_del(outline_colorstr); eina_stringshare_del(shadow_colorstr); eina_stringshare_del(glow_colorstr); eina_stringshare_del(glow2_colorstr); eina_stringshare_del(secondary_glow_colorstr); eina_stringshare_del(backing_colorstr); + eina_stringshare_del(background_colorstr); eina_stringshare_del(strikethrough_colorstr); eina_stringshare_del(alignstr); eina_stringshare_del(valignstr); @@ -1672,9 +1693,14 @@ _format_command_shutdown(void) eina_stringshare_del(left_marginstr); eina_stringshare_del(right_marginstr); eina_stringshare_del(underlinestr); + eina_stringshare_del(underline_typestr); eina_stringshare_del(strikethroughstr); + eina_stringshare_del(strikethrough_typestr); eina_stringshare_del(backingstr); + eina_stringshare_del(background_typestr); eina_stringshare_del(stylestr); + eina_stringshare_del(effect_typestr); + eina_stringshare_del(shadow_directionstr); eina_stringshare_del(tabstopsstr); eina_stringshare_del(tab_stopsstr); eina_stringshare_del(linesizestr); @@ -1692,7 +1718,9 @@ _format_command_shutdown(void) eina_stringshare_del(passwordstr); eina_stringshare_del(replacement_charstr); eina_stringshare_del(underline_dash_widthstr); + eina_stringshare_del(underline_dashed_widthstr); eina_stringshare_del(underline_dash_gapstr); + eina_stringshare_del(underline_dashed_gapstr); eina_stringshare_del(underline_heightstr); eina_stringshare_del(gfx_filterstr); } @@ -1722,266 +1750,226 @@ _format_clean_param(char *s) return len; } -/** - * @internal - * Parses the cmd and parameter and adds the parsed format to fmt. - * - * @param obj the evas object - should not be NULL. - * @param fmt The format to populate - should not be NULL. - * @param[in] cmd the command to process, should be stringshared. - * @param[in] param the parameter of the command. may modify the string. - */ static void -_format_command(Evas_Object *eo_obj, Evas_Object_Textblock_Format *fmt, const char *cmd, char *param) +_format_command_legacy_only(Evas_Object_Textblock_Format *fmt, const char *cmd, char *param, int len) { - int len; - - len = _format_clean_param(param); - - /* If we are changing the font, create the fdesc. */ - if ((cmd == font_weightstr) || (cmd == font_widthstr) || - (cmd == font_stylestr) || (cmd == langstr) || - (cmd == fontstr) || (cmd == font_fallbacksstr)) - { - if (!fmt->font.fdesc) - { - fmt->font.fdesc = evas_font_desc_new(); - - /* Set default language according to locale. */ - eina_stringshare_replace(&(fmt->font.fdesc->lang), - evas_font_lang_normalize("auto")); - } - else if (!fmt->font.fdesc->is_new) - { - Evas_Font_Description *old = fmt->font.fdesc; - fmt->font.fdesc = evas_font_desc_dup(fmt->font.fdesc); - if (old) evas_font_desc_unref(old); - } - } - - - if (cmd == fontstr) + if (cmd == backing_colorstr) + /** + * @page evas_textblock_style_page Evas Textblock Style Options + * + * @subsection evas_textblock_style_backing_color Backing Color + * + * Sets a background color for text. The following formats are + * accepted: + * @li "#RRGGBB" + * @li "#RRGGBBAA" + * @li "#RGB" + * @li "#RGBA" + * @li "rgb(r,g,b)" + * @li "rgba(r,g,b,a)" + * @li "color_name" like "red" + * @code + * backing_color=<color> + * @endcode + */ + evas_common_format_color_parse(param, len, + &(fmt->color.backing.r), &(fmt->color.backing.g), + &(fmt->color.backing.b), &(fmt->color.backing.a)); + else if (cmd == backingstr) { /** * @page evas_textblock_style_page Evas Textblock Style Options * - * @subsection evas_textblock_style_font Font + * @subsection evas_textblock_style_backing Backing * - * This sets the name of the font to be used. + * Sets if the text will have backing. The value must be one of + * the following: + * @li "off" - No backing + * @li "on" - Backing * @code - * font=<font name> + * backing=on/off * @endcode */ - evas_font_name_parse(fmt->font.fdesc, param); + if (len == 3 && !strcmp(param, "off")) + fmt->backing = 0; + else if (len == 2 && !strcmp(param, "on")) + fmt->backing = 1; } - else if (cmd == font_fallbacksstr) + else if (cmd == underline2_colorstr) + /** + * @page evas_textblock_style_page Evas Textblock Style Options + * + * @subsection evas_textblock_style_underline2_color Second Underline Color + * + * Sets the color of the second line of underline(when using underline + * mode "double"). The following formats are accepted: + * @li "#RRGGBB" + * @li "#RRGGBBAA" + * @li "#RGB" + * @li "#RGBA" + * @li "rgb(r,g,b)" + * @li "rgba(r,g,b,a)" + * @li "color_name" like "red" + * @code + * underline2_color=<color> + * @endcode + */ + evas_common_format_color_parse(param, len, + &(fmt->color.underline2.r), &(fmt->color.underline2.g), + &(fmt->color.underline2.b), &(fmt->color.underline2.a)); + else if (cmd == glow2_colorstr) + /** + * @page evas_textblock_style_page Evas Textblock Style Options + * + * @subsection evas_textblock_style_glow2_color Second Glow Color + * + * Sets the second color of the glow of text. The following formats are + * accepted: + * @li "#RRGGBB" + * @li "#RRGGBBAA" + * @li "#RGB" + * @li "#RGBA" + * @li "rgb(r,g,b)" + * @li "rgba(r,g,b,a)" + * @li "color_name" like "red" + * @code + * glow2_color=<color> + * @endcode + */ + evas_common_format_color_parse(param, len, + &(fmt->color.glow2.r), &(fmt->color.glow2.g), + &(fmt->color.glow2.b), &(fmt->color.glow2.a)); + else if (cmd == tabstopsstr) { /** * @page evas_textblock_style_page Evas Textblock Style Options * - * @subsection evas_textblock_style_font_fallback Font fallback + * @subsection evas_textblock_style_tabstops Tabstops * - * This sets the name of the fallback font to be used. This font will - * be used if the primary font is not available. + * Sets the size of the tab character. The value must be a number + * greater than one. * @code - * font_fallbacks=<font name> + * tabstops=<number> * @endcode */ - eina_stringshare_replace(&(fmt->font.fdesc->fallbacks), param); + fmt->tabstops = atoi(param); + if (fmt->tabstops < 1) fmt->tabstops = 1; } - else if (cmd == font_sizestr) + else if (cmd == linesizestr) { /** * @page evas_textblock_style_page Evas Textblock Style Options * - * @subsection evas_textblock_style_font_size Font size + * @subsection evas_textblock_style_linesize Line size * - * This sets the the size of font in points to be used. + * Sets the size of line of text. The value should be a number. + * @warning Setting this value sets linerelsize to 0%! * @code - * font_size=<size> + * linesize=<number> * @endcode */ - int v; - - v = atoi(param); - if (v != fmt->font.size) - { - fmt->font.size = v; - } + fmt->linesize = atoi(param); + fmt->linerelsize = 0.0; } - else if (cmd == font_sourcestr) + else if (cmd == linerelsizestr) { /** * @page evas_textblock_style_page Evas Textblock Style Options * - * @subsection evas_textblock_style_font_source Font source + * @subsection evas_textblock_style_linerelsize Relative line size * - * Specify an object from which to search for the font. + * Sets the relative size of line of text. The value must be a + * percentage. + * @warning Setting this value sets linesize to 0! * @code - * font_source=<source> + * linerelsize=<number>% * @endcode */ - if ((!fmt->font.source) || - ((fmt->font.source) && (strcmp(fmt->font.source, param)))) + char *endptr = NULL; + double val = strtod(param, &endptr); + if (endptr) { - eina_stringshare_replace(&(fmt->font.source), param); + while (*endptr && _is_white(*endptr)) + endptr++; + if (*endptr == '%') + { + fmt->linerelsize = val / 100.0; + fmt->linesize = 0; + if (fmt->linerelsize < 0.0) fmt->linerelsize = 0.0; + } } } - else if (cmd == font_weightstr) + else if (cmd == linegapstr) { /** * @page evas_textblock_style_page Evas Textblock Style Options * - * @subsection evas_textblock_style_font_weight Font weight + * @subsection evas_textblock_style_linegap Line gap * - * Sets the weight of the font. The value must be one of: - * @li "normal" - * @li "thin" - * @li "ultralight" - * @li "extralight" - * @li "light" - * @li "book" - * @li "medium" - * @li "semibold" - * @li "bold" - * @li "ultrabold" - * @li "extrabold" - * @li "black" - * @li "extrablack" + * Sets the size of the line gap in text. The value should be a + * number. + * @warning Setting this value sets linerelgap to 0%! * @code - * font_weight=<weight> + * linegap=<number> * @endcode */ - fmt->font.fdesc->weight = evas_font_style_find(param, - param + len, - EVAS_FONT_STYLE_WEIGHT); + fmt->linegap = atoi(param); + fmt->linerelgap = 0.0; } - else if (cmd == font_stylestr) + else if (cmd == linerelgapstr) { /** * @page evas_textblock_style_page Evas Textblock Style Options * - * @subsection evas_textblock_style_font_style Font style + * @subsection evas_textblock_style_linerelgap Relative line gap * - * Sets the style of the font. The value must be one of: - * @li "normal" - * @li "oblique" - * @li "italic" + * Sets the relative size of the line gap in text. The value must be + * a percentage. + * @warning Setting this value sets linegap to 0! * @code - * font_style=<style> + * linerelgap=<number>% * @endcode */ - fmt->font.fdesc->slant = evas_font_style_find(param, - param + len, - EVAS_FONT_STYLE_SLANT); + char *endptr = NULL; + double val = strtod(param, &endptr); + if (endptr) + { + while (*endptr && _is_white(*endptr)) + endptr++; + if (*endptr == '%') + { + fmt->linerelgap = val / 100.0; + fmt->linegap = 0; + if (fmt->linerelgap < 0.0) fmt->linerelgap = 0.0; + } + } } - else if (cmd == font_widthstr) + else if (cmd == linefillstr) { /** * @page evas_textblock_style_page Evas Textblock Style Options * - * @subsection evas_textblock_style_font_width Font width + * @subsection evas_textblock_style_linefill Line fill * - * Sets the width of the font. The value must be one of: - * @li "normal" - * @li "ultracondensed" - * @li "extracondensed" - * @li "condensed" - * @li "semicondensed" - * @li "semiexpanded" - * @li "expanded" - * @li "extraexpanded" - * @li "ultraexpanded" + * Sets the size of the line fill in text. The value must be a + * percentage. * @code - * font_width=<width> + * linefill=<number>% * @endcode */ - fmt->font.fdesc->width = evas_font_style_find(param, - param + len, - EVAS_FONT_STYLE_WIDTH); + char *endptr = NULL; + double val = strtod(param, &endptr); + if (endptr) + { + while (*endptr && _is_white(*endptr)) + endptr++; + if (*endptr == '%') + { + fmt->linefill = val / 100.0; + if (fmt->linefill < 0.0) fmt->linefill = 0.0; + } + } } - else if (cmd == langstr) - { - /** - * @page evas_textblock_style_page Evas Textblock Style Options - * - * @subsection evas_textblock_style_lang Language - * - * Sets the language of the text for FontConfig. - * The value can either be a language text or one of presets: - * @li "auto" - Respects system locale settings as language - * @li "none" - Disable language support - * @code - * lang=<language> - * @endcode - */ - eina_stringshare_replace(&(fmt->font.fdesc->lang), - evas_font_lang_normalize(param)); - } - else if (cmd == colorstr) - /** - * @page evas_textblock_style_page Evas Textblock Style Options - * - * @subsection evas_textblock_style_color Color - * - * Sets the color of the text. The following formats are accepted: - * @li "#RRGGBB" - * @li "#RRGGBBAA" - * @li "#RGB" - * @li "#RGBA" - * @li "rgb(r,g,b)" - * @li "rgba(r,g,b,a)" - * @li "color_name" like "red" - * @code - * color=<color> - * @endcode - */ - evas_common_format_color_parse(param, len, - &(fmt->color.normal.r), &(fmt->color.normal.g), - &(fmt->color.normal.b), &(fmt->color.normal.a)); - else if (cmd == underline_colorstr) - /** - * @page evas_textblock_style_page Evas Textblock Style Options - * - * @subsection evas_textblock_style_underline_color Underline Color - * - * Sets the color of the underline. The following formats are accepted: - * @li "#RRGGBB" - * @li "#RRGGBBAA" - * @li "#RGB" - * @li "#RGBA" - * @li "rgb(r,g,b)" - * @li "rgba(r,g,b,a)" - * @li "color_name" like "red" - * @code - * underline_color=<color> - * @endcode - */ - evas_common_format_color_parse(param, len, - &(fmt->color.underline.r), &(fmt->color.underline.g), - &(fmt->color.underline.b), &(fmt->color.underline.a)); - else if (cmd == underline2_colorstr || cmd == secondary_underline_colorstr) - /** - * @page evas_textblock_style_page Evas Textblock Style Options - * - * @subsection evas_textblock_style_underline2_color Second Underline Color - * - * Sets the color of the second line of underline(when using underline - * mode "double"). The following formats are accepted: - * @li "#RRGGBB" - * @li "#RRGGBBAA" - * @li "#RGB" - * @li "#RGBA" - * @li "rgb(r,g,b)" - * @li "rgba(r,g,b,a)" - * @li "color_name" like "red" - * @code - * underline2_color=<color> - * @endcode - */ - evas_common_format_color_parse(param, len, - &(fmt->color.underline2.r), &(fmt->color.underline2.g), - &(fmt->color.underline2.b), &(fmt->color.underline2.a)); else if (cmd == underline_dash_colorstr) /** * @page evas_textblock_style_page Evas Textblock Style Options @@ -2003,424 +1991,22 @@ _format_command(Evas_Object *eo_obj, Evas_Object_Textblock_Format *fmt, const ch evas_common_format_color_parse(param, len, &(fmt->color.underline_dash.r), &(fmt->color.underline_dash.g), &(fmt->color.underline_dash.b), &(fmt->color.underline_dash.a)); - else if (cmd == outline_colorstr) - /** - * @page evas_textblock_style_page Evas Textblock Style Options - * - * @subsection evas_textblock_style_outline_color Outline Color - * - * Sets the color of the outline of the text. The following formats are - * accepted: - * @li "#RRGGBB" - * @li "#RRGGBBAA" - * @li "#RGB" - * @li "#RGBA" - * @li "rgb(r,g,b)" - * @li "rgba(r,g,b,a)" - * @li "color_name" like "red" - * @code - * outline_color=<color> - * @endcode - */ - evas_common_format_color_parse(param, len, - &(fmt->color.outline.r), &(fmt->color.outline.g), - &(fmt->color.outline.b), &(fmt->color.outline.a)); - else if (cmd == shadow_colorstr) - /** - * @page evas_textblock_style_page Evas Textblock Style Options - * - * @subsection evas_textblock_style_shadow_color Shadow Color - * - * Sets the color of the shadow of the text. The following formats are - * accepted: - * @li "#RRGGBB" - * @li "#RRGGBBAA" - * @li "#RGB" - * @li "#RGBA" - * @li "rgb(r,g,b)" - * @li "rgba(r,g,b,a)" - * @li "color_name" like "red" - * @code - * shadow_color=<color> - * @endcode - */ - evas_common_format_color_parse(param, len, - &(fmt->color.shadow.r), &(fmt->color.shadow.g), - &(fmt->color.shadow.b), &(fmt->color.shadow.a)); - else if (cmd == glow_colorstr) - /** - * @page evas_textblock_style_page Evas Textblock Style Options - * - * @subsection evas_textblock_style_glow_color First Glow Color - * - * Sets the first color of the glow of text. The following formats are - * accepted: - * @li "#RRGGBB" - * @li "#RRGGBBAA" - * @li "#RGB" - * @li "#RGBA" - * @li "rgb(r,g,b)" - * @li "rgba(r,g,b,a)" - * @li "color_name" like "red" - * @code - * glow_color=<color> - * @endcode - */ - evas_common_format_color_parse(param, len, - &(fmt->color.glow.r), &(fmt->color.glow.g), - &(fmt->color.glow.b), &(fmt->color.glow.a)); - else if (cmd == glow2_colorstr || cmd == secondary_glow_colorstr) - /** - * @page evas_textblock_style_page Evas Textblock Style Options - * - * @subsection evas_textblock_style_glow2_color Second Glow Color - * - * Sets the second color of the glow of text. The following formats are - * accepted: - * @li "#RRGGBB" - * @li "#RRGGBBAA" - * @li "#RGB" - * @li "#RGBA" - * @li "rgb(r,g,b)" - * @li "rgba(r,g,b,a)" - * @li "color_name" like "red" - * @code - * glow2_color=<color> - * @endcode - */ - evas_common_format_color_parse(param, len, - &(fmt->color.glow2.r), &(fmt->color.glow2.g), - &(fmt->color.glow2.b), &(fmt->color.glow2.a)); - else if (cmd == backing_colorstr) - /** - * @page evas_textblock_style_page Evas Textblock Style Options - * - * @subsection evas_textblock_style_backing_color Backing Color - * - * Sets a background color for text. The following formats are - * accepted: - * @li "#RRGGBB" - * @li "#RRGGBBAA" - * @li "#RGB" - * @li "#RGBA" - * @li "rgb(r,g,b)" - * @li "rgba(r,g,b,a)" - * @li "color_name" like "red" - * @code - * backing_color=<color> - * @endcode - */ - evas_common_format_color_parse(param, len, - &(fmt->color.backing.r), &(fmt->color.backing.g), - &(fmt->color.backing.b), &(fmt->color.backing.a)); - else if (cmd == strikethrough_colorstr) - /** - * @page evas_textblock_style_page Evas Textblock Style Options - * - * @subsection evas_textblock_style_strikethrough_color Strikethrough Color - * - * Sets the color of text that is striked through. The following formats - * are accepted: - * @li "#RRGGBB" - * @li "#RRGGBBAA" - * @li "#RGB" - * @li "#RGBA" - * @li "rgb(r,g,b)" - * @li "rgba(r,g,b,a)" - * @li "color_name" like "red" - * @code - * strikethrough_color=<color> - * @endcode - */ - evas_common_format_color_parse(param, len, - &(fmt->color.strikethrough.r), &(fmt->color.strikethrough.g), - &(fmt->color.strikethrough.b), &(fmt->color.strikethrough.a)); - else if (cmd == alignstr) + else if (cmd == underlinestr) { /** * @page evas_textblock_style_page Evas Textblock Style Options * - * @subsection evas_textblock_style_align Horizontal Align + * @subsection evas_textblock_style_underline Underline * - * Sets the horizontal alignment of the text. The value can either be - * a number, a percentage or one of several presets: - * @li "auto" - Respects LTR/RTL settings - * @li "locale" - Respects locale(language) direction settings - * @li "center" - Centers the text in the line - * @li "middle" - Alias for "center" - * @li "left" - Puts the text at the left of the line - * @li "right" - Puts the text at the right of the line - * @li "start" - Respects LTR/RTL settings. It is same with "auto" - * @li "end" - Puts the text at the opposite side of LTR/RTL settings - * @li <number> - A number between 0.0 and 1.0 where 0.0 represents - * "left" and 1.0 represents "right" - * @li <number>% - A percentage between 0% and 100% where 0% - * represents "left" and 100% represents "right" + * Sets if and how a text will be underlined. The value must be one of + * the following: + * @li "off" - No underlining + * @li "single" - A single line under the text + * @li "on" - Alias for "single" + * @li "double" - Two lines under the text + * @li "dashed" - A dashed line under the text * @code - * align=<value or preset> - * @endcode - */ - if ((len == 4 && !strcmp(param, "auto")) || - (len == 5 && !strcmp(param, "start"))) - { - fmt->halign_auto = EVAS_TEXTBLOCK_ALIGN_AUTO_NORMAL; - } - else if (len == 3 && !strcmp(param, "end")) - { - fmt->halign_auto = EVAS_TEXTBLOCK_ALIGN_AUTO_END; - } - else if (len == 6 && !strcmp(param, "locale")) - { - fmt->halign_auto = EVAS_TEXTBLOCK_ALIGN_AUTO_LOCALE; - } - else - { - static const struct { - const char *param; - int len; - double halign; - } halign_named[] = { - { "middle", 6, 0.5 }, - { "center", 6, 0.5 }, - { "left", 4, 0.0 }, - { "right", 5, 1.0 }, - { NULL, 0, 0.0 } - }; - unsigned int i; - - for (i = 0; halign_named[i].param; i++) - if (len == halign_named[i].len && - !strcmp(param, halign_named[i].param)) - { - fmt->halign = halign_named[i].halign; - break; - } - - if (halign_named[i].param == NULL) - { - char *endptr = NULL; - double val = strtod(param, &endptr); - if (endptr) - { - while (*endptr && _is_white(*endptr)) - endptr++; - if (*endptr == '%') - val /= 100.0; - } - fmt->halign = val; - if (fmt->halign < 0.0) fmt->halign = 0.0; - else if (fmt->halign > 1.0) fmt->halign = 1.0; - } - fmt->halign_auto = EVAS_TEXTBLOCK_ALIGN_AUTO_NONE; - } - } - else if (cmd == valignstr) - { - /** - * @page evas_textblock_style_page Evas Textblock Style Options - * - * @subsection evas_textblock_style_valign Vertical Align - * - * Sets the vertical alignment of the text. The value can either be - * a number or one of the following presets: - * @li "top" - Puts text at the top of the line - * @li "center" - Centers the text in the line - * @li "middle" - Alias for "center" - * @li "bottom" - Puts the text at the bottom of the line - * @li "baseline" - Baseline - * @li "base" - Alias for "baseline" - * @li <number> - A number between 0.0 and 1.0 where 0.0 represents - * "top" and 1.0 represents "bottom" - * @li <number>% - A percentage between 0% and 100% where 0% - * represents "top" and 100% represents "bottom" - * @code - * valign=<value or preset> - * @endcode - * - * See explanation of baseline at: - * https://en.wikipedia.org/wiki/Baseline_%28typography%29 - */ - static const struct { - const char *param; - int len; - double valign; - } valign_named[] = { - { "top", 3, 0.0 }, - { "middle", 6, 0.5 }, - { "center", 6, 0.5 }, - { "bottom", 6, 1.0 }, - { "baseline", 8, -1.0 }, - { "base", 4, -1.0 }, - { NULL, 0, 0 } - }; - unsigned int i; - - for (i = 0; valign_named[i].param; i++) - if (len == valign_named[i].len && - !strcmp(valign_named[i].param, param)) - { - fmt->valign = valign_named[i].valign; - break; - } - - if (valign_named[i].param == NULL) - { - char *endptr = NULL; - double val = strtod(param, &endptr); - if (endptr) - { - while (*endptr && _is_white(*endptr)) - endptr++; - if (*endptr == '%') - val /= 100.0; - } - fmt->valign = val; - if (fmt->valign < 0.0) fmt->valign = 0.0; - else if (fmt->valign > 1.0) fmt->valign = 1.0; - } - } - else if (cmd == text_valignstr) - { - Efl_Canvas_Textblock_Data *o = efl_data_scope_get(eo_obj, MY_CLASS); - char *endptr = NULL; - double val = strtod(param, &endptr); - o->valign = val; - if (o->valign < 0.0) o->valign = 0.0; - else if (o->valign > 1.0) o->valign = 1.0; - } - else if (cmd == wrapstr) - { - /** - * @page evas_textblock_style_page Evas Textblock Style Options - * - * @subsection evas_textblock_style_wrap Wrap - * - * Sets the wrap policy of the text. The value must be one of the - * following: - * @li "word" - Only wraps lines at word boundaries - * @li "char" - Wraps at any character - * @li "mixed" - Wrap at words if possible, if not at any character - * @li "hyphenation" - Hyphenate if possible, if not wrap at words if possible, if not at any character - * @li "" - Don't wrap - * @code - * wrap=<value or preset> - * @endcode - */ - static const struct { - const char *param; - int len; - Eina_Bool wrap_word; - Eina_Bool wrap_char; - Eina_Bool wrap_mixed; - Eina_Bool wrap_hyphenation; - } wrap_named[] = { - { "word", 4, 1, 0, 0, 0 }, - { "char", 4, 0, 1, 0, 0 }, - { "mixed", 5, 0, 0, 1, 0 }, - { "hyphenation", 11, 0, 0, 0, 1 }, - { NULL, 0, 0, 0, 0, 0 } - }; - unsigned int i; - - fmt->wrap_word = fmt->wrap_mixed = fmt->wrap_char = - fmt->wrap_hyphenation = 0; - for (i = 0; wrap_named[i].param; i++) - if (wrap_named[i].len == len && - !strcmp(wrap_named[i].param, param)) - { - fmt->wrap_word = wrap_named[i].wrap_word; - fmt->wrap_char = wrap_named[i].wrap_char; - fmt->wrap_mixed = wrap_named[i].wrap_mixed; - fmt->wrap_hyphenation = wrap_named[i].wrap_hyphenation; - break; - } - -#ifdef HAVE_HYPHEN - /* Hyphenating textblocks are registered as "clients", so we load/unload - * the hyphenation dictionaries on-demand. */ - if (fmt->wrap_hyphenation) - { - _dicts_hyphen_init(eo_obj); - } -#endif - - } - else if (cmd == left_marginstr) - { - /** - * @page evas_textblock_style_page Evas Textblock Style Options - * - * @subsection evas_textblock_style_left_margin Left margin - * - * Sets the left margin of the text. The value can be a number, an - * increment, decrement or "reset": - * @li +<number> - Increments existing left margin by <number> - * @li -<number> - Decrements existing left margin by <number> - * @li <number> - Sets left margin to <number> - * @li "reset" - Sets left margin to 0 - * @code - * left_margin=<value or reset> - * @endcode - */ - if (len == 5 && !strcmp(param, "reset")) - fmt->margin.l = 0; - else - { - if (param[0] == '+') - fmt->margin.l += atoi(&(param[1])); - else if (param[0] == '-') - fmt->margin.l -= atoi(&(param[1])); - else - fmt->margin.l = atoi(param); - if (fmt->margin.l < 0) fmt->margin.l = 0; - } - } - else if (cmd == right_marginstr) - { - /** - * @page evas_textblock_style_page Evas Textblock Style Options - * - * @subsection evas_textblock_style_right_margin Right margin - * - * Sets the right margin of the text. The value can be a number, an - * increment, decrement or "reset": - * @li +<number> - Increments existing right margin by <number> - * @li -<number> - Decrements existing right margin by <number> - * @li <number> - Sets left margin to <number> - * @li "reset" - Sets left margin to 0 - * @code - * right_margin=<value or reset> - * @endcode - */ - if (len == 5 && !strcmp(param, "reset")) - fmt->margin.r = 0; - else - { - if (param[0] == '+') - fmt->margin.r += atoi(&(param[1])); - else if (param[0] == '-') - fmt->margin.r -= atoi(&(param[1])); - else - fmt->margin.r = atoi(param); - if (fmt->margin.r < 0) fmt->margin.r = 0; - } - } - else if (cmd == underlinestr) - { - /** - * @page evas_textblock_style_page Evas Textblock Style Options - * - * @subsection evas_textblock_style_underline Underline - * - * Sets if and how a text will be underlined. The value must be one of - * the following: - * @li "off" - No underlining - * @li "single" - A single line under the text - * @li "on" - Alias for "single" - * @li "double" - Two lines under the text - * @li "dashed" - A dashed line under the text - * @code - * underline=off/single/on/double/dashed + * underline=off/single/on/double/dashed * @endcode */ static const struct { @@ -2470,32 +2056,12 @@ _format_command(Evas_Object *eo_obj, Evas_Object_Textblock_Format *fmt, const ch else if (len == 2 && !strcmp(param, "on")) fmt->strikethrough = 1; } - else if (cmd == backingstr) + else if (cmd == stylestr) { /** * @page evas_textblock_style_page Evas Textblock Style Options * - * @subsection evas_textblock_style_backing Backing - * - * Sets if the text will have backing. The value must be one of - * the following: - * @li "off" - No backing - * @li "on" - Backing - * @code - * backing=on/off - * @endcode - */ - if (len == 3 && !strcmp(param, "off")) - fmt->backing = 0; - else if (len == 2 && !strcmp(param, "on")) - fmt->backing = 1; - } - else if (cmd == stylestr) - { - /** - * @page evas_textblock_style_page Evas Textblock Style Options - * - * @subsection evas_textblock_style_style Style + * @subsection evas_textblock_style_style Style * * Sets the style of the text. The value must be a string composed of * two comma separated parts. The first part of the value sets the @@ -2542,151 +2108,797 @@ _format_command(Evas_Object *eo_obj, Evas_Object_Textblock_Format *fmt, const ch if (*part2) _format_shadow_direction_set(fmt, part2, EINA_FALSE, NULL); } - else if (cmd == tabstopsstr || cmd == tab_stopsstr) + else if (cmd == underline_dash_widthstr) { /** * @page evas_textblock_style_page Evas Textblock Style Options * - * @subsection evas_textblock_style_tabstops Tabstops + * @subsection evas_textblock_style_underline_dash_width Underline dash width * - * Sets the size of the tab character. The value must be a number - * greater than one. + * Sets the width of the underline dash. The value should be a number. * @code - * tabstops=<number> + * underline_dash_width=<number> * @endcode */ - fmt->tabstops = atoi(param); - if (fmt->tabstops < 1) fmt->tabstops = 1; + fmt->underline_dash_width = atoi(param); + if (fmt->underline_dash_width <= 0) fmt->underline_dash_width = 1; } - else if (cmd == linesizestr || cmd == line_sizestr) + else if (cmd == underline_dash_gapstr) { /** * @page evas_textblock_style_page Evas Textblock Style Options * - * @subsection evas_textblock_style_linesize Line size + * @subsection evas_textblock_style_underline_dash_gap Underline dash gap * - * Sets the size of line of text. The value should be a number. - * @warning Setting this value sets linerelsize to 0%! + * Sets the gap of the underline dash. The value should be a number. * @code - * linesize=<number> + * underline_dash_gap=<number> * @endcode */ + fmt->underline_dash_gap = atoi(param); + if (fmt->underline_dash_gap <= 0) fmt->underline_dash_gap = 1; + } +} + +static void +_format_command_unified_only( Efl_Canvas_Textblock_Data *o, Evas_Object_Textblock_Format *fmt, const char *cmd, char *param, int len) +{ + if (cmd == background_colorstr) + evas_common_format_color_parse(param, len, + &(fmt->color.backing.r), &(fmt->color.backing.g), + &(fmt->color.backing.b), &(fmt->color.backing.a)); + else if (cmd == background_typestr) + { + if (len == 4 && !strcmp(param, "none")) + fmt->backing = 0; + else if (len == 5 && !strcmp(param, "solid")) + fmt->backing = 1; + } + else if (cmd == secondary_underline_colorstr) + evas_common_format_color_parse(param, len, + &(fmt->color.underline2.r), &(fmt->color.underline2.g), + &(fmt->color.underline2.b), &(fmt->color.underline2.a)); + else if (cmd == secondary_glow_colorstr) + evas_common_format_color_parse(param, len, + &(fmt->color.glow2.r), &(fmt->color.glow2.g), + &(fmt->color.glow2.b), &(fmt->color.glow2.a)); + else if (cmd == tab_stopsstr) + { + fmt->tabstops = atoi(param); + if (fmt->tabstops < 1) fmt->tabstops = 1; + } + else if (cmd == line_sizestr) + { fmt->linesize = atoi(param); fmt->linerelsize = 0.0; } - else if (cmd == linerelsizestr || cmd == line_rel_sizestr) + else if (cmd == line_rel_sizestr) + { + char *endptr = NULL; + double val = strtod(param, &endptr); + if (endptr) + { + while (*endptr && _is_white(*endptr)) + endptr++; + if (*endptr == '%') + { + fmt->linerelsize = val / 100.0; + fmt->linesize = 0; + if (fmt->linerelsize < 0.0) fmt->linerelsize = 0.0; + } + } + } + else if (cmd == line_gapstr) + { + fmt->linegap = atoi(param); + fmt->linerelgap = 0.0; + } + else if (cmd == line_rel_gapstr) + { + char *endptr = NULL; + double val = strtod(param, &endptr); + if (endptr) + { + while (*endptr && _is_white(*endptr)) + endptr++; + if (*endptr == '%') + { + fmt->linerelgap = val / 100.0; + fmt->linegap = 0; + if (fmt->linerelgap < 0.0) fmt->linerelgap = 0.0; + } + } + } + else if (cmd == line_fillstr) + { + char *endptr = NULL; + double val = strtod(param, &endptr); + if (endptr) + { + while (*endptr && _is_white(*endptr)) + endptr++; + if (*endptr == '%') + { + fmt->linefill = val / 100.0; + if (fmt->linefill < 0.0) fmt->linefill = 0.0; + } + } + } + else if (cmd == underline_dashed_colorstr) + evas_common_format_color_parse(param, len, + &(fmt->color.underline_dash.r), &(fmt->color.underline_dash.g), + &(fmt->color.underline_dash.b), &(fmt->color.underline_dash.a)); + else if (cmd == underline_typestr) + { + typedef struct { + const char *param; + int len; + Eina_Bool underline; + Eina_Bool underline2; + Eina_Bool underline_dash; + } Underline_Info; + + fmt->underline = fmt->underline2 = fmt->underline_dash = 0; + unsigned int i; + #define SET_UNDERLINE_VALUES() \ + for (i = 0; underlines_named[i].param; ++i) { \ + if (underlines_named[i].len == len && \ + !strcmp(underlines_named[i].param, param)) \ + { \ + fmt->underline = underlines_named[i].underline; \ + fmt->underline2 = underlines_named[i].underline2; \ + fmt->underline_dash = underlines_named[i].underline_dash; \ + break;\ + } \ + } + static Underline_Info underlines_named[] = { + { "none", 4, 0, 0, 0 }, + { "single", 6, 1, 0, 0 }, + { "double", 6, 1, 1, 0 }, + { "dashed", 6, 0, 0, 1 }, + { NULL, 0, 0, 0, 0 } + }; + SET_UNDERLINE_VALUES(); + } + else if (cmd == strikethrough_typestr) + { + if (len == 4 && !strcmp(param, "none")) + fmt->strikethrough = 0; + else if (len == 6 && !strcmp(param, "single")) + fmt->strikethrough = 1; + } + else if (cmd == effect_typestr) + { + _format_shadow_set(fmt, param, EINA_TRUE, o); + } + else if (cmd == shadow_directionstr) + { + _format_shadow_direction_set(fmt, param, EINA_TRUE, o); + } + else if (cmd == underline_dashed_widthstr) + { + fmt->underline_dash_width = atoi(param); + if (fmt->underline_dash_width <= 0) fmt->underline_dash_width = 1; + } + else if (cmd == underline_dashed_gapstr) + { + fmt->underline_dash_gap = atoi(param); + if (fmt->underline_dash_gap <= 0) fmt->underline_dash_gap = 1; + } +} + +/** + * @internal + * Parses the cmd and parameter and adds the parsed format to fmt. + * + * @param obj the evas object - should not be NULL. + * @param fmt The format to populate - should not be NULL. + * @param[in] cmd the command to process, should be stringshared. + * @param[in] param the parameter of the command. may modify the string. + */ +static void +_format_command(Evas_Object *eo_obj, Evas_Object_Textblock_Format *fmt, const char *cmd, char *param) +{ + int len; + Efl_Canvas_Textblock_Data *o = efl_data_scope_get(eo_obj, MY_CLASS); + Eina_Bool is_legacy = o->is_legacy; + + len = _format_clean_param(param); + + /* If we are changing the font, create the fdesc. */ + if ((cmd == font_weightstr) || (cmd == font_widthstr) || + (cmd == font_stylestr) || (cmd == langstr) || + (cmd == fontstr) || (cmd == font_fallbacksstr)) + { + if (!fmt->font.fdesc) + { + fmt->font.fdesc = evas_font_desc_new(); + + /* Set default language according to locale. */ + eina_stringshare_replace(&(fmt->font.fdesc->lang), + evas_font_lang_normalize("auto")); + } + else if (!fmt->font.fdesc->is_new) + { + Evas_Font_Description *old = fmt->font.fdesc; + fmt->font.fdesc = evas_font_desc_dup(fmt->font.fdesc); + if (old) evas_font_desc_unref(old); + } + } + + + if (cmd == fontstr) + { + /** + * @page evas_textblock_style_page Evas Textblock Style Options + * + * @subsection evas_textblock_style_font Font + * + * This sets the name of the font to be used. + * @code + * font=<font name> + * @endcode + */ + evas_font_name_parse(fmt->font.fdesc, param); + } + else if (cmd == font_fallbacksstr) + { + /** + * @page evas_textblock_style_page Evas Textblock Style Options + * + * @subsection evas_textblock_style_font_fallback Font fallback + * + * This sets the name of the fallback font to be used. This font will + * be used if the primary font is not available. + * @code + * font_fallbacks=<font name> + * @endcode + */ + eina_stringshare_replace(&(fmt->font.fdesc->fallbacks), param); + } + else if (cmd == font_sizestr) + { + /** + * @page evas_textblock_style_page Evas Textblock Style Options + * + * @subsection evas_textblock_style_font_size Font size + * + * This sets the the size of font in points to be used. + * @code + * font_size=<size> + * @endcode + */ + int v; + + v = atoi(param); + if (v != fmt->font.size) + { + fmt->font.size = v; + } + } + else if (cmd == font_sourcestr) + { + /** + * @page evas_textblock_style_page Evas Textblock Style Options + * + * @subsection evas_textblock_style_font_source Font source + * + * Specify an object from which to search for the font. + * @code + * font_source=<source> + * @endcode + */ + if ((!fmt->font.source) || + ((fmt->font.source) && (strcmp(fmt->font.source, param)))) + { + eina_stringshare_replace(&(fmt->font.source), param); + } + } + else if (cmd == font_weightstr) + { + /** + * @page evas_textblock_style_page Evas Textblock Style Options + * + * @subsection evas_textblock_style_font_weight Font weight + * + * Sets the weight of the font. The value must be one of: + * @li "normal" + * @li "thin" + * @li "ultralight" + * @li "extralight" + * @li "light" + * @li "book" + * @li "medium" + * @li "semibold" + * @li "bold" + * @li "ultrabold" + * @li "extrabold" + * @li "black" + * @li "extrablack" + * @code + * font_weight=<weight> + * @endcode + */ + fmt->font.fdesc->weight = evas_font_style_find(param, + param + len, + EVAS_FONT_STYLE_WEIGHT); + } + else if (cmd == font_stylestr) + { + /** + * @page evas_textblock_style_page Evas Textblock Style Options + * + * @subsection evas_textblock_style_font_style Font style + * + * Sets the style of the font. The value must be one of: + * @li "normal" + * @li "oblique" + * @li "italic" + * @code + * font_style=<style> + * @endcode + */ + fmt->font.fdesc->slant = evas_font_style_find(param, + param + len, + EVAS_FONT_STYLE_SLANT); + } + else if (cmd == font_widthstr) + { + /** + * @page evas_textblock_style_page Evas Textblock Style Options + * + * @subsection evas_textblock_style_font_width Font width + * + * Sets the width of the font. The value must be one of: + * @li "normal" + * @li "ultracondensed" + * @li "extracondensed" + * @li "condensed" + * @li "semicondensed" + * @li "semiexpanded" + * @li "expanded" + * @li "extraexpanded" + * @li "ultraexpanded" + * @code + * font_width=<width> + * @endcode + */ + fmt->font.fdesc->width = evas_font_style_find(param, + param + len, + EVAS_FONT_STYLE_WIDTH); + } + else if (cmd == langstr) + { + /** + * @page evas_textblock_style_page Evas Textblock Style Options + * + * @subsection evas_textblock_style_lang Language + * + * Sets the language of the text for FontConfig. + * The value can either be a language text or one of presets: + * @li "auto" - Respects system locale settings as language + * @li "none" - Disable language support + * @code + * lang=<language> + * @endcode + */ + eina_stringshare_replace(&(fmt->font.fdesc->lang), + evas_font_lang_normalize(param)); + } + else if (cmd == colorstr) + /** + * @page evas_textblock_style_page Evas Textblock Style Options + * + * @subsection evas_textblock_style_color Color + * + * Sets the color of the text. The following formats are accepted: + * @li "#RRGGBB" + * @li "#RRGGBBAA" + * @li "#RGB" + * @li "#RGBA" + * @li "rgb(r,g,b)" + * @li "rgba(r,g,b,a)" + * @li "color_name" like "red" + * @code + * color=<color> + * @endcode + */ + evas_common_format_color_parse(param, len, + &(fmt->color.normal.r), &(fmt->color.normal.g), + &(fmt->color.normal.b), &(fmt->color.normal.a)); + else if (cmd == underline_colorstr) + /** + * @page evas_textblock_style_page Evas Textblock Style Options + * + * @subsection evas_textblock_style_underline_color Underline Color + * + * Sets the color of the underline. The following formats are accepted: + * @li "#RRGGBB" + * @li "#RRGGBBAA" + * @li "#RGB" + * @li "#RGBA" + * @li "rgb(r,g,b)" + * @li "rgba(r,g,b,a)" + * @li "color_name" like "red" + * @code + * underline_color=<color> + * @endcode + */ + evas_common_format_color_parse(param, len, + &(fmt->color.underline.r), &(fmt->color.underline.g), + &(fmt->color.underline.b), &(fmt->color.underline.a)); + else if (cmd == outline_colorstr) + /** + * @page evas_textblock_style_page Evas Textblock Style Options + * + * @subsection evas_textblock_style_outline_color Outline Color + * + * Sets the color of the outline of the text. The following formats are + * accepted: + * @li "#RRGGBB" + * @li "#RRGGBBAA" + * @li "#RGB" + * @li "#RGBA" + * @li "rgb(r,g,b)" + * @li "rgba(r,g,b,a)" + * @li "color_name" like "red" + * @code + * outline_color=<color> + * @endcode + */ + evas_common_format_color_parse(param, len, + &(fmt->color.outline.r), &(fmt->color.outline.g), + &(fmt->color.outline.b), &(fmt->color.outline.a)); + else if (cmd == shadow_colorstr) + /** + * @page evas_textblock_style_page Evas Textblock Style Options + * + * @subsection evas_textblock_style_shadow_color Shadow Color + * + * Sets the color of the shadow of the text. The following formats are + * accepted: + * @li "#RRGGBB" + * @li "#RRGGBBAA" + * @li "#RGB" + * @li "#RGBA" + * @li "rgb(r,g,b)" + * @li "rgba(r,g,b,a)" + * @li "color_name" like "red" + * @code + * shadow_color=<color> + * @endcode + */ + evas_common_format_color_parse(param, len, + &(fmt->color.shadow.r), &(fmt->color.shadow.g), + &(fmt->color.shadow.b), &(fmt->color.shadow.a)); + else if (cmd == glow_colorstr) + /** + * @page evas_textblock_style_page Evas Textblock Style Options + * + * @subsection evas_textblock_style_glow_color First Glow Color + * + * Sets the first color of the glow of text. The following formats are + * accepted: + * @li "#RRGGBB" + * @li "#RRGGBBAA" + * @li "#RGB" + * @li "#RGBA" + * @li "rgb(r,g,b)" + * @li "rgba(r,g,b,a)" + * @li "color_name" like "red" + * @code + * glow_color=<color> + * @endcode + */ + evas_common_format_color_parse(param, len, + &(fmt->color.glow.r), &(fmt->color.glow.g), + &(fmt->color.glow.b), &(fmt->color.glow.a)); + else if (cmd == strikethrough_colorstr) + /** + * @page evas_textblock_style_page Evas Textblock Style Options + * + * @subsection evas_textblock_style_strikethrough_color Strikethrough Color + * + * Sets the color of text that is striked through. The following formats + * are accepted: + * @li "#RRGGBB" + * @li "#RRGGBBAA" + * @li "#RGB" + * @li "#RGBA" + * @li "rgb(r,g,b)" + * @li "rgba(r,g,b,a)" + * @li "color_name" like "red" + * @code + * strikethrough_color=<color> + * @endcode + */ + evas_common_format_color_parse(param, len, + &(fmt->color.strikethrough.r), &(fmt->color.strikethrough.g), + &(fmt->color.strikethrough.b), &(fmt->color.strikethrough.a)); + else if (cmd == alignstr) + { + /** + * @page evas_textblock_style_page Evas Textblock Style Options + * + * @subsection evas_textblock_style_align Horizontal Align + * + * Sets the horizontal alignment of the text. The value can either be + * a number, a percentage or one of several presets: + * @li "auto" - Respects LTR/RTL settings + * @li "locale" - Respects locale(language) direction settings + * @li "center" - Centers the text in the line + * @li "middle" - Alias for "center" + * @li "left" - Puts the text at the left of the line + * @li "right" - Puts the text at the right of the line + * @li "start" - Respects LTR/RTL settings. It is same with "auto" + * @li "end" - Puts the text at the opposite side of LTR/RTL settings + * @li <number> - A number between 0.0 and 1.0 where 0.0 represents + * "left" and 1.0 represents "right" + * @li <number>% - A percentage between 0% and 100% where 0% + * represents "left" and 100% represents "right" + * @code + * align=<value or preset> + * @endcode + */ + if ((len == 4 && !strcmp(param, "auto")) || + (len == 5 && !strcmp(param, "start"))) + { + fmt->halign_auto = EVAS_TEXTBLOCK_ALIGN_AUTO_NORMAL; + } + else if (len == 3 && !strcmp(param, "end")) + { + fmt->halign_auto = EVAS_TEXTBLOCK_ALIGN_AUTO_END; + } + else if (len == 6 && !strcmp(param, "locale")) + { + fmt->halign_auto = EVAS_TEXTBLOCK_ALIGN_AUTO_LOCALE; + } + else + { + static const struct { + const char *param; + int len; + double halign; + } halign_named[] = { + { "middle", 6, 0.5 }, + { "center", 6, 0.5 }, + { "left", 4, 0.0 }, + { "right", 5, 1.0 }, + { NULL, 0, 0.0 } + }; + unsigned int i; + + for (i = 0; halign_named[i].param; i++) + if (len == halign_named[i].len && + !strcmp(param, halign_named[i].param)) + { + fmt->halign = halign_named[i].halign; + break; + } + + if (halign_named[i].param == NULL) + { + char *endptr = NULL; + double val = strtod(param, &endptr); + if (endptr) + { + while (*endptr && _is_white(*endptr)) + endptr++; + if (*endptr == '%') + val /= 100.0; + } + fmt->halign = val; + if (fmt->halign < 0.0) fmt->halign = 0.0; + else if (fmt->halign > 1.0) fmt->halign = 1.0; + } + fmt->halign_auto = EVAS_TEXTBLOCK_ALIGN_AUTO_NONE; + } + } + else if (cmd == valignstr) { /** * @page evas_textblock_style_page Evas Textblock Style Options * - * @subsection evas_textblock_style_linerelsize Relative line size + * @subsection evas_textblock_style_valign Vertical Align * - * Sets the relative size of line of text. The value must be a - * percentage. - * @warning Setting this value sets linesize to 0! + * Sets the vertical alignment of the text. The value can either be + * a number or one of the following presets: + * @li "top" - Puts text at the top of the line + * @li "center" - Centers the text in the line + * @li "middle" - Alias for "center" + * @li "bottom" - Puts the text at the bottom of the line + * @li "baseline" - Baseline + * @li "base" - Alias for "baseline" + * @li <number> - A number between 0.0 and 1.0 where 0.0 represents + * "top" and 1.0 represents "bottom" + * @li <number>% - A percentage between 0% and 100% where 0% + * represents "top" and 100% represents "bottom" * @code - * linerelsize=<number>% + * valign=<value or preset> * @endcode + * + * See explanation of baseline at: + * https://en.wikipedia.org/wiki/Baseline_%28typography%29 */ - char *endptr = NULL; - double val = strtod(param, &endptr); - if (endptr) + static const struct { + const char *param; + int len; + double valign; + } valign_named[] = { + { "top", 3, 0.0 }, + { "middle", 6, 0.5 }, + { "center", 6, 0.5 }, + { "bottom", 6, 1.0 }, + { "baseline", 8, -1.0 }, + { "base", 4, -1.0 }, + { NULL, 0, 0 } + }; + unsigned int i; + + for (i = 0; valign_named[i].param; i++) + if (len == valign_named[i].len && + !strcmp(valign_named[i].param, param)) + { + fmt->valign = valign_named[i].valign; + break; + } + + if (valign_named[i].param == NULL) { - while (*endptr && _is_white(*endptr)) - endptr++; - if (*endptr == '%') + char *endptr = NULL; + double val = strtod(param, &endptr); + if (endptr) { - fmt->linerelsize = val / 100.0; - fmt->linesize = 0; - if (fmt->linerelsize < 0.0) fmt->linerelsize = 0.0; + while (*endptr && _is_white(*endptr)) + endptr++; + if (*endptr == '%') + val /= 100.0; } + fmt->valign = val; + if (fmt->valign < 0.0) fmt->valign = 0.0; + else if (fmt->valign > 1.0) fmt->valign = 1.0; } } - else if (cmd == linegapstr || cmd == line_gapstr) + else if (cmd == text_valignstr) + { + Efl_Canvas_Textblock_Data *o = efl_data_scope_get(eo_obj, MY_CLASS); + char *endptr = NULL; + double val = strtod(param, &endptr); + o->valign = val; + if (o->valign < 0.0) o->valign = 0.0; + else if (o->valign > 1.0) o->valign = 1.0; + } + else if (cmd == wrapstr) { /** * @page evas_textblock_style_page Evas Textblock Style Options * - * @subsection evas_textblock_style_linegap Line gap + * @subsection evas_textblock_style_wrap Wrap * - * Sets the size of the line gap in text. The value should be a - * number. - * @warning Setting this value sets linerelgap to 0%! + * Sets the wrap policy of the text. The value must be one of the + * following: + * @li "word" - Only wraps lines at word boundaries + * @li "char" - Wraps at any character + * @li "mixed" - Wrap at words if possible, if not at any character + * @li "hyphenation" - Hyphenate if possible, if not wrap at words if possible, if not at any character + * @li "" - Don't wrap * @code - * linegap=<number> + * wrap=<value or preset> * @endcode */ - fmt->linegap = atoi(param); - fmt->linerelgap = 0.0; + static const struct { + const char *param; + int len; + Eina_Bool wrap_word; + Eina_Bool wrap_char; + Eina_Bool wrap_mixed; + Eina_Bool wrap_hyphenation; + } wrap_named[] = { + { "word", 4, 1, 0, 0, 0 }, + { "char", 4, 0, 1, 0, 0 }, + { "mixed", 5, 0, 0, 1, 0 }, + { "hyphenation", 11, 0, 0, 0, 1 }, + { NULL, 0, 0, 0, 0, 0 } + }; + unsigned int i; + + fmt->wrap_word = fmt->wrap_mixed = fmt->wrap_char = + fmt->wrap_hyphenation = 0; + for (i = 0; wrap_named[i].param; i++) + if (wrap_named[i].len == len && + !strcmp(wrap_named[i].param, param)) + { + fmt->wrap_word = wrap_named[i].wrap_word; + fmt->wrap_char = wrap_named[i].wrap_char; + fmt->wrap_mixed = wrap_named[i].wrap_mixed; + fmt->wrap_hyphenation = wrap_named[i].wrap_hyphenation; + break; + } + +#ifdef HAVE_HYPHEN + /* Hyphenating textblocks are registered as "clients", so we load/unload + * the hyphenation dictionaries on-demand. */ + if (fmt->wrap_hyphenation) + { + _dicts_hyphen_init(eo_obj); + } +#endif + } - else if (cmd == linerelgapstr || cmd == line_rel_gapstr) + else if (cmd == left_marginstr) { /** * @page evas_textblock_style_page Evas Textblock Style Options * - * @subsection evas_textblock_style_linerelgap Relative line gap + * @subsection evas_textblock_style_left_margin Left margin * - * Sets the relative size of the line gap in text. The value must be - * a percentage. - * @warning Setting this value sets linegap to 0! + * Sets the left margin of the text. The value can be a number, an + * increment, decrement or "reset": + * @li +<number> - Increments existing left margin by <number> + * @li -<number> - Decrements existing left margin by <number> + * @li <number> - Sets left margin to <number> + * @li "reset" - Sets left margin to 0 * @code - * linerelgap=<number>% + * left_margin=<value or reset> * @endcode */ - char *endptr = NULL; - double val = strtod(param, &endptr); - if (endptr) + if (len == 5 && !strcmp(param, "reset")) + fmt->margin.l = 0; + else { - while (*endptr && _is_white(*endptr)) - endptr++; - if (*endptr == '%') - { - fmt->linerelgap = val / 100.0; - fmt->linegap = 0; - if (fmt->linerelgap < 0.0) fmt->linerelgap = 0.0; - } + if (param[0] == '+') + fmt->margin.l += atoi(&(param[1])); + else if (param[0] == '-') + fmt->margin.l -= atoi(&(param[1])); + else + fmt->margin.l = atoi(param); + if (fmt->margin.l < 0) fmt->margin.l = 0; } } - else if (cmd == itemstr) + else if (cmd == right_marginstr) { /** * @page evas_textblock_style_page Evas Textblock Style Options * - * @subsection evas_textblock_style_item Item + * @subsection evas_textblock_style_right_margin Right margin * - * Not implemented! Does nothing! + * Sets the right margin of the text. The value can be a number, an + * increment, decrement or "reset": + * @li +<number> - Increments existing right margin by <number> + * @li -<number> - Decrements existing right margin by <number> + * @li <number> - Sets left margin to <number> + * @li "reset" - Sets left margin to 0 * @code - * item=<anything> + * right_margin=<value or reset> * @endcode */ - // itemstr == replacement object items in textblock - inline imges - // for example + if (len == 5 && !strcmp(param, "reset")) + fmt->margin.r = 0; + else + { + if (param[0] == '+') + fmt->margin.r += atoi(&(param[1])); + else if (param[0] == '-') + fmt->margin.r -= atoi(&(param[1])); + else + fmt->margin.r = atoi(param); + if (fmt->margin.r < 0) fmt->margin.r = 0; + } } - else if (cmd == linefillstr || cmd == line_fillstr) + else if (cmd == itemstr) { /** * @page evas_textblock_style_page Evas Textblock Style Options * - * @subsection evas_textblock_style_linefill Line fill + * @subsection evas_textblock_style_item Item * - * Sets the size of the line fill in text. The value must be a - * percentage. + * Not implemented! Does nothing! * @code - * linefill=<number>% + * item=<anything> * @endcode */ - char *endptr = NULL; - double val = strtod(param, &endptr); - if (endptr) - { - while (*endptr && _is_white(*endptr)) - endptr++; - if (*endptr == '%') - { - fmt->linefill = val / 100.0; - if (fmt->linefill < 0.0) fmt->linefill = 0.0; - } - } + // itemstr == replacement object items in textblock - inline imges + // for example } else if (cmd == ellipsisstr) { @@ -2739,36 +2951,6 @@ _format_command(Evas_Object *eo_obj, Evas_Object_Textblock_Format *fmt, const ch Efl_Canvas_Textblock_Data *o = efl_data_scope_get(eo_obj, MY_CLASS); eina_stringshare_replace(&o->repch, param); } - else if (cmd == underline_dash_widthstr) - { - /** - * @page evas_textblock_style_page Evas Textblock Style Options - * - * @subsection evas_textblock_style_underline_dash_width Underline dash width - * - * Sets the width of the underline dash. The value should be a number. - * @code - * underline_dash_width=<number> - * @endcode - */ - fmt->underline_dash_width = atoi(param); - if (fmt->underline_dash_width <= 0) fmt->underline_dash_width = 1; - } - else if (cmd == underline_dash_gapstr) - { - /** - * @page evas_textblock_style_page Evas Textblock Style Options - * - * @subsection evas_textblock_style_underline_dash_gap Underline dash gap - * - * Sets the gap of the underline dash. The value should be a number. - * @code - * underline_dash_gap=<number> - * @endcode - */ - fmt->underline_dash_gap = atoi(param); - if (fmt->underline_dash_gap <= 0) fmt->underline_dash_gap = 1; - } else if (cmd == underline_heightstr) { /** @@ -2800,6 +2982,18 @@ _format_command(Evas_Object *eo_obj, Evas_Object_Textblock_Format *fmt, const ch fmt->gfx_filter = calloc(1, sizeof(Efl_Canvas_Textblock_Filter)); eina_stringshare_replace(&fmt->gfx_filter->name, param); } + else + { + if (is_legacy) + { + _format_command_legacy_only(fmt, cmd, param, len); + } + else + { + _format_command_unified_only(o, fmt, cmd, param, len); + } + + } } //FIXME Create common function for both _default _format_command & _format_command @@ -3350,7 +3544,7 @@ _format_string_get(const Eo *eo_obj, Evas_Object_Textblock_Format *fmt) PRINTF_APPEND_COLOR(secondary_underline_colorstr, fmt->color.underline2.r, fmt->color.underline2.g, fmt->color.underline2.b, fmt->color.underline2.a); - PRINTF_APPEND_COLOR(underline_dash_colorstr, fmt->color.underline_dash.r, fmt->color.underline_dash.g, + PRINTF_APPEND_COLOR(underline_dashed_colorstr, fmt->color.underline_dash.r, fmt->color.underline_dash.g, fmt->color.underline_dash.b, fmt->color.underline_dash.a); PRINTF_APPEND_COLOR(outline_colorstr, fmt->color.outline.r, fmt->color.outline.g, @@ -3365,7 +3559,7 @@ _format_string_get(const Eo *eo_obj, Evas_Object_Textblock_Format *fmt) PRINTF_APPEND_COLOR(secondary_glow_colorstr, fmt->color.glow2.r, fmt->color.glow2.g, fmt->color.glow2.b, fmt->color.glow2.a); - PRINTF_APPEND_COLOR(backing_colorstr, fmt->color.backing.r, fmt->color.backing.g, + PRINTF_APPEND_COLOR(background_colorstr, fmt->color.backing.r, fmt->color.backing.g, fmt->color.backing.b, fmt->color.backing.a); PRINTF_APPEND_COLOR(strikethrough_colorstr, fmt->color.strikethrough.r, fmt->color.strikethrough.g, @@ -3423,7 +3617,7 @@ _format_string_get(const Eo *eo_obj, Evas_Object_Textblock_Format *fmt) PRINTF_APPEND_INT(right_marginstr, fmt->margin.r); - char *underline_value_str = "off"; + char *underline_value_str = "none"; if (fmt->underline == EINA_TRUE && fmt->underline2 == EINA_TRUE) underline_value_str = "double"; @@ -3432,88 +3626,80 @@ _format_string_get(const Eo *eo_obj, Evas_Object_Textblock_Format *fmt) else if (fmt->underline_dash == EINA_TRUE) underline_value_str = "dashed"; - PRINTF_APPEND_STR(underlinestr, underline_value_str); - PRINTF_APPEND_STR(strikethroughstr, (fmt->strikethrough == 0 ? "off" : "on")); - PRINTF_APPEND_STR(backingstr, (fmt->backing == 0 ? "off" : "on")); + PRINTF_APPEND_STR(underline_typestr, underline_value_str); + PRINTF_APPEND_STR(strikethrough_typestr, (fmt->strikethrough == 0 ? "none" : "single")); + PRINTF_APPEND_STR(background_typestr, (fmt->backing == 0 ? "none" : "solid")); - char *style_value_str_1 = "off"; - char *style_value_str_2 = NULL; - Efl_Text_Style_Effect_Type style1 = _FMT_INFO(effect); - Efl_Text_Style_Effect_Type style2 = _FMT_INFO(shadow_direction); + Efl_Text_Style_Effect_Type effect = _FMT_INFO(effect); - switch (style1) + switch (effect) { case EFL_TEXT_STYLE_EFFECT_TYPE_NONE: - style_value_str_1 = "plain"; + PRINTF_APPEND_STR(effect_typestr, "none"); break; case EFL_TEXT_STYLE_EFFECT_TYPE_SHADOW: - style_value_str_1 = "shadow"; + PRINTF_APPEND_STR(effect_typestr, "shadow"); break; case EFL_TEXT_STYLE_EFFECT_TYPE_OUTLINE: - style_value_str_1 = "outline"; + PRINTF_APPEND_STR(effect_typestr, "outline"); break; case EFL_TEXT_STYLE_EFFECT_TYPE_SOFT_OUTLINE: - style_value_str_1 = "soft_outline"; + PRINTF_APPEND_STR(effect_typestr, "soft_outline"); break; case EFL_TEXT_STYLE_EFFECT_TYPE_OUTLINE_SHADOW: - style_value_str_1 = "outline_shadow"; + PRINTF_APPEND_STR(effect_typestr, "outline_shadow"); break; case EFL_TEXT_STYLE_EFFECT_TYPE_OUTLINE_SOFT_SHADOW: - style_value_str_1 = "outline_soft_shadow"; + PRINTF_APPEND_STR(effect_typestr, "outline_soft_shadow"); break; case EFL_TEXT_STYLE_EFFECT_TYPE_GLOW: - style_value_str_1 = "glow"; + PRINTF_APPEND_STR(effect_typestr, "glow"); break; case EFL_TEXT_STYLE_EFFECT_TYPE_FAR_SHADOW: - style_value_str_1 = "far_shadow"; + PRINTF_APPEND_STR(effect_typestr, "far_shadow"); break; case EFL_TEXT_STYLE_EFFECT_TYPE_SOFT_SHADOW: - style_value_str_1 = "soft_shadow"; + PRINTF_APPEND_STR(effect_typestr, "soft_shadow"); break; case EFL_TEXT_STYLE_EFFECT_TYPE_FAR_SOFT_SHADOW: - style_value_str_1 = "far_soft_shadow"; + PRINTF_APPEND_STR(effect_typestr, "far_soft_shadow"); break; default: - style_value_str_1 = "off"; break; } - switch (style2) + Efl_Text_Style_Shadow_Direction shadow_direction = _FMT_INFO(shadow_direction); + + switch (shadow_direction) { case EFL_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT: - style_value_str_2 = "bottom_right"; + PRINTF_APPEND_STR(shadow_directionstr, "bottom_right"); break; case EFL_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM: - style_value_str_2 = "bottom"; + PRINTF_APPEND_STR(shadow_directionstr, "bottom"); break; case EFL_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT: - style_value_str_2 = "bottom_left"; + PRINTF_APPEND_STR(shadow_directionstr, "bottom_left"); break; case EFL_TEXT_STYLE_SHADOW_DIRECTION_LEFT: - style_value_str_2 = "left"; + PRINTF_APPEND_STR(shadow_directionstr, "left"); break; case EFL_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT: - style_value_str_2 = "top_left"; + PRINTF_APPEND_STR(shadow_directionstr, "top_left"); break; case EFL_TEXT_STYLE_SHADOW_DIRECTION_TOP: - style_value_str_2 = "top"; + PRINTF_APPEND_STR(shadow_directionstr, "top"); break; case EFL_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT: - style_value_str_2 = "top_right"; + PRINTF_APPEND_STR(shadow_directionstr, "top_right"); break; case EFL_TEXT_STYLE_SHADOW_DIRECTION_RIGHT: - style_value_str_2 = "right"; + PRINTF_APPEND_STR(shadow_directionstr, "right"); break; default: - style_value_str_2 = NULL; break; } - if (style_value_str_2 != NULL) - eina_strbuf_append_printf(format_buffer, "%s=%s,%s ", stylestr, style_value_str_1, style_value_str_2); - else - PRINTF_APPEND_STR(stylestr, style_value_str_1); - PRINTF_APPEND_INT(tab_stopsstr, fmt->tabstops); PRINTF_APPEND_INT(line_sizestr, fmt->linesize); PRINTF_APPEND_PERCENT_FLOAT(line_rel_sizestr, (fmt->linerelsize*100)); @@ -3526,8 +3712,8 @@ _format_string_get(const Eo *eo_obj, Evas_Object_Textblock_Format *fmt) if (o->repch) PRINTF_APPEND_STR(replacement_charstr, o->repch); - PRINTF_APPEND_INT(underline_dash_widthstr, fmt->underline_dash_width); - PRINTF_APPEND_INT(underline_dash_gapstr, fmt->underline_dash_gap); + PRINTF_APPEND_INT(underline_dashed_widthstr, fmt->underline_dash_width); + PRINTF_APPEND_INT(underline_dashed_gapstr, fmt->underline_dash_gap); PRINTF_APPEND_FLOAT(underline_heightstr, fmt->underline_height); const char *temp = eina_strbuf_string_get(format_buffer); @@ -7656,6 +7842,7 @@ evas_object_textblock_add(Evas *e) efl_text_multiline_set(efl_added, EINA_TRUE), efl_canvas_object_legacy_ctor(efl_added)); o = efl_data_scope_get(eo_obj, MY_CLASS); + o->is_legacy = EINA_TRUE; o->legacy_newline = EINA_TRUE; o->auto_styles = EINA_FALSE; _FMT(password) = EINA_TRUE; diff --git a/src/tests/evas/evas_test_textblock.c b/src/tests/evas/evas_test_textblock.c index 1fee7eb5b1..76bf4c68b1 100644 --- a/src/tests/evas/evas_test_textblock.c +++ b/src/tests/evas/evas_test_textblock.c @@ -4909,23 +4909,33 @@ EFL_START_TEST(efl_canvas_textblock_style) efl_canvas_textblock_style_apply(txt, "wrap=none"); ck_assert_int_eq(efl_text_wrap_get(txt), EFL_TEXT_FORMAT_WRAP_NONE); - efl_canvas_textblock_style_apply(txt, "backing=on"); + efl_canvas_textblock_style_apply(txt, "background_type=solid"); ck_assert_int_eq(efl_text_background_type_get(txt), EFL_TEXT_STYLE_BACKGROUND_TYPE_SOLID_COLOR); - efl_canvas_textblock_style_apply(txt, "style=far_soft_shadow"); + efl_canvas_textblock_style_apply(txt, "background_color=red"); + efl_text_background_color_get(txt, &r, &g, &b, &a); + ck_assert_int_eq(r, 0xFF); + ck_assert_int_eq(g, 0x00); + ck_assert_int_eq(b, 0x00); + ck_assert_int_eq(a, 0xFF); + + efl_canvas_textblock_style_apply(txt, "effect_type=far_soft_shadow"); ck_assert_int_eq(efl_text_effect_type_get(txt), EFL_TEXT_STYLE_EFFECT_TYPE_FAR_SOFT_SHADOW); - efl_canvas_textblock_style_apply(txt, "style=glow,top_right"); - ck_assert_int_eq(efl_text_effect_type_get(txt), EFL_TEXT_STYLE_EFFECT_TYPE_GLOW); + efl_canvas_textblock_style_apply(txt, "shadow_direction=top_right"); ck_assert_int_eq(efl_text_shadow_direction_get(txt), EFL_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT); - efl_canvas_textblock_style_apply(txt, "style=far_shadow,top"); - ck_assert_int_eq(efl_text_effect_type_get(txt), EFL_TEXT_STYLE_EFFECT_TYPE_FAR_SHADOW); + efl_canvas_textblock_style_apply(txt, "shadow_direction=top"); ck_assert_int_eq(efl_text_shadow_direction_get(txt), EFL_TEXT_STYLE_SHADOW_DIRECTION_TOP); - efl_canvas_textblock_style_apply(txt, "style=soft_outline,top,bottom"); + efl_canvas_textblock_style_apply(txt, "effect_type=soft_outline"); ck_assert_int_eq(efl_text_effect_type_get(txt), EFL_TEXT_STYLE_EFFECT_TYPE_SOFT_OUTLINE); - ck_assert_int_eq(efl_text_shadow_direction_get(txt), EFL_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM); + + efl_canvas_textblock_style_apply(txt, "underline_type=none"); + ck_assert_int_eq(efl_text_underline_type_get(txt), EFL_TEXT_STYLE_UNDERLINE_TYPE_NONE); + + efl_canvas_textblock_style_apply(txt, "strikethrough_type=single"); + ck_assert_int_eq(efl_text_strikethrough_type_get(txt), EFL_TEXT_STYLE_STRIKETHROUGH_TYPE_SINGLE); efl_canvas_textblock_style_apply(txt, "color=#EF596C"); efl_text_color_get(txt, &r, &g, &b, &a); --
