Commit Graph

132 Commits

Author SHA1 Message Date
Carsten Haitzler 39240fa3e7 Revert "evas_textblock: content fit feature"
This reverts commit 2f676a6591.

This causes segv's in edje_cc - i suspect the eet changes (or in combo
to how they are used in edje):

AddressSanitizer:DEADLYSIGNAL
=================================================================
==8991==ERROR: AddressSanitizer: SEGV on unknown address 0x000001010000 (pc 0xffff9f002604 bp 0xfffffa747700 sp 0xfffffa747700 T0)
==8991==The signal is caused by a READ memory access.
    #0 0xffff9f002600 in _eet_hash_gen ../src/lib/eet/eet_utils.c:25
    #1 0xffff9efdd024 in eet_dictionary_string_add ../src/lib/eet/eet_dictionary.c:103
    #2 0xffff9efbe324 in eet_data_put_string ../src/lib/eet/eet_data.c:849
    #3 0xffff9efc1c4c in eet_data_put_type ../src/lib/eet/eet_data.c:1427
    #4 0xffff9efd9128 in eet_data_put_unknown ../src/lib/eet/eet_data.c:4730
    #5 0xffff9efdb320 in _eet_data_descriptor_encode ../src/lib/eet/eet_data.c:5108
    #6 0xffff9efd5958 in eet_data_put_variant ../src/lib/eet/eet_data.c:4309
    #7 0xffff9efdb320 in _eet_data_descriptor_encode ../src/lib/eet/eet_data.c:5108
    #8 0xffff9efd9270 in eet_data_put_unknown ../src/lib/eet/eet_data.c:4739
    #9 0xffff9efdb320 in _eet_data_descriptor_encode ../src/lib/eet/eet_data.c:5108
    #10 0xffff9efd8ca0 in eet_data_put_array ../src/lib/eet/eet_data.c:4692
    #11 0xffff9efdb320 in _eet_data_descriptor_encode ../src/lib/eet/eet_data.c:5108
    #12 0xffff9efc7768 in eet_data_write_cipher ../src/lib/eet/eet_data.c:2403
    #13 0xffff9efc78a4 in eet_data_write ../src/lib/eet/eet_data.c:2420
    #14 0xaaaabb151dcc in data_thread_group ../src/bin/edje/edje_cc_out.c:2045
    #15 0xaaaabb152130 in data_write_groups ../src/bin/edje/edje_cc_out.c:2086
    #16 0xaaaabb157734 in data_write ../src/bin/edje/edje_cc_out.c:2866
    #17 0xaaaabb14122c in main ../src/bin/edje/edje_cc.c:456
    #18 0xffff9dbd92a0 in __libc_start_main (/usr/lib/aarch64-linux-gnu/libc.so.6+0x242a0)
    #19 0xaaaabb13ea00  (/home/raster/C/git/efl/build/src/bin/edje/edje_cc+0x38a00)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV ../src/lib/eet/eet_utils.c:25 in _eet_hash_gen
==8991==ABORTING
Aborted (core dumped)

When compiling breaks... it's certainly time to revert ASAP :(
2019-11-07 10:23:58 +00:00
Ali Alzyod 2f676a6591 evas_textblock: content fit feature
Summary:
**Content Fit Feature for Evas_Object_Textblock**

This Feature is available at **Evas **object level.  And **Edje **level (where it is internally use evas functionality)
This feature will allow text block to fit its content font size to proper size to fit its area.

**Main Properties:**
Fit Modes        :   None=Default, Width, Height, All [Width+Height]
Fit Size Range :   Contains maximum and minimum font size to be used (and in between).
Fit Step Size    :   Step(Jump) value when trying fonts sizes between Size_Range max and min.
Fit Size Array   :   Other way to resize font, where you explicitly select font sizes to be uses    (for example [20, 50, 100] it will try 3 sizes only)

Text Fit feature was available in Edje but:
1- It doesn't effected by ellipsis or warping in font style (or do not handle the in right way)
2- Accuracy is not good (specially if you have fix pixel size elements (spaces,tabs,items))
3- No (Step size, Size Array) available.

Test Plan:
To check the Feature
> elementary_test
> fit
> textbock fit
You can modify all the modes and properties

These are two examples, One using Evas other uses Edje

**Evas**

