Imported Upstream version 1.7.1
[platform/upstream/edje.git] / src / lib / edje_text.c
1 #include "edje_private.h"
2 #define _ELLIP_STR "\xE2\x80\xA6"
3
4 /* returns with and height for this part.
5  *
6  * depending on the value of the use_alternate_font_metrics flag, it will
7  * either use evas_object_geometry_get() or the _advance_get() functions.
8  *
9  * The latter is useful if you want to make sure that width and height
10  * are the same value for the same number of characters in the text.
11  * This usually only makes sense for monospaced fonts.
12  *
13  * In future changes to this file, you probably should use this wrapper
14  * function everywhere instead of calling evas_object_geometry_get()
15  * directly.
16  */
17 static inline void
18 part_get_geometry(Edje_Real_Part *rp, Evas_Coord *w, Evas_Coord *h)
19 {
20    if (!rp->part->use_alternate_font_metrics)
21      evas_object_geometry_get(rp->object, NULL, NULL, w, h);
22    else
23      {
24         if (w) *w = evas_object_text_horiz_advance_get(rp->object);
25         if (h) *h = evas_object_text_vert_advance_get(rp->object);
26      }
27 }
28
29 void
30 _edje_text_init(void)
31 {
32 }
33
34 void
35 _edje_text_part_on_add(Edje *ed, Edje_Real_Part *ep)
36 {
37    Edje_Part *pt = ep->part;
38    Edje_Part_Description_Text *desc;
39    unsigned int i;
40
41    if (ep->part->type != EDJE_PART_TYPE_TEXT) return;
42
43    /* if text class exists for this part, add the edje to the tc member list */
44    desc = (Edje_Part_Description_Text *) pt->default_desc;
45    if ((pt->default_desc) && (desc->text.text_class))
46      _edje_text_class_member_add(ed, desc->text.text_class);
47
48    /* If any other classes exist add them */
49    for (i = 0; i < pt->other.desc_count; ++i)
50      {
51         desc = (Edje_Part_Description_Text *) pt->other.desc[i];
52         if ((desc) && (desc->text.text_class))
53           _edje_text_class_member_add(ed, desc->text.text_class);
54      }
55 }
56
57 void
58 _edje_text_part_on_del(Edje *ed, Edje_Part *pt)
59 {
60    Edje_Part_Description_Text *desc;
61    unsigned int i;
62
63    if (!pt) return;
64    if (pt->type != EDJE_PART_TYPE_TEXT
65        && pt->type != EDJE_PART_TYPE_TEXTBLOCK)
66      return ;
67
68    desc = (Edje_Part_Description_Text *) pt->default_desc;
69    if ((pt->default_desc) && (desc->text.text_class))
70      _edje_text_class_member_del(ed, desc->text.text_class);
71
72    for (i = 0; i < pt->other.desc_count; ++i)
73      {
74         desc = (Edje_Part_Description_Text *) pt->other.desc[i];
75         if (desc->text.text_class)
76           _edje_text_class_member_del(ed, desc->text.text_class);
77      }
78 }
79
80 static void
81 _edje_text_fit_set(char *buf, const char *text, int c1, int c2)
82 {
83    /* helper function called from _edje_text_fit_x().
84     * note that we can use strcpy()/strcat() safely, the buffer lengths
85     * are checked in the caller.
86     */
87
88    if (c1 >= 0)
89      {
90         strcpy(buf, _ELLIP_STR);
91
92         if (c2 >= 0)
93           {
94              strncat(buf, text + c1, c2 - c1);
95              strcat(buf, _ELLIP_STR);
96           }
97         else
98           strcat(buf, text + c1);
99      }
100    else
101      {
102         if (c2 >= 0)
103           {
104              strncpy(buf, text, c2);
105              buf[c2] = 0;
106              strcat(buf, _ELLIP_STR);
107           }
108         else
109           strcpy(buf, text);
110      }
111 }
112
113 static const char *
114 _edje_text_fit_x(Edje *ed, Edje_Real_Part *ep,
115                  Edje_Calc_Params *params,
116                  const char *text, const char *font, int size,
117                  Evas_Coord sw, int *free_text)
118 {
119    Evas_Coord tw = 0, th = 0, p;
120    int l, r;
121    int i;
122    char *buf;
123    int uc1 = -1, uc2 = -1, c1 = -1, c2 = -1;
124    int loop = 0, extra;
125    size_t orig_len;
126    FLOAT_T sc;
127
128    sc = ed->scale;
129    if (sc == ZERO) sc = _edje_scale;
130
131    *free_text = 0;
132    if (sw <= 1) return "";
133
134    if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
135    evas_object_text_font_set(ep->object, font, size);
136    evas_object_text_text_set(ep->object, text);
137
138    part_get_geometry(ep, &tw, &th);
139    evas_object_text_style_pad_get(ep->object, &l, &r, NULL, NULL);
140
141    p = ((sw - tw) * params->type.text.elipsis);
142
143    /* chop chop */
144    if (tw > sw)
145      {
146         if (params->type.text.elipsis != 0.0)
147           /* should be the last in text! not the rightmost */
148           uc1 = evas_object_text_last_up_to_pos(ep->object,
149                 -p + l, th / 2);
150         if (params->type.text.elipsis != 1.0)
151           {
152              /* should be the last in text! not the rightmost */
153              if ((-p + sw -r) < 0)
154                 uc2 = evas_object_text_last_up_to_pos(ep->object, 0, th / 2);
155              else
156                 uc2 = evas_object_text_last_up_to_pos(ep->object,
157                       -p + sw - r, th / 2);
158           }
159         if ((uc1 < 0) && (uc2 < 0))
160           {
161              uc1 = 0;
162              uc2 = 0;
163           }
164      }
165
166    if (!(((uc1 >= 0) || (uc2 >= 0)) && (tw > sw)))
167      return text;
168
169    if ((uc1 == 0) && (uc2 == 0))
170      return text;
171
172    orig_len = strlen(text);
173
174    /* don't overflow orig_len by adding extra
175     * FIXME: we might want to set a max string length somewhere...
176     */
177    extra = 1 + 3 + 3; /* terminator, leading and trailing ellipsis */
178    orig_len = MIN(orig_len, ((size_t) 8192 - extra));
179
180    if (!(buf = malloc(orig_len + extra)))
181      return text;
182
183    /* Convert uc1, uc2 -> c1, c2 */
184    i = 0;
185    if (uc1 >= 0)
186      {
187         c1 = 0;
188         for ( ; i < uc1 ; i++)
189           {
190              c1 = evas_string_char_next_get(text, c1, NULL);
191           }
192      }
193    if (uc2 >= 0)
194      {
195         if (c1 >= 0)
196           {
197              c2 = c1;
198           }
199         else
200           {
201              c2 = 0;
202           }
203         for ( ; i < uc2 ; i++)
204           {
205              c2 = evas_string_char_next_get(text, c2, NULL);
206           }
207      }
208
209    buf[0] = '\0';
210
211    while (((c1 >= 0) || (c2 >= 0)) && (tw > sw))
212      {
213         loop++;
214         if (sw <= 0.0)
215           {
216              buf[0] = 0;
217              break;
218           }
219         if ((c1 >= 0) && (c2 >= 0))
220           {
221              if ((loop & 0x1))
222                {
223                   if (c1 >= 0)
224                     c1 = evas_string_char_next_get(text, c1, NULL);
225                }
226              else
227                {
228                   if (c2 >= 0)
229                     {
230                        c2 = evas_string_char_prev_get(text, c2, NULL);
231                        if (c2 < 0)
232                          {
233                             buf[0] = 0;
234                             break;
235                          }
236                     }
237                }
238           }
239         else
240           {
241              if (c1 >= 0)
242                c1 = evas_string_char_next_get(text, c1, NULL);
243              else if (c2 >= 0)
244                {
245                   c2 = evas_string_char_prev_get(text, c2, NULL);
246                   if (c2 < 0)
247                     {
248                        buf[0] = 0;
249                        break;
250                     }
251                }
252           }
253         if ((c1 >= 0) && (c2 >= 0))
254           {
255              if (c1 >= c2)
256                {
257                   buf[0] = 0;
258                   break;
259                }
260           }
261         else if ((c1 > 0 && (size_t) c1 >= orig_len) || c2 == 0)
262           {
263              buf[0] = 0;
264              break;
265           }
266
267         buf[0] = 0;
268
269         _edje_text_fit_set(buf, text, c1, c2);
270
271         evas_object_text_text_set(ep->object, buf);
272         part_get_geometry(ep, &tw, &th);
273      }
274
275    *free_text = 1;
276
277    return buf;
278 }
279
280 static const char *
281 _edje_text_font_get(const char *base, const char *new, char **free_later)
282 {
283    const char *base_style, *new_style, *aux;
284    size_t font_len, style_len;
285
286    if (base && (!new))
287      return base;
288    else if (!base)
289      return new;
290
291    base_style = strstr(base, ":style=");
292    if (!base_style)
293      return new;
294
295    new_style = strstr(new, ":style=");
296    if (new_style)
297      return new;
298
299    font_len = strlen(new);
300    aux = strchr(base_style, ',');
301    style_len = (aux) ? (size_t)(aux - base_style) : strlen(base_style);
302
303    *free_later = malloc(font_len + style_len + 1);
304    memcpy(*free_later, new, font_len);
305    memcpy(*free_later + font_len, base_style, style_len);
306    (*free_later)[font_len + style_len] = '\0';
307
308    return *free_later;
309 }
310
311 const char *
312 _edje_text_class_font_get(Edje *ed, Edje_Part_Description_Text *chosen_desc, int *size, char **free_later)
313 {
314    Edje_Text_Class *tc;
315    const char *text_class_name, *font;
316
317    font = edje_string_get(&chosen_desc->text.font);
318    *size = chosen_desc->text.size;
319
320    text_class_name = chosen_desc->text.text_class;
321    if ((!text_class_name) || (!text_class_name[0]))
322      return font;
323
324    tc = _edje_text_class_find(ed, text_class_name);
325    if (!tc)
326      return font;
327
328    font = _edje_text_font_get(edje_string_get(&chosen_desc->text.font), tc->font, free_later);
329    *size = _edje_text_size_calc(*size, tc);
330
331    return font;
332 }
333
334 void
335 _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
336                         Edje_Calc_Params *params,
337                         Edje_Part_Description_Text *chosen_desc)
338 {
339    const char   *text = NULL;
340    const char   *font;
341    char         *font2 = NULL;
342    char         *sfont = NULL;
343    int           size;
344    Evas_Coord    tw, th;
345    Evas_Coord    sw, sh;
346    int           inlined_font = 0, free_text = 0;
347    Eina_Bool     same_text = EINA_FALSE;
348    FLOAT_T       sc;
349
350    sc = ed->scale;
351    if (sc == 0.0) sc = _edje_scale;
352    text = edje_string_get(&chosen_desc->text.text);
353    font = _edje_text_class_font_get(ed, chosen_desc, &size, &sfont);
354
355    if (ep->text.text) text = ep->text.text;
356    if (ep->text.font) font = ep->text.font;
357    if (ep->text.size > 0) size = ep->text.size;
358
359    if (ep->text.text_source)
360      {
361         text = edje_string_get(&(((Edje_Part_Description_Text *)ep->text.text_source->chosen_description)->text.text));
362         if (ep->text.text_source->text.text) text = ep->text.text_source->text.text;
363      }
364    if (ep->text.source)
365      {
366         font = edje_string_get(&(((Edje_Part_Description_Text *)ep->text.source->chosen_description)->text.font));
367         size = ((Edje_Part_Description_Text *)ep->text.source->chosen_description)->text.size;
368         if (ep->text.source->text.font) font = ep->text.source->text.font;
369         if (ep->text.source->text.size > 0) size = ep->text.source->text.size;
370      }
371
372    if (!text) text = "";
373    if (!font) font = "";
374
375    /* check if the font is embedded in the .eet */
376    if (ed->file->fonts)
377      {
378         Edje_Font_Directory_Entry *fnt = eina_hash_find(ed->file->fonts, font);
379
380         if (fnt)
381           {
382              size_t len = strlen(font) + sizeof("edje/fonts/") + 1;
383              font2 = alloca(len);
384              sprintf(font2, "edje/fonts/%s", font);
385              font = font2;
386              inlined_font = 1;
387              font2 = NULL;
388           }
389      }
390
391    if ((_edje_fontset_append) && (font))
392      {
393         font2 = malloc(strlen(font) + 1 + strlen(_edje_fontset_append) + 1);
394         if (font2)
395           {
396              strcpy(font2, font);
397              strcat(font2, ",");
398              strcat(font2, _edje_fontset_append);
399              font = font2;
400           }
401      }
402      {
403         int l, r, t, b;
404
405         evas_object_text_style_pad_get(ep->object, &l, &r, &t, &b);
406         sw = params->w;
407         sh = params->h;
408      }
409
410    size = params->type.text.size;
411    if (!text) text = "";
412
413    if ((text == ep->text.cache.in_str)
414        || (text && ep->text.cache.in_str && !strcmp(ep->text.cache.in_str, text)))
415      {
416         text = ep->text.cache.in_str;
417         same_text = EINA_TRUE;
418      }
419
420    if ((ep->text.cache.in_size == size) &&
421        (ep->text.cache.in_w == sw) &&
422        (ep->text.cache.in_h == sh) &&
423        (ep->text.cache.in_str) &&
424        same_text &&
425        (ep->text.cache.align_x == params->type.text.align.x) &&
426        (ep->text.cache.align_y == params->type.text.align.y) &&
427        (ep->text.cache.elipsis == params->type.text.elipsis) &&
428        (ep->text.cache.fit_x == chosen_desc->text.fit_x) &&
429        (ep->text.cache.fit_y == chosen_desc->text.fit_y))
430      {
431         text = ep->text.cache.out_str;
432         size = ep->text.cache.out_size;
433
434         goto arrange_text;
435      }
436    if (!same_text)
437      {
438         eina_stringshare_replace(&ep->text.cache.in_str, text);
439      }
440    ep->text.cache.in_size = size;
441    if (chosen_desc->text.fit_x && (ep->text.cache.in_str && eina_stringshare_strlen(ep->text.cache.in_str) > 0))
442      {
443         if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
444         else evas_object_text_font_source_set(ep->object, NULL);
445
446         if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
447         evas_object_text_font_set(ep->object, font, size);
448         evas_object_text_text_set(ep->object, text);
449         part_get_geometry(ep, &tw, &th);
450         /* Find the wanted font size */
451         if ((tw != sw) && (size > 0) && (tw != 0))
452           {
453              size = (size * sw) / tw;
454
455              if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
456              else evas_object_text_font_source_set(ep->object, NULL);
457
458              if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
459              evas_object_text_font_set(ep->object, font, size);
460              part_get_geometry(ep, &tw, &th);
461           }
462
463         /* FIXME: This should possibly be replaced by more proper handling,
464          * but it's still way better than what was here before. */
465         if (tw > sw) size--;
466      }
467    if (chosen_desc->text.fit_y && (ep->text.cache.in_str && eina_stringshare_strlen(ep->text.cache.in_str) > 0))
468      {
469         /* if we fit in the x axis, too, size already has a somewhat
470          * meaningful value, so don't overwrite it with the starting
471          * value in that case
472          */
473         if (!chosen_desc->text.fit_x) size = sh;
474
475         if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
476         else evas_object_text_font_source_set(ep->object, NULL);
477
478         if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
479         evas_object_text_font_set(ep->object, font, size);
480         evas_object_text_text_set(ep->object, text);
481         part_get_geometry(ep, &tw, &th);
482
483         /* only grow the font size if we didn't already reach the max size
484          * for the x axis
485          */
486         if (!chosen_desc->text.fit_x && th < sh)
487           {
488              int dif;
489
490              dif = (th - sh) / 4;
491              if (dif < 1) dif = 1;
492              while ((th < sh) && (sw > 0))
493                {
494                   size += dif;
495                   if (size <= 0) break;
496                   if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
497                   else evas_object_text_font_source_set(ep->object, NULL);
498
499                   if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
500                   evas_object_text_font_set(ep->object, font, size);
501                   part_get_geometry(ep, &tw, &th);
502                   if ((size > 0) && (th == 0)) break;
503                }
504              size -= dif;
505           }
506         else if (th > sh)
507           {
508              int current;
509
510              if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
511              evas_object_text_font_set(ep->object, font, 10);
512              part_get_geometry(ep, &tw, &th);
513
514              if (th == sh)
515                current = 10;
516              else
517                {
518                   int bottom, top;
519
520                   if (th < sh) bottom = 10;
521                   else if (th > sh) bottom = 1;
522                   else bottom = 0; /* XXX shut up GCC, th == sh is handled before! */
523
524                   top = size;
525                   /* search one that fits (binary search) */
526                   do
527                     {
528                        current = (top + bottom) / 2;
529
530                        if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
531                        evas_object_text_font_set(ep->object, font, current);
532                        part_get_geometry(ep, &tw, &th);
533
534                        if      (th < sh) bottom = current + 1;
535                        else if (th > sh) top    = current - 1;
536                     } while ((bottom < top) && (th != sh));
537                }
538
539              /* search the larger one that fits (linear search) */
540              do
541                {
542                   current++;
543
544                   if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
545                   evas_object_text_font_set(ep->object, font, current);
546                   part_get_geometry(ep, &tw, &th);
547                } while (th <= sh);
548              size = current - 1;
549           }
550      }
551
552    /* Make sure the size is in range */
553    if (size < 1)
554       size = 1;
555    else if ((size > chosen_desc->text.size_range_max) &&
556             (chosen_desc->text.size_range_max > 0))
557       size = chosen_desc->text.size_range_max;
558    else if (size < chosen_desc->text.size_range_min)
559       size = chosen_desc->text.size_range_min;
560
561    /* Handle ellipsis */
562    if (!chosen_desc->text.min_x)
563      {
564         if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
565         else evas_object_text_font_source_set(ep->object, NULL);
566
567         text = _edje_text_fit_x(ed, ep, params, text, font, size, sw, &free_text);
568      }
569
570    eina_stringshare_replace(&ep->text.cache.out_str, text);
571    ep->text.cache.in_w = sw;
572    ep->text.cache.in_h = sh;
573    ep->text.cache.out_size = size;
574    ep->text.cache.align_x = params->type.text.align.x;
575    ep->text.cache.align_y = params->type.text.align.y;
576    ep->text.cache.elipsis = params->type.text.elipsis;
577    ep->text.cache.fit_x = chosen_desc->text.fit_x;
578    ep->text.cache.fit_y = chosen_desc->text.fit_y;
579    arrange_text:
580
581    if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
582    else evas_object_text_font_source_set(ep->object, NULL);
583
584    if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
585    evas_object_text_font_set(ep->object, font, size);
586    evas_object_text_text_set(ep->object, text);
587    part_get_geometry(ep, &tw, &th);
588    /* Handle alignment */
589      {
590         FLOAT_T align_x;
591         if (params->type.text.align.x < FROM_INT(0))
592           {
593              if (evas_object_text_direction_get(ep->object) ==
594                    EVAS_BIDI_DIRECTION_RTL)
595                {
596                   align_x = FROM_INT(1);
597                }
598              else
599                {
600                   align_x = FROM_INT(0);
601                }
602           }
603         else
604           {
605              align_x = params->type.text.align.x;
606           }
607         ep->text.offset.x = TO_INT(SCALE(align_x, (sw - tw)));
608         ep->text.offset.y = TO_INT(SCALE(params->type.text.align.y, (sh - th)));
609      }
610
611    evas_object_move(ep->object,
612                     ed->x + params->x + ep->text.offset.x,
613                     ed->y + params->y + ep->text.offset.y);
614
615    if (params->visible) evas_object_show(ep->object);
616    else evas_object_hide(ep->object);
617      {
618         Evas_Text_Style_Type style;
619         Edje_Text_Effect effect;
620
621         style = EVAS_TEXT_STYLE_PLAIN;
622
623         evas_object_color_set(ep->object,
624                               (params->color.r * params->color.a) / 255,
625                               (params->color.g * params->color.a) / 255,
626                               (params->color.b * params->color.a) / 255,
627                               params->color.a);
628         effect = ep->part->effect;
629         switch (effect & EDJE_TEXT_EFFECT_MASK_BASIC)
630           {
631            case EDJE_TEXT_EFFECT_NONE:
632            case EDJE_TEXT_EFFECT_PLAIN:
633              style = EVAS_TEXT_STYLE_PLAIN;
634              break;
635            case EDJE_TEXT_EFFECT_OUTLINE:
636              style = EVAS_TEXT_STYLE_OUTLINE;
637              evas_object_text_outline_color_set(ep->object,
638                                                 (params->type.text.color2.r * params->type.text.color2.a) / 255,
639                                                 (params->type.text.color2.g * params->type.text.color2.a) / 255,
640                                                 (params->type.text.color2.b * params->type.text.color2.a) / 255,
641                                                 params->type.text.color2.a);
642              break;
643            case EDJE_TEXT_EFFECT_SOFT_OUTLINE:
644              style = EVAS_TEXT_STYLE_SOFT_OUTLINE;
645              evas_object_text_outline_color_set(ep->object,
646                                                 (params->type.text.color2.r * params->type.text.color2.a) / 255,
647                                                 (params->type.text.color2.g * params->type.text.color2.a) / 255,
648                                                 (params->type.text.color2.b * params->type.text.color2.a) / 255,
649                                                 params->type.text.color2.a);
650              break;
651            case EDJE_TEXT_EFFECT_SHADOW:
652              style = EVAS_TEXT_STYLE_SHADOW;
653              evas_object_text_shadow_color_set(ep->object,
654                                                (params->type.text.color3.r * params->type.text.color3.a) / 255,
655                                                (params->type.text.color3.g * params->type.text.color3.a) / 255,
656                                                (params->type.text.color3.b * params->type.text.color3.a) / 255,
657                                                params->type.text.color3.a);
658              break;
659            case EDJE_TEXT_EFFECT_SOFT_SHADOW:
660              style = EVAS_TEXT_STYLE_SOFT_SHADOW;
661              evas_object_text_shadow_color_set(ep->object,
662                                                (params->type.text.color3.r * params->type.text.color3.a) / 255,
663                                                (params->type.text.color3.g * params->type.text.color3.a) / 255,
664                                                (params->type.text.color3.b * params->type.text.color3.a) / 255,
665                                                params->type.text.color3.a);
666              break;
667            case EDJE_TEXT_EFFECT_OUTLINE_SHADOW:
668              style = EVAS_TEXT_STYLE_OUTLINE_SHADOW;
669              evas_object_text_outline_color_set(ep->object,
670                                                 (params->type.text.color2.r * params->type.text.color2.a) / 255,
671                                                 (params->type.text.color2.g * params->type.text.color2.a) / 255,
672                                                 (params->type.text.color2.b * params->type.text.color2.a) / 255,
673                                                 params->type.text.color2.a);
674              evas_object_text_shadow_color_set(ep->object,
675                                                (params->type.text.color3.r * params->type.text.color3.a) / 255,
676                                                (params->type.text.color3.g * params->type.text.color3.a) / 255,
677                                                (params->type.text.color3.b * params->type.text.color3.a) / 255,
678                                                params->type.text.color3.a);
679              break;
680            case EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW:
681              style = EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW;
682              evas_object_text_outline_color_set(ep->object,
683                                                 (params->type.text.color2.r * params->type.text.color2.a) / 255,
684                                                 (params->type.text.color2.g * params->type.text.color2.a) / 255,
685                                                 (params->type.text.color2.b * params->type.text.color2.a) / 255,
686                                                 params->type.text.color2.a);
687              evas_object_text_shadow_color_set(ep->object,
688                                                (params->type.text.color3.r * params->type.text.color3.a) / 255,
689                                                (params->type.text.color3.g * params->type.text.color3.a) / 255,
690                                                (params->type.text.color3.b * params->type.text.color3.a) / 255,
691                                                params->type.text.color3.a);
692              break;
693            case EDJE_TEXT_EFFECT_FAR_SHADOW:
694              style = EVAS_TEXT_STYLE_FAR_SHADOW;
695              evas_object_text_shadow_color_set(ep->object,
696                                                (params->type.text.color3.r * params->type.text.color3.a) / 255,
697                                                (params->type.text.color3.g * params->type.text.color3.a) / 255,
698                                                (params->type.text.color3.b * params->type.text.color3.a) / 255,
699                                                params->type.text.color3.a);
700              break;
701            case EDJE_TEXT_EFFECT_FAR_SOFT_SHADOW:
702              style = EVAS_TEXT_STYLE_FAR_SOFT_SHADOW;
703              evas_object_text_shadow_color_set(ep->object,
704                                                (params->type.text.color3.r * params->type.text.color3.a) / 255,
705                                                (params->type.text.color3.g * params->type.text.color3.a) / 255,
706                                                (params->type.text.color3.b * params->type.text.color3.a) / 255,
707                                                params->type.text.color3.a);
708              break;
709            case EDJE_TEXT_EFFECT_GLOW:
710              style = EVAS_TEXT_STYLE_GLOW;
711              evas_object_text_glow_color_set(ep->object,
712                                              (params->type.text.color2.r * params->type.text.color2.a) / 255,
713                                              (params->type.text.color2.g * params->type.text.color2.a) / 255,
714                                              (params->type.text.color2.b * params->type.text.color2.a) / 255,
715                                              params->type.text.color2.a);
716              evas_object_text_glow2_color_set(ep->object,
717                                               (params->type.text.color3.r * params->type.text.color3.a) / 255,
718                                               (params->type.text.color3.g * params->type.text.color3.a) / 255,
719                                               (params->type.text.color3.b * params->type.text.color3.a) / 255,
720                                               params->type.text.color3.a);
721              break;
722            default:
723              style = EVAS_TEXT_STYLE_PLAIN;
724              break;
725           }
726         
727         switch (effect & EDJE_TEXT_EFFECT_MASK_SHADOW_DIRECTION)
728           {
729            case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM_RIGHT:
730              EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
731                 (style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT);
732              break;
733            case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM:
734              EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
735                 (style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM);
736              break;
737            case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM_LEFT:
738              EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
739                 (style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT);
740              break;
741            case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_LEFT:
742              EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
743                 (style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_LEFT);
744              break;
745            case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP_LEFT:
746              EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
747                 (style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT);
748              break;
749            case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP:
750              EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
751                 (style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP);
752              break;
753            case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP_RIGHT:
754              EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
755                 (style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT);
756              break;
757            case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_RIGHT:
758              EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
759                 (style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_RIGHT);
760              break;
761            default:
762              break;
763           }
764         evas_object_text_style_set(ep->object, style);
765      }
766    
767    if (free_text) free((char *)text);
768    if (font2) free(font2);
769    if (sfont) free(sfont);
770 }
771
772 Evas_Font_Size
773 _edje_text_size_calc(Evas_Font_Size size, Edje_Text_Class *tc)
774 {
775    int val;
776
777    if (tc->size == 0)
778      {
779         val = size;
780      }
781    else if (tc->size > 0.0)
782      {
783         val = tc->size;
784      }
785    else
786      {
787         val = (size * -tc->size) / 100;
788      }
789    return val;
790 }