edje_textblock: style font size override size_range max
authorAli Alzyod <ali198724@gmail.com>
Thu, 12 Mar 2020 11:07:12 +0000 (20:07 +0900)
committerJongmin Lee <jm105.lee@samsung.com>
Fri, 13 Mar 2020 00:18:32 +0000 (09:18 +0900)
Summary: style font size (also text_class) will change size_range max value, regardless of what user specifed in textblock description

Reviewers: woohyun

Reviewed By: woohyun

Subscribers: cedric, #reviewers, #committers

Tags: #efl

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

src/lib/edje/edje_textblock.c

index eb1ad6b..3ee30db 100644 (file)
@@ -574,6 +574,20 @@ _edje_part_textblock_style_text_set(Edje *ed,
    return EINA_FALSE;
 }
 
+static char*
+strrstr(const char* haystack, const char* violate)
+{
+   char *s_ret = NULL;
+   char *tmp = NULL;
+   const char *_haystack = haystack;
+   size_t len = strlen(violate);
+   while((tmp = strstr(_haystack, violate))){
+     s_ret = tmp;
+     _haystack = tmp + len;
+   }
+   return s_ret;
+}
+
 void
 _edje_part_recalc_single_textblock(FLOAT_T sc,
                                    Edje *ed,
@@ -690,11 +704,21 @@ _edje_part_recalc_single_textblock(FLOAT_T sc,
                   size_t size_array_len = 0;
                   Eina_List *l;
                   unsigned int *value;
+                  Evas_Textblock_Style *st = _edje_textblock_style_get(ed, chosen_desc->text.style.str);
+                  const char *text_style = evas_textblock_style_get(st);
+                  char *s_font_size = (text_style) ? strrstr(text_style,"font_size=") : NULL;
+                  if (s_font_size)
+                    {
+                      int font_size = strtol(&s_font_size[10], NULL, 10);
+                      chosen_desc->text.size_range_max = font_size;
+                      if (chosen_desc->text.size_range_min > chosen_desc->text.size_range_max)
+                        chosen_desc->text.size_range_min = chosen_desc->text.size_range_max;
+                    }
                   EINA_LIST_FOREACH(chosen_desc->text.fit_size_array, l, value)
                     {
                        size_array[size_array_len++] = *value;
                     }
-                 unsigned int mode = TEXTBLOCK_FIT_MODE_NONE;
+                  unsigned int mode = TEXTBLOCK_FIT_MODE_NONE;
 
                   if (chosen_desc->text.fit_x)
                     mode |= TEXTBLOCK_FIT_MODE_WIDTH;