```
#include <Elementary.h>

enum BUTTON{
   BUTTON_MODE             = 0,
   BUTTON_MAX              = 1,
   BUTTON_MIN              = 2,
   BUTTON_STEP             = 3,
   BUTTON_ARRAY            = 4,
   BUTTON_CONTENT          = 5,
   BUTTON_STYLE            = 6,
   BUTTON_ALL              = BUTTON_STYLE+1,
};

char* BUTTON_STR[BUTTON_ALL] ={
   "MODE",
   "MAX",
   "MIN",
   "STEP",
   "ARRAY",
   "CONTENT",
   "STYLE",
};

char *contents[] = {
   "Hello World",
   "This is Line<br>THis is other Line",
   "This text contains <font_size=20 color=#F00>SPECIFIC SIZE</font_size> that does not effected by fit mode"
   };

char *styles[] = {
   "DEFAULT='font=sans font_size=30 color=#000 wrap=mixed ellipsis=1.0'",
   "DEFAULT='font=sans font_size=30 color=#000 wrap=mixed'",
   "DEFAULT='font=sans font_size=30 color=#000 ellipsis=1.0'",
   "DEFAULT='font=sans font_size=30 color=#000'",
   };

char *styles_names[] = {
   "wrap=<color=#F00>mixed</color> ellipsis=<color=#F00>1.0</color>",
   "wrap=<color=#F00>mixed</color> ellipsis=<color=#F00>NONE</color>",
   "wrap=<color=#F00>NONE</color> ellipsis=<color=#F00>1.0</color>",
   "wrap=<color=#F00>NONE</color> ellipsis=<color=#F00>NONE</color>",
   };

typedef struct _APP
{
   Evas_Object *win, *box, *txtblock,*bg, *boxHor, *boxHor2;
   Eo *btn[BUTTON_ALL];
   Eo *lbl_status;
   char * str;
   unsigned int i_contnet, i_style;
} APP;
APP *app;

char * get_fit_status(Eo * textblock);

static void _btn_clicked(void *data EINA_UNUSED, Eo *obj, void *eventInfo EINA_UNUSED){
   if (obj == app->btn[BUTTON_MODE])
     {
        unsigned int options;
        evas_textblock_fit_options_get(app->txtblock, &options);
        if (options == TEXTBLOCK_FIT_MODE_NONE)
           evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_HEIGHT);
        else if (options == TEXTBLOCK_FIT_MODE_HEIGHT)
           evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_WIDTH);
        else if (options == TEXTBLOCK_FIT_MODE_WIDTH)
           evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_ALL);
        else if (options == TEXTBLOCK_FIT_MODE_ALL)
           evas_textblock_fit_options_set(app->txtblock, TEXTBLOCK_FIT_MODE_NONE);
     }
   else if (obj == app->btn[BUTTON_MAX])
     {
        unsigned int min, max;
        evas_textblock_fit_size_range_get(app->txtblock, &min, &max);
        max -= 5;
        evas_textblock_fit_size_range_set(app->txtblock, min, max);
     }
   else if (obj == app->btn[BUTTON_MIN])
     {
        unsigned int min, max;
        evas_textblock_fit_size_range_get(app->txtblock, &min, &max);
        min += 5;
        evas_textblock_fit_size_range_set(app->txtblock, min, max);
     }
   else if (obj == app->btn[BUTTON_STEP])
     {
        unsigned int step;
        evas_textblock_fit_step_size_get(app->txtblock, &step);
        step++;
        evas_textblock_fit_step_size_set(app->txtblock, step);
     }
   else if (obj == app->btn[BUTTON_ARRAY])
     {
        unsigned int font_size[] = {10, 50, 100 ,150};
        evas_textblock_fit_size_array_set(app->txtblock,font_size,4);
     }
   else if (obj == app->btn[BUTTON_CONTENT])
     {
        app->i_contnet++;
        if(app->i_contnet>=sizeof(contents)/sizeof(char*))
           app->i_contnet=0;
        evas_object_textblock_text_markup_set(app->txtblock,contents[app->i_contnet]);
     }
   else if (obj == app->btn[BUTTON_STYLE])
     {
        app->i_style++;
        if(app->i_style>=sizeof(styles)/sizeof(char*))
           app->i_style=0;

        Evas_Textblock_Style *style = evas_object_textblock_style_get(app->txtblock);
        evas_textblock_style_set(style,styles[app->i_style]);
     }

   elm_object_text_set(app->lbl_status, get_fit_status(app->txtblock));
}

char * get_fit_status(Eo * textblock)
{
   static char status[0xFFF];
   unsigned int options,min,max,step,size_array[256];
   size_t size_array_len;
   evas_textblock_fit_options_get(textblock,&options);
   evas_textblock_fit_size_range_get(textblock,&min,&max);
   evas_textblock_fit_step_size_get(textblock,&step);
   evas_textblock_fit_size_array_get(textblock,NULL,&size_array_len,0);
   if (size_array_len>255)
      size_array_len = 255;
   evas_textblock_fit_size_array_get(textblock,size_array,NULL,size_array_len);

   strcpy(status,"Mode : ");
   if (options == TEXTBLOCK_FIT_MODE_NONE)
      strcat(status,"MODE_NONE");
   else if (options == TEXTBLOCK_FIT_MODE_HEIGHT)
      strcat(status,"MODE_HEIGHT");
   else if (options == TEXTBLOCK_FIT_MODE_WIDTH)
      strcat(status,"MODE_WIDTH");
   else if (options == TEXTBLOCK_FIT_MODE_ALL)
      strcat(status,"MODE_ALL");

   strcat(status,"<br>");
   sprintf(status + strlen(status),"Max   : %d<br>",max);
   sprintf(status + strlen(status),"Min   : %d<br>",min);
   sprintf(status + strlen(status),"Step  : %d<br>",step);
   sprintf(status + strlen(status),"Array  : [ ");
   for (size_t i = 0 ; i < 10 ; i++)
     {
        if(i<size_array_len)
           sprintf(status + strlen(status)," %d,",size_array[i]);
     }

   if(10<size_array_len)
      sprintf(status + strlen(status)," ... ");
   sprintf(status + strlen(status)," ]");

   sprintf(status + strlen(status),"<br>");
   sprintf(status + strlen(status),"%s",styles_names[app->i_style]);

   return status;
}

int elm_main(int argc, char **argv)
{
  app = calloc(sizeof(APP), 1);

   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);

   app->win = elm_win_util_standard_add("Main", "App");
   elm_win_autodel_set(app->win, EINA_TRUE);

   app->box = elm_box_add(app->win);
   app->boxHor = elm_box_add(app->box);
   app->boxHor2 = elm_box_add(app->box);
   app->txtblock = evas_object_textblock_add(app->box);
   app->bg = elm_bg_add(app->box);
   elm_bg_color_set(app->bg,255,255,255);

   Evas_Textblock_Style *style = evas_textblock_style_new();
   evas_textblock_style_set(style,styles[0]);
   evas_object_textblock_style_set(app->txtblock,style);
   evas_object_textblock_text_markup_set(app->txtblock,contents[0]);

   elm_box_horizontal_set(app->boxHor, EINA_TRUE);
   elm_box_horizontal_set(app->boxHor2, EINA_TRUE);

   evas_object_size_hint_weight_set(app->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_size_hint_align_set(app->box, EVAS_HINT_FILL, EVAS_HINT_FILL);

   evas_object_size_hint_weight_set(app->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_size_hint_align_set(app->box, EVAS_HINT_FILL, EVAS_HINT_FILL);

   evas_object_show(app->txtblock);
   evas_object_show(app->bg);
   evas_object_show(app->box);
   evas_object_show(app->boxHor);
   evas_object_show(app->boxHor2);

   elm_box_pack_end(app->box, app->bg);
   elm_box_pack_end(app->box, app->boxHor);
   elm_box_pack_end(app->box, app->boxHor2);

   elm_object_content_set(app->bg,app->txtblock);

   elm_win_resize_object_add(app->win, app->box);
   evas_object_resize(app->win, 320, 480);

   for(int i = 0 ; i < BUTTON_ALL ; i++)
     {
        app->btn[i] = elm_button_add(app->boxHor);
        evas_object_smart_callback_add(app->btn[i], "clicked", _btn_clicked, NULL);
        elm_object_text_set(app->btn[i], BUTTON_STR[i]);
        elm_box_pack_end(app->boxHor, app->btn[i]);
        evas_object_show(app->btn[i]);
     }

   app->lbl_status = elm_label_add(app->boxHor2);
   elm_object_text_set(app->lbl_status, get_fit_status(app->txtblock));
   elm_box_pack_end(app->boxHor2, app->lbl_status);
   evas_object_show(app->lbl_status);

   evas_object_size_hint_weight_set(app->txtblock, EVAS_HINT_EXPAND,EVAS_HINT_EXPAND);
   evas_object_size_hint_align_set(app->txtblock, EVAS_HINT_FILL, EVAS_HINT_FILL);

   evas_object_size_hint_weight_set(app->bg, EVAS_HINT_EXPAND,EVAS_HINT_EXPAND);
   evas_object_size_hint_align_set(app->bg, EVAS_HINT_FILL, EVAS_HINT_FILL);

   evas_object_show(app->win);
   elm_run();
   return 0;
}

ELM_MAIN()
```

