zmike pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=0164162a48dc1b1febf7828193e8ea05b4865b8f

commit 0164162a48dc1b1febf7828193e8ea05b4865b8f
Author: a.srour <[email protected]>
Date:   Mon Dec 30 11:12:37 2019 -0500

    Edje: edc text_class applied without font or font_size in style
    
    Summary:
    The issue with `text_class` in Edc styles has to be within a string 
containing `font` & `font_size` properties to effect style, if font or 
font_size not presented in the same string text_class will be ignored.
    
    So in the following Edc example, `text_class` will be ignored:
    ```
    collections {
       text_classes {
          text_class {
             name: "tc1";
             font: "Sans";
             size: 20;
          }
       }
       styles {
          style {
             name: "style1";
             base: "color=#00FF00 text_class=tc1";
             tag: "br" "\n";
          }
       }
    }
    ```
    
    To apply text_class `tc1`, font and font_size has to be added to 
`styles.style.base` value, to be as follows:
    ```
    ...
    base: "font=Serif font_size=15 color=#00FF00 text_class=tc1";
    ...
    ```
    
    NOTE: The produced font will be `Sans` and font_size equal to `20`
    
    Test Plan:
    `layout.edc`
    ```
    // compile: edje_cc layout.edc
    // play: edje_player layout.edj
    collections {
        text_classes {
           text_class {
              name: "tc1";
              font: "Sans";
              size: 20;
           }
        }
        styles {
            style {
                name: "style1";
                base: "color=#FFFFFF text_class=tc1";
            }
        }
        group {
            name : "group1";
            parts {
               part {
                  name : "tb1";
                  type: TEXTBLOCK;
                  scale: 1;
                  entry_mode: NONE;
                  description {
                      state: "default" 0.0;
                      rel1.relative: 0.0 0.0;
                      rel2.relative: 0.5 0.5;
                      text {
                         style: "style1";
                         align: 0.0 0.0;
                         text: "Hello EFL";
                      }
                  }
               }
            }
        }
    }
    
    Reviewers: segfaultxavi, smohanty, ali.alzyod, cedric, zmike
    
    Reviewed By: zmike
    
    Subscribers: zmike, segfaultxavi, cedric, #reviewers, #committers
    
    Tags: #efl
    
    Maniphest Tasks: T8477, T8478
    
    Differential Revision: https://phab.enlightenment.org/D10692
---
 src/lib/edje/edje_textblock_styles.c   |  4 +--
 src/tests/edje/data/test_textblock.edc | 41 +++++++++++++++++++++++++++++
 src/tests/edje/edje_test_text.c        | 47 +++++++++++++++++++++++++++++++---
 3 files changed, 86 insertions(+), 6 deletions(-)

diff --git a/src/lib/edje/edje_textblock_styles.c 
b/src/lib/edje/edje_textblock_styles.c
index d2b8aaa4ba..3618d201c4 100644
--- a/src/lib/edje/edje_textblock_styles.c
+++ b/src/lib/edje/edje_textblock_styles.c
@@ -193,7 +193,7 @@ _edje_textblock_style_update(Edje *ed, Edje_Style *stl)
                   eina_strbuf_append(txt, fontsource);
                }
           }
-        if (tc && tc->size && !EINA_DBL_EQ(tag->font_size, 0))
+        if (tc && tc->size)
           {
              double new_size = _edje_text_size_calc(tag->font_size, tc);
              if (!EINA_DBL_EQ(tag->font_size, new_size))
@@ -206,7 +206,7 @@ _edje_textblock_style_update(Edje *ed, Edje_Style *stl)
                }
           }
         /* Add font name last to save evas from multiple loads */
-        if (tc && tc->font && tag->font)
+        if (tc && tc->font)
           {
              const char *f;
              char *sfont = NULL;
diff --git a/src/tests/edje/data/test_textblock.edc 
b/src/tests/edje/data/test_textblock.edc
index e8223e75be..f7cc0070a9 100644
--- a/src/tests/edje/data/test_textblock.edc
+++ b/src/tests/edje/data/test_textblock.edc
@@ -1,8 +1,21 @@
 collections {
+   text_classes {
+      text_class {
+         name: "tc1";
+         font: "Serif";
+         size: 18;
+      }
+   }
    styles {
       style { name: "tb_style";
          base: "font=Sans font_size=20 color=#fff";
       }
+      style { name: "tb_tc_style";
+         base: "color=#ff0 text_class=tc1";
+      }
+      style { name: "tb_tc2_style";
+         base: "color=#0ff text_class=tc2";
+      }
    }
    group { name: "test_textblock";
       parts {
@@ -18,4 +31,32 @@ collections {
          }
       }
    }
+   group { name: "test_tc_textblock";
+      parts {
+         part { name: "tb";
+            type: TEXTBLOCK;
+            description { state: "default" 0.0;
+               min: 300 300;
+               text {
+                  text: "Hello World";
+                  style: "tb_tc_style";
+               }
+            }
+         }
+      }
+   }
+   group { name: "test_tc_textblock2";
+      parts {
+         part { name: "tb2";
+            type: TEXTBLOCK;
+            description { state: "default" 0.0;
+               min: 300 300;
+               text {
+                  text: "Hello World";
+                  style: "tb_tc2_style";
+               }
+            }
+         }
+      }
+   }
 }
diff --git a/src/tests/edje/edje_test_text.c b/src/tests/edje/edje_test_text.c
index a66132c1d8..0939f8bbbf 100644
--- a/src/tests/edje/edje_test_text.c
+++ b/src/tests/edje/edje_test_text.c
@@ -102,13 +102,52 @@ EFL_START_TEST(edje_test_textblock)
    evas = _setup_evas();
 
    obj = edje_object_add(evas);
-   fail_unless(edje_object_file_set(obj, 
test_layout_get("test_textblock.edj"), "test_textblock"));
+   ck_assert(edje_object_file_set(obj, test_layout_get("test_textblock.edj"), 
"test_textblock"));
    txt = edje_object_part_text_get(obj, "text");
-   fail_if(!txt || strcmp(txt, "Bye"));
+   ck_assert(txt || !strcmp(txt, "Bye"));
    edje_object_part_text_set(obj, "text", buf);
    txt = edje_object_part_text_get(obj, "text");
-   fail_if(!txt || strcmp(txt, buf));
-
+   ck_assert(txt || !strcmp(txt, buf));
+
+   Evas_Object *obj2 = edje_object_add(evas);
+   ck_assert(edje_object_file_set(obj2, test_layout_get("test_textblock.edj"), 
"test_tc_textblock"));
+   Evas_Object *tb = (Evas_Object*)edje_object_part_object_get(obj2, "tb");
+   ck_assert_ptr_ne(tb, NULL);
+   int w = 0, h = 0;
+   evas_object_textblock_size_formatted_get(tb, &w, &h);
+   Evas_Textblock_Style *st = evas_object_textblock_style_get(tb);
+   txt = evas_textblock_style_get(st);
+   ck_assert_str_eq(txt, "DEFAULT='color=#ff0 font_size=18.0 font=Serif'");
+   ck_assert_int_ne(w, 0);
+   ck_assert_int_ne(h, 0);
+
+   edje_object_text_class_set(obj2, "tc1", "Sans", 15);
+   edje_object_calc_force(obj2);
+   int w2 = 0, h2 = 0;
+   evas_object_textblock_size_formatted_get(tb, &w2, &h2);
+   ck_assert_int_ne(w2, 0);
+   ck_assert_int_ne(h2, 0);
+   ck_assert_int_ne(w, w2);
+   ck_assert_int_ne(h, h2);
+
+   ck_assert(edje_object_file_set(obj2, test_layout_get("test_textblock.edj"), 
"test_tc_textblock2"));
+   tb = (Evas_Object*)edje_object_part_object_get(obj2, "tb2");
+   ck_assert_ptr_ne(tb, NULL);
+   st = evas_object_textblock_style_get(tb);
+   txt = evas_textblock_style_get(st);
+   ck_assert_str_eq(txt, "DEFAULT='color=#0ff'");
+   evas_object_textblock_size_formatted_get(tb, &w, &h);
+   ck_assert_int_eq(w, 0);
+   ck_assert_int_eq(h, 0);
+
+   edje_object_text_class_set(obj2, "tc2", "Sans", 15);
+   edje_object_calc_force(obj2);
+   evas_object_textblock_size_formatted_get(tb, &w, &h);
+   ck_assert_int_ne(w, 0);
+   ck_assert_int_ne(h, 0);
+   st = evas_object_textblock_style_get(tb);
+   txt = evas_textblock_style_get(st);
+   ck_assert_str_eq(txt, "DEFAULT='color=#0ff font_size=15.0 font=Sans'");
 }
 EFL_END_TEST
 

-- 


Reply via email to