summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorali-alzyod <ali198724@gmail.com>2021-04-08 02:02:08 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2021-04-08 02:02:09 +0100
commitb2f61deb37accb065480b591622415b9b9ff286e (patch)
treedf7cd9a3e8ef0a7bcaed22161d0006372bcd03cd /src
parent69cd4b41883b0c533c02186937fac392db0799d4 (diff)
evas_textblock: update color text parsingUpdate text color parsing for rgba(r, g, b, a) for alpha to be value between 0.0 - 1.0 same as CSS.
Summary: ... spam removed ... Reviewers: woohyun, bowonryu, id213sin, AbdullehGhujeh, devilhorns Subscribers: raster, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D12248
Diffstat (limited to 'src')
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c40
-rw-r--r--src/lib/evas/common/evas_text_utils.c15
2 files changed, 29 insertions, 26 deletions
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index f44dfaab5c..ff87db7be0 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -1785,8 +1785,8 @@ _format_command_legacy_only(Evas_Object_Textblock_Format *fmt, const char *cmd,
1785 * @li "#RRGGBBAA" 1785 * @li "#RRGGBBAA"
1786 * @li "#RGB" 1786 * @li "#RGB"
1787 * @li "#RGBA" 1787 * @li "#RGBA"
1788 * @li "rgb(r,g,b)" 1788 * @li "rgb(0-255,0-255,0-255)"
1789 * @li "rgba(r,g,b,a)" 1789 * @li "rgba(0-255,0-255,0-255,0.0-1.0)"
1790 * @li "color_name" like "red" 1790 * @li "color_name" like "red"
1791 * @code 1791 * @code
1792 * backing_color=<color> 1792 * backing_color=<color>
@@ -1827,8 +1827,8 @@ _format_command_legacy_only(Evas_Object_Textblock_Format *fmt, const char *cmd,
1827 * @li "#RRGGBBAA" 1827 * @li "#RRGGBBAA"
1828 * @li "#RGB" 1828 * @li "#RGB"
1829 * @li "#RGBA" 1829 * @li "#RGBA"
1830 * @li "rgb(r,g,b)" 1830 * @li "rgb(0-255,0-255,0-255)"
1831 * @li "rgba(r,g,b,a)" 1831 * @li "rgba(0-255,0-255,0-255,0.0-1.0)"
1832 * @li "color_name" like "red" 1832 * @li "color_name" like "red"
1833 * @code 1833 * @code
1834 * underline2_color=<color> 1834 * underline2_color=<color>
@@ -1849,8 +1849,8 @@ _format_command_legacy_only(Evas_Object_Textblock_Format *fmt, const char *cmd,
1849 * @li "#RRGGBBAA" 1849 * @li "#RRGGBBAA"
1850 * @li "#RGB" 1850 * @li "#RGB"
1851 * @li "#RGBA" 1851 * @li "#RGBA"
1852 * @li "rgb(r,g,b)" 1852 * @li "rgb(0-255,0-255,0-255)"
1853 * @li "rgba(r,g,b,a)" 1853 * @li "rgba(0-255,0-255,0-255,0.0-1.0)"
1854 * @li "color_name" like "red" 1854 * @li "color_name" like "red"
1855 * @code 1855 * @code
1856 * glow2_color=<color> 1856 * glow2_color=<color>
@@ -2001,8 +2001,8 @@ _format_command_legacy_only(Evas_Object_Textblock_Format *fmt, const char *cmd,
2001 * @li "#RRGGBBAA" 2001 * @li "#RRGGBBAA"
2002 * @li "#RGB" 2002 * @li "#RGB"
2003 * @li "#RGBA" 2003 * @li "#RGBA"
2004 * @li "rgb(r,g,b)" 2004 * @li "rgb(0-255,0-255,0-255)"
2005 * @li "rgba(r,g,b,a)" 2005 * @li "rgba(0-255,0-255,0-255,0.0-1.0)"
2006 * @li "color_name" like "red" 2006 * @li "color_name" like "red"
2007 * @code 2007 * @code
2008 * underline_dash_color=<color> 2008 * underline_dash_color=<color>
@@ -2516,8 +2516,8 @@ _format_command(Evas_Object *eo_obj, Evas_Object_Textblock_Format *fmt, const ch
2516 * @li "#RRGGBBAA" 2516 * @li "#RRGGBBAA"
2517 * @li "#RGB" 2517 * @li "#RGB"
2518 * @li "#RGBA" 2518 * @li "#RGBA"
2519 * @li "rgb(r,g,b)" 2519 * @li "rgb(0-255,0-255,0-255)"
2520 * @li "rgba(r,g,b,a)" 2520 * @li "rgba(0-255,0-255,0-255,0.0-1.0)"
2521 * @li "color_name" like "red" 2521 * @li "color_name" like "red"
2522 * @code 2522 * @code
2523 * color=<color> 2523 * color=<color>
@@ -2537,8 +2537,8 @@ _format_command(Evas_Object *eo_obj, Evas_Object_Textblock_Format *fmt, const ch
2537 * @li "#RRGGBBAA" 2537 * @li "#RRGGBBAA"
2538 * @li "#RGB" 2538 * @li "#RGB"
2539 * @li "#RGBA" 2539 * @li "#RGBA"
2540 * @li "rgb(r,g,b)" 2540 * @li "rgb(0-255,0-255,0-255)"
2541 * @li "rgba(r,g,b,a)" 2541 * @li "rgba(0-255,0-255,0-255,0.0-1.0)"
2542 * @li "color_name" like "red" 2542 * @li "color_name" like "red"
2543 * @code 2543 * @code
2544 * underline_color=<color> 2544 * underline_color=<color>
@@ -2559,8 +2559,8 @@ _format_command(Evas_Object *eo_obj, Evas_Object_Textblock_Format *fmt, const ch
2559 * @li "#RRGGBBAA" 2559 * @li "#RRGGBBAA"
2560 * @li "#RGB" 2560 * @li "#RGB"
2561 * @li "#RGBA" 2561 * @li "#RGBA"
2562 * @li "rgb(r,g,b)" 2562 * @li "rgb(0-255,0-255,0-255)"
2563 * @li "rgba(r,g,b,a)" 2563 * @li "rgba(0-255,0-255,0-255,0.0-1.0)"
2564 * @li "color_name" like "red" 2564 * @li "color_name" like "red"
2565 * @code 2565 * @code
2566 * outline_color=<color> 2566 * outline_color=<color>
@@ -2581,8 +2581,8 @@ _format_command(Evas_Object *eo_obj, Evas_Object_Textblock_Format *fmt, const ch
2581 * @li "#RRGGBBAA" 2581 * @li "#RRGGBBAA"
2582 * @li "#RGB" 2582 * @li "#RGB"
2583 * @li "#RGBA" 2583 * @li "#RGBA"
2584 * @li "rgb(r,g,b)" 2584 * @li "rgb(0-255,0-255,0-255)"
2585 * @li "rgba(r,g,b,a)" 2585 * @li "rgba(0-255,0-255,0-255,0.0-1.0)"
2586 * @li "color_name" like "red" 2586 * @li "color_name" like "red"
2587 * @code 2587 * @code
2588 * shadow_color=<color> 2588 * shadow_color=<color>
@@ -2603,8 +2603,8 @@ _format_command(Evas_Object *eo_obj, Evas_Object_Textblock_Format *fmt, const ch
2603 * @li "#RRGGBBAA" 2603 * @li "#RRGGBBAA"
2604 * @li "#RGB" 2604 * @li "#RGB"
2605 * @li "#RGBA" 2605 * @li "#RGBA"
2606 * @li "rgb(r,g,b)" 2606 * @li "rgb(0-255,0-255,0-255)"
2607 * @li "rgba(r,g,b,a)" 2607 * @li "rgba(0-255,0-255,0-255,0.0-1.0)"
2608 * @li "color_name" like "red" 2608 * @li "color_name" like "red"
2609 * @code 2609 * @code
2610 * glow_color=<color> 2610 * glow_color=<color>
@@ -2625,8 +2625,8 @@ _format_command(Evas_Object *eo_obj, Evas_Object_Textblock_Format *fmt, const ch
2625 * @li "#RRGGBBAA" 2625 * @li "#RRGGBBAA"
2626 * @li "#RGB" 2626 * @li "#RGB"
2627 * @li "#RGBA" 2627 * @li "#RGBA"
2628 * @li "rgb(r,g,b)" 2628 * @li "rgb(0-255,0-255,0-255)"
2629 * @li "rgba(r,g,b,a)" 2629 * @li "rgba(0-255,0-255,0-255,0.0-1.0)"
2630 * @li "color_name" like "red" 2630 * @li "color_name" like "red"
2631 * @code 2631 * @code
2632 * strikethrough_color=<color> 2632 * strikethrough_color=<color>
diff --git a/src/lib/evas/common/evas_text_utils.c b/src/lib/evas/common/evas_text_utils.c
index 99a9c3e3b3..1a0a7a0af2 100644
--- a/src/lib/evas/common/evas_text_utils.c
+++ b/src/lib/evas/common/evas_text_utils.c
@@ -1362,8 +1362,8 @@ Eina_Bool read_byte_color_component(const char* source,char ** next,unsigned cha
1362 * 3. "#RGB" 1362 * 3. "#RGB"
1363 * 4. "#RGBA" 1363 * 4. "#RGBA"
1364 * 5. "color names" 1364 * 5. "color names"
1365 * 6. "rgb(r,g,b)" 1365 * 6. "rgb(0-255,0-255,0-255)"
1366 * 7. "rgba(r,g,b,a)" 1366 * 7. "rgba(0-255,0-255,0-255,0.0-1.0)"
1367 * TODO (we may use specific color parser) 1367 * TODO (we may use specific color parser)
1368 * 8. "hsl(H,S,L)" 1368 * 8. "hsl(H,S,L)"
1369 * 9. "hsla(H,S,L,A)" 1369 * 9. "hsla(H,S,L,A)"
@@ -1422,7 +1422,7 @@ evas_common_format_color_parse(const char *str, int slen,
1422 } 1422 }
1423 else v = EINA_FALSE; 1423 else v = EINA_FALSE;
1424 } 1424 }
1425 else if (slen <= 21)/* search for rgb(),hsv(),colorname, 20 is length of rgba(255,255,255,255) */ 1425 else if (slen <= 25)/* search for rgb(),hsv(),colorname, 25 is length of rgba(255,255,255,1.0) */
1426 { 1426 {
1427 /*remove spaces and convert name to lowercase*/ 1427 /*remove spaces and convert name to lowercase*/
1428 char color_name[0xFF] = {0}; 1428 char color_name[0xFF] = {0};
@@ -1446,20 +1446,23 @@ evas_common_format_color_parse(const char *str, int slen,
1446 *a = 0xff; 1446 *a = 0xff;
1447 } 1447 }
1448 } 1448 }
1449 else if ((strncmp(color_name,"rgba(",4) == 0) && color_name[slen-1] == ')'&& slen >= 13 && slen <=21) /* rgba() */ 1449 else if ((strncmp(color_name,"rgba(",4) == 0) && color_name[slen-1] == ')'&& slen >= 13 && slen <=25) /* rgba() */
1450 { 1450 {
1451 char * p_color = &color_name[4]; 1451 char * p_color = &color_name[4];
1452 1452
1453 if ( 1453 if (
1454 (!read_byte_color_component(++p_color,&p_color,r) || !p_color || *p_color != ',') || 1454 (!read_byte_color_component(++p_color,&p_color,r) || !p_color || *p_color != ',') ||
1455 (!read_byte_color_component(++p_color,&p_color,g) || !p_color || *p_color != ',') || 1455 (!read_byte_color_component(++p_color,&p_color,g) || !p_color || *p_color != ',') ||
1456 (!read_byte_color_component(++p_color,&p_color,b) || !p_color || *p_color != ',') || 1456 (!read_byte_color_component(++p_color,&p_color,b) || !p_color || *p_color != ',')
1457 (!read_byte_color_component(++p_color,&p_color,a) || !p_color || *p_color != ')')
1458 ) 1457 )
1459 { 1458 {
1460 *r = *g = *b = *a = 0; 1459 *r = *g = *b = *a = 0;
1461 v = EINA_FALSE; 1460 v = EINA_FALSE;
1462 } 1461 }
1462 else
1463 {
1464 *a = (unsigned char)(strtof(++p_color, NULL) * 255);
1465 }
1463 } 1466 }
1464 else 1467 else
1465 { 1468 {