**Edje**

```
// compile: edje_cc source.edc
// run: edje_player source.edje
collections {
   styles
   {
      style
      {
         name: "text_style";
         base: "font=sans font_size=30 color=#FFF wrap=mixed ellipsis=1.0";
         tag: "br" "\n";
         tag: "ps" "ps";
         tag: "tab" "\t";
         tag: "b" "+ font_weight=Bold";
      }
   }
   group {
      name: "my_group"; // must be the same as in source.c
      parts {

         part
         {
            name: "background";
            type: RECT;
            scale: 1;
            description
            {
               color: 0 0 0 0;
               rel1.relative: 0.0 0.0;
               rel2.relative: 1.0 1.0;
            }
         }

         part
         {
            name: "text";
            type: TEXTBLOCK;
            scale: 1;
            entry_mode: NONE;
            effect: OUTLINE_SHADOW;
            description
            {
               state: "default" 0.0;
               rel1.to : "background";
               rel1.relative: 0.0 0.0;
               rel2.to : "background";
               rel2.relative: 1.0 1.0;
               text
               {
                  style: "text_style";
                  align: 0.0 0.0;
                  text: "Hello World This is Me";
                  fit: 1 1;
                  fit_step: 1;
                  size_range: 30 200;
                  //fit_size_array: 20 40 60 80 100 200;
               }
            }
         }
      }
   }
}
```

Found Task T5724 relative to this Feature

Reviewers: woohyun, bowonryu, cedric, raster

Subscribers: #committers, #reviewers, cedric

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9280
2019-11-05 20:40:59 +09:00
Carsten Haitzler 80d317f20e evas - revert evas variation sequence support - out of bound accesses
This code is filled with out of bounds accesses now after the reverted
patch. All those base_char+1, itr+1 etc. in
evas_common_font_query_run_font_end_get() are accessing BEYOND
the end of the run. textgrid shows this instantly to fall over as it
uses single unicode codepoint chars with no nul terminator. As this
api takes an explicit run_len we should never access beyond the end of
the run_len.

Please revisit this code and keep in mind proper memory/bounds
accessing. If there was ano run_len and it assumed strings were
regular strings that had to be nul terminated... then it might be ok,
but not here.

of course if i put in guards for these +1's then it ends up in
infintie loops, so enough debugging and send it back for a rethink. :)

....

Revert "evas_object_textblock: add support for variation sequences"

This reverts commit 46f2d8acdc.
2019-10-31 12:31:52 +00:00
Ali Alzyod 46f2d8acdc evas_object_textblock: add support for variation sequences
Summary: update font processing to handle variation sequences unicodes to select proper glypg in respect to variation seqences

Test Plan:
```
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <Eina.h>
#include <Efl.h>
#include <Elementary.h>

EAPI_MAIN int
elm_main(int argc, char **argv)
{
   Evas_Object *win, *textblock;

   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);

   win = elm_win_util_standard_add("Main", "");
   elm_win_autodel_set(win, EINA_TRUE);
   textblock = evas_object_textblock_add(win);
   efl_canvas_text_style_set(textblock,NULL,"DEFAULT='font=DejaVuSans font_fallbacks=SamsungColorEmoji color=#000 font_size=20'");
   evas_object_textblock_text_markup_set(textblock, "8&#xfe0f;&#x20E3;&#x262a;&#xfe0f;AAA&#x262a;&#xfe0E;1234567&#xfe0f;&#x20E3;");

   evas_object_size_hint_weight_set(textblock, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   evas_object_size_hint_align_set(textblock, EVAS_HINT_FILL, EVAS_HINT_FILL);
   evas_object_show(textblock);
   evas_object_move(textblock, 0, 0);
   evas_object_resize(textblock, 320, 320);
   evas_object_resize(win, 320, 320);
   evas_object_show(win);
   elm_run();
   return 0;

}

ELM_MAIN()

```

Reviewers: woohyun, bowonryu, segfaultxavi, cedric, bu5hm4n

Reviewed By: woohyun, cedric

Subscribers: bu5hm4n, subodh6129, herdsman, segfaultxavi, zmike, cedric, #committers, #reviewers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9053
2019-10-19 14:01:36 +09:00
Ali Alzyod e08ca17488 evas_textblock: markup text: improve handling invalide escape characters
Improve handling invalid escape characters.

(*) When '&' character founded in Markup text.
      Old Behavior   : Any text after '&' (if it is not escape), all text will be discarded
      New Behavior : Any text after '&' (if it is not escape), will be processes as normal plain text.

Example:
     Markup  Text :  Hello X & Y & Z 1 2 3
     Old     output :  Hello
     New   output :  Hello X & Y & Z 1 2 3

This is related to T8077

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D9489
2019-08-19 11:33:25 -07:00
Ali Alzyod 32cffb4494 evas_textblock: change font-size/font-family only using EFL.Text.Font Interface
Currently:
User cannot change font size only, he needs to set both font and font size with (**efl_text_font_font_set**)
To change size only, you need to make two calls, one to get font (**efl_text_font_font_get**) , then pass it again with new size to (**efl_text_font_font_set**).

New Behaviour:
If user want to change size only, then he passes NULL as font argument to keep same font.
If user want to change font only, then he passes 0 as font-size argument, to keep same font-size.

Notes:
This is not best solution, but it better than current behaviour.
I think best solution to have separate function to set font size, but It might break current api or duplicate functions.

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D9158
2019-07-31 10:54:55 -07:00
Marcel Hollerbach 6883087ac7 Revert "evas_object_textblock: add support for variation sequences"
This reverts commit f7ce771e32.
2019-07-30 19:09:12 +02:00
Ali Alzyod f7ce771e32 evas_object_textblock: add support for variation sequences
update font processing to handle variation sequences unicodes to select proper glypg in respect to variation seqences

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D9053
2019-07-29 11:17:35 -07:00
Woochanlee fdfb781e22 evas_object_textblock: Fix binary search fail.
D8610 Makes API Testcase fault.

"&lt" is never searching.

@fix

Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D8803
2019-05-02 18:14:43 +02:00
Mike Blumenkrantz 9aca866fd1 efl.text_markup: move cursor-related methods to efl.text_markup_interactive
many users of the markup property are not interactive text cases, so splitting
off the interactive methods resolves a number of unimplemented method issues

ref T5719

Differential Revision: https://phab.enlightenment.org/D7787
2019-01-30 13:32:04 +01:00
Chris Michael 26caf1641f evas_test_textblock: Fix unused variable warning
In evas_textblock_cursor test, the variable 'dir' is only used if
HAVE_FRIBIDI is defined. If that is not defined, then we get an unused
variable warning when compiling. This patch wraps the variable around
an #ifdef so that it does not get declared without FRIBIDI support.
2019-01-29 11:03:09 -05:00
Daniel Hirt de72dd5730 Evas textblock: fix test to use provided hyphen dictionary
This fixes the test suite so it does not rely on the system's dictionary
files.

Fixes T7466
2018-11-16 11:21:53 +02:00
Youngbok Shin 09da85807a evas textblock: remove white space after line-break by a next item
Summary:
In some cases, white space at end of line is remained after line-break.
This issue is happened when Textblock do word wrap at the next item. Without
spliting a previous text item. Then, Textblock just skipped calling
_layout_item_text_split_strip_white() function.

This patch also fixed a wrong test case based on wrong logic.
The range rectangles shouldn't be overlapped. Because of remained white space,
a meaningless rectangle was added. And it overlapped by next rectangle.
@fix

Test Plan:
Fixed an exising test case for range renctangles.
Run test case.

Reviewers: herdsman, woohyun, raster, cedric, subodh, subodh6129

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D7204
2018-11-14 10:48:54 +02:00
Daniel Hirt 9903e7d556 Text: add markup_range_get
This allows to retrieve the markup representation of the current text.

@feature
2018-11-05 17:31:06 +02:00
Daniel Hirt 2caa38f166 Canvas text: fix line_jump_by logic
Some cases of line_jump_by did not emit "cursor,changed" when it should
have.

@fix
2018-11-05 17:31:06 +02:00
Yeongjong Lee 02d83ebcd4 docs: Fix typos in API reference doc and comments.
Reviewers: Hermet, segfaultxavi

Reviewed By: Hermet, segfaultxavi

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D6948
2018-08-31 17:45:31 +09:00
Youngbok Shin 517018e008 evas textblock: add/apply cursor cluster APIs based on grapheme cluster
Summary:
Add a feature for moving cursor over a grapheme cluster.
It is applied to edje_entry.c and elm_entry.c for improving
cursor handling just like other modern text editors. ex) gedit
The patch on Evas needs to update libunibreak library.
So, the patch will update libunibreak, too.
@feature

Test Plan:
1. Put "ഹലോ" in your entry.
2. Your cursor can reach at the end of text from the beginning
   only in 2 right key event with this feature.

Reviewers: raster, cedric, jpeg, herdsman, zmike, devilhorns

Reviewed By: herdsman, zmike

Subscribers: #reviewers, #committers, zmike, bowonryu, woohyun

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D5490
2018-08-20 10:29:32 -04:00
Youngbok Shin f6acd6f9e4 Evas Textblock: Don't convert <br/> to <ps/> after changing text
Summary:
It was only happened when legacy newline is enabled. By default,
legacy newline is enabled. As I know, legacy newline option has
to change textblock's internal behavior. But, it shouldn't change
the given original text. It fixes T3399.

Test Plan: A Test case is included in Evas test suite.

Reviewers: Jaehyun_Cho, z-wony, tasn, woohyun, herdsman, Blackmole, devilhorns

Subscribers: #committers, zmike, raster, cedric, jpeg

Tags: #efl

Maniphest Tasks: T3399

Differential Revision: https://phab.enlightenment.org/D3874
2018-07-02 18:33:45 +03:00
Youngbok Shin f17cae08e6 evas textblock: manage default style properly for new interfaces
Summary:
Calling efl_canvas_text_style_set() with empty key means
setting a default style to object. But, it counldn't store style
as default properly. It caused a crash issue from elementary_test.
@fix

Test Plan:
New test case is included. Run test suite. Or,
1. Run elementary_test
2. Find and launch "Image Zoomable animation" test.
3. Close the image test window.
4. See the crash issue.

Reviewers: raster, herdsman, jpeg, cedric, zmike

Subscribers: zmike

Tags: #efl

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

Committer's note: rebased and removed unrelated test.
2018-05-16 22:24:11 +03:00
Youngbok Shin f437a3075a evas textblock: update format nodes when a Evas Textblock Style is updated
Summary:
A style tag among a text has to be replcaed by its matched tag when
a format node is created. If the matched tag is changed, format nodes
should be updated.
But, if a style text for Evas Textblock Style is changed,
related format nodes are not updated without setting new text.
The patch changes to update format nodes when new style text is set.
@fix

Test Plan: Included in Evas Test Suite.

Reviewers: raster, tasn, herdsman, subodh6129, zmike

Subscribers: zmike, cedric, z-wony, Blackmole

Tags: #efl

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

Committer's note: rebased.
2018-05-16 22:24:11 +03:00
Youngbok Shin 73c39bcf12 Evas textblock: fix wrong hyphenation issues with non UTF8 encoded dictionary
Summary:
hnj_hyphen_hyphenate2() needs properly encoded text based on the given
dictionary. Each dictionary contains its encoding information at the head
of file. So, text will be converted to proper encoding before calling
the function. It fixes T3221.
@fix

Test Plan: Included in Evas test suite.

Reviewers: z-wony, tasn, woohyun, herdsman, Blackmole, minudf

Subscribers: zmike, stefan_schmidt, raster, cedric, jpeg

Tags: #efl

Maniphest Tasks: T3221

Differential Revision: https://phab.enlightenment.org/D3863
2018-05-06 12:01:41 +03:00
Youngbok Shin c33ef15d5d evas textblock: fix double free issue from user style push/pop and free
Summary: The Textblock Style which is created for user style was managed
application side.  It is created and free'd from application - outside
of Evas Textblock.  Recently, evas_object_textblock_style_user_push/pop
start to call efl_canvas_text_style_set() instead of legacy code. The
problem is efl_canvas_text_style_set() is always going to call free()
when a style is going to be deleted.  It makes conflicts(double free
issue) with application which is used to call
evas_textblock_style_free().  So, the issue will be fixed by this patch.

The patch also revise push/pop/peek code to make clean and avoid
meaningless calculation/events.

@fix

Test Plan:
A test case is Included in this patch.
The test case try to trigger double free.

Reviewers: herdsman, raster, cedric

Subscribers: zmike, woohyun

Tags: #efl

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

Committer's note: formatted commit summary (80 width).
2018-05-06 12:01:41 +03:00
Xavi Artigas 55bd097a3d Efl.Gfx.Entity (from Efl.Gfx)
Ref https://phab.enlightenment.org/T6847

Reviewed-by: Cedric Bail <cedric@osg.samsung.com>
2018-04-24 09:03:32 -07:00
Mike Blumenkrantz 624925fe6e tests: move to using checked fixtures for all test suites
individual tests should not need to explicitly call init/shutdown functions
in most cases, and many did not properly do this anyway

see followup commit which resolves some issues with eina tests

ref T6813
ref T6811

Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
2018-04-05 11:10:26 +02:00
Mike Blumenkrantz adc601aca2 tests: add instrumentation to existing tests to find slow tests
efl_check.h must be included and the EFL_START/END_TEST macros must be
used in place of normal START/END_TEST macros

timing is enabled when TIMING_ENABLED is set
https://phab.enlightenment.org/w/improve_tests/

Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>
2018-04-05 11:10:25 +02:00
Daniel Hirt 4a905a22a4 Canvas image: add Efl.Canvas.Text.Factory + use in Ui.Text
This interface has a simple 'create' method to create Efl.Canvas.Object
given a key.
This is used higher-up in Ui.Text in the next commit.

Ui text: add ability to set item factories

Added API to set an item factory object.
This is similar to the previous item providers (that worked with
callbacks).

You instantiate a factory object and set it on the Ui.Text object.
Each factory implements the "create" method from
Efl.Canvas.Text.Item_Factory.

This also includes 3 public factories (Image, Emoticon and Fallback):
  - Image factory: creates images from added entries (key strings)
  - Emoticon factory: creates emoticons by querying the theme
  - Fallback: creates image, then falls back to emoticon

If no factory is set, then the fallback (internal) factory is used.

See the added "Ui.text Item Factory" test in elementary_test for an
example of usage.

@feature
2018-01-18 10:20:28 -08:00
Carsten Haitzler e30fb6945e fix evas test suite to now init both ecore and evas.... correctly.
see c8dcc4327b803e9b8ad2a0985e756c924946c442 - basicall evas depends
on ecore these days... thus requires ecore be initted THEN evas. ...
which in theory is an abi break for those using evas and ONLY evas
long ago from when efl was separate... but it''s how we're building
these days.

@fix
2018-01-05 02:34:16 +09:00
Daniel Hirt 45d3614345 Canvas text: fix width calculation with style effects
There are multiple places in the code where both the padded item's
width and the maximum style padding (at the edges) are accounted for.
For the sake of making calculations for wrapping/ellipsis we should
only use the maximum style padding.

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2017-11-10 10:29:49 -08:00
Daniel Hirt 0725ff620b Canvas text: update style pad when no format nodes are present
This updates the style pad even if there are no format nodes.
An example of this is having a default style set to the object.

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
2017-11-10 10:29:44 -08:00
Youngbok Shin a386597ad9 evas textblock: handle ellipsis when text's height exceed its area by "br"
Summary:
Textblock's ellipsis feature only worked when text's width exceeds its area.
So, it didn't work when text's height exceeds its area by "br" tags.
This patch will do ellipsis when only ellipsis=1.0 is set.
@fix

Test Plan: make check

Reviewers: herdsman, raster, cedric, jpeg, sohyun

Reviewed By: raster

Subscribers: woohyun

Differential Revision: https://phab.enlightenment.org/D5412
2017-11-06 11:29:43 +09:00
Jean-Philippe Andre 4c634ed78e efl: Use Eina.Size2D for Efl.Gfx.size
Big patch as a lot of things call or reimplement size_set. Hopefully I
got it right... fingers crossed.
2017-09-18 13:34:50 +09:00
Daniel Hirt 048dcc3263 Canvas text: fix non-dirty paragraph width calculation
Follow-up fix for 1624417d91.
Changed for a max comparison, rather than just assigning the line's
width.
Also, added a test case.

Fixes T5939

@fix
2017-08-29 17:07:15 +03:00
Daniel Hirt 4923945f81 Text: move Annotation type to Efl.Text.Annotate namespace 2017-07-17 17:38:28 +03:00
Daniel Hirt d5f781da2b Efl text: replace all usages of cursor handle to same type
Changes cursor handle name from 'Efl.Text.Cursor.Cursor_Data' to
'Efl.Text.Cursor.Cursor'.
Also, replace all usages of Efl_Canvas_Text_Cursor
with Efl_Text_Cursor_Cursor as the handle for the cursor.
2017-07-17 16:51:45 +03:00
Jean-Philippe Andre e8b35c779e evas: Add a test case with a custom font
The font is **ugly** and was created with birdfont. Its license
shall be anything EFL requires (public domain in the ttf file).
2017-07-11 16:21:29 +09:00
Youngbok Shin f29dfe2789 evas textblock: fix evas test suite build errors
Summary:
Fix build errors caused by recent patches for Text cursor.
@fix

Test Plan: run "make check"

Reviewers: herdsman, jpeg, raster

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D4957
2017-06-12 16:31:04 +03:00
Daniel Hirt 49b838c448 Canvas text cursor: move to Efl.Canvas.Text namespace
Originally it was its own object.
There are some valid claims that there is no justification for it to
remain an object.
Furthermore, it's apparent that it added little benefit: changes of
each cursors, in practice, triggered a query for all objects of the
same textblock. There wasn't real advantage to have a finer resolution
of controlling the cursors with their own events.

This ports back a lot of code, and changes a lot of other code in the
higher-up widgets, such as Efl.Ui.Text and co.

The usage was replaces from:
  efl_canvas_text_cursor_char_next(cur_obj)
to
  efl_canvas_text_cursor_char_next(text_obj, cur_obj)
that is, it is an operations on the TEXT OBJECT, rather than on the
(now removed) cursor object.

So, one less efl object to worry about now.
Hopefully, the port went smooth.
2017-06-11 23:58:52 +03:00
Daniel Hirt 1624417d91 Evas textblock: fix width calculation of non-dirty paragraphs
This reverts commit 0a28cb97af, as the
addressed issue was still occurring.
Non-dirty paragraphs were not considered when recalculating the
formatted width of the text.
This could easily be reproduced with two paragraphs, getting the width,
and then updating only the second paragraph.

Added a test case.

@fix
2017-05-23 13:26:32 +03:00
Daniel Hirt 2d44738fae Canvas text: fix ellipsis RTL handling
First, fixing ellipsis text positions: ellipsis items should be assigned the
text positions of the omitted text (while maintaining the formatting of the
last visual item). In the case where an entire item was rejected, it
will be assigned that item's text position. If an item was split, it will be
assigned the text position of the split portion.
The BiDi reorder code relies on properly-assigned text positions.

Second, fixing ellipsis handling: the width calc was only considering the
ellipsis item's width. However, if the ellipsis is placed as e.g. the first
visual item (such as in RTL cases), its advance value should've be considered,
instead.

Thanks Youngbok Shin for the test case and information.

@fix
2016-08-31 16:23:32 +03:00
Daniel Hirt 0d9ddc4514 Canvas text: fix range geometry calculation for RTL
Fixes T3627.

@fix
2016-07-31 10:33:30 +03:00
Daniel Hirt 0c23985626 Canvas text: fix corner case in range geometry calc
The trivial case of [pos,pos] (i.e. range of length 0) didn't work if there is a
format item in 'pos'.
The condition was fixed to not include such items. The reason it was not
apparent for text items is that these have further handling in the rest of the
code and would've been disposed of.

@fix
2016-07-11 16:39:51 +00:00
Youngbok Shin 64e0dc341d Evas textblock: Apply scale factor to <linesize>, <linegap> formats
Summary:
Font size is scaled according to scale factor.
The linesize, linegap formats also have to be scaled properly.
@fix

Test Plan:
Test cases are included.
Run "make check"

Reviewers: woohyun, Jieun, tasn, herdsman

Reviewed By: tasn

Subscribers: raster, cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D3688
2016-07-11 17:57:40 +09:00
Daniel Hirt 06fd1566ea Canvas text cursor: fix bug after code port
Fixes T4005.
Also, unified repeated code and added a test for multiple cursors.
2016-07-03 14:39:45 +00:00
Daniel Hirt dbbb4bf8ad Canvas text: revert new behavior on text append
This was discussed and still wasn't decided whether this is required to be
supported internally.
The reason for this revert is that the behavior still needs tweaking to work
just right along with the legacy behavior.
2016-06-21 10:40:48 +00:00
Daniel Hirt c9744965c0 Canvas test: remove style test for now 2016-06-16 19:15:20 +01:00
Daniel Hirt ed512ea49e Canvas Text: continue porting api and fixup bugs
Also: This merges style user and normal style into a list with precedence. This
allows for more flexibility while keeping the API clean.

@feature
2016-06-16 19:15:20 +01:00
Tom Hacohen c297ff4115 Canvas text cursor: introduce this new object
The text cursor is now an eo object. Consult the efl_canvas_text_cursor.eo file
for the API.

@feature
2016-06-16 19:15:20 +01:00
Daniel Hirt 3a6c648d28 Canvas text: introduce new text object
The implementation depends on creating different code paths from the now-legacy
behavior of text appending.

The annotation system introduced in this commit replaces the current way of
applying formats on text.
Up until now it has been quite a hassle for the user to control the formats, as
it required keeping track of the format positions with an opener and closer
formats almost every time (with the exception of own-closing formats).

The combination of Efl.Text API along with the Efl.Canvas.Text annotation API
essentially replaces the capabilities of the old format.

There is additional annotation API to allow more control, so be sure to check
the documentation/.eo files and the wiki page of Efl.Canvas.Text.

The style API now accepts actual strings of format style. There is not longer
need to instantiate as style with style_new() followed later by style_free().

@feature
2016-06-16 19:15:20 +01:00
Youngbok Shin f4f9753c20 Evas: Add API to reinit the language and use it in elementary.
Summary:
evas_common_language_from_locale_* functions kept static pointers
inside of its functions. Once these function was called, it was never reset.
It made big problems for harfbuzz and hyphenation. Also, Elementary
provides elm_language_set() API. Then we need to support it fully.
@fix

Test Plan: Test case for hyphenation is included in Evas test suite.

Reviewers: raster, tasn, herdsman, woohyun, z-wony, Blackmole, minudf

Subscribers: cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D3864
2016-04-08 11:24:32 +01:00
Jiwon Kim c23283944b Evas textblock: fix null-derefernce in _style_match_tag()
Summary:
add null check in _style_match_tag()
if evas_object_textblock_text_markup_set() is called with markup text before setting style,
segmentation fault is occurred in _style_match_tag()
@fix

Test Plan:
Insert this situation to test suite
 -> test id : evas_textblock_simple

Test for without this patch:
 1. apply patch just "src/tests/evas/evas_test_textblock.c" partially.
 2. $make check

Test for with this patch:
 1. apply this patch completely (2 files)
 2. $make check

Reviewers: id213sin, herdsman

Subscribers: Blackmole, cedric, jpeg

Projects: #efl

Differential Revision: https://phab.enlightenment.org/D3818
2016-03-24 10:17:57 +02:00