summaryrefslogtreecommitdiff
path: root/legacy/edje/src/lib/edje_text.c
diff options
context:
space:
mode:
authortsauerbeck <tsauerbeck>2004-10-30 16:54:58 +0000
committertsauerbeck <tsauerbeck@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>2004-10-30 16:54:58 +0000
commit9324e26f14316cedf9aa5b7067d397342d54a7b5 (patch)
tree1ce5c31fffef4d5402a902781a62269d636639ce /legacy/edje/src/lib/edje_text.c
parent216fdda3e3ffc1ebde32d4078800963939e70abc (diff)
unbreak edje_text_fit_x
SVN revision: 12093
Diffstat (limited to 'legacy/edje/src/lib/edje_text.c')
-rw-r--r--legacy/edje/src/lib/edje_text.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/legacy/edje/src/lib/edje_text.c b/legacy/edje/src/lib/edje_text.c
index 692131d..fb9ec70 100644
--- a/legacy/edje/src/lib/edje_text.c
+++ b/legacy/edje/src/lib/edje_text.c
@@ -286,17 +286,19 @@ _edje_text_real_part_on_del(Edje *ed, Edje_Real_Part *ep)
286 } 286 }
287} 287}
288 288
289void 289static char *
290_edje_text_fit_x(Edje *ed, Edje_Real_Part *ep, 290_edje_text_fit_x(Edje *ed, Edje_Real_Part *ep,
291 Edje_Calc_Params *params, 291 Edje_Calc_Params *params,
292 char *text, char *font, int size, 292 char *text, char *font, int size,
293 Evas_Coord sw) 293 Evas_Coord sw, int *free_text)
294{ 294{
295 Evas_Coord tw = 0, th = 0, p; 295 Evas_Coord tw = 0, th = 0, p;
296 char *buf; 296 char *buf;
297 int c1 = -1, c2 = -1, loop = 0, extra; 297 int c1 = -1, c2 = -1, loop = 0, extra;
298 size_t orig_len; 298 size_t orig_len;
299 299
300 *free_text = 0;
301
300 evas_object_text_font_set(ep->object, font, size); 302 evas_object_text_font_set(ep->object, font, size);
301 evas_object_text_text_set(ep->object, text); 303 evas_object_text_text_set(ep->object, text);
302 304
@@ -322,17 +324,19 @@ _edje_text_fit_x(Edje *ed, Edje_Real_Part *ep,
322 } 324 }
323 } 325 }
324 326
325 extra = 1 + 3 + 3; /* terminator, leading and trailing ellipsis */ 327 if (!((c1 >= 0 || c2 >= 0) && (tw > sw)))
328 return text;
326 329
327 orig_len = strlen(text); 330 orig_len = strlen(text);
328 331
329 /* don't overflow orig_len by adding extra 332 /* don't overflow orig_len by adding extra
330 * FIXME: we might want to set a max string length somewhere... 333 * FIXME: we might want to set a max string length somewhere...
331 */ 334 */
335 extra = 1 + 3 + 3; /* terminator, leading and trailing ellipsis */
332 orig_len = MIN(orig_len, SIZE_MAX - extra); 336 orig_len = MIN(orig_len, SIZE_MAX - extra);
333 337
334 if (!(buf = malloc(orig_len + extra))) 338 if (!(buf = malloc(orig_len + extra)))
335 return; 339 return text;
336 340
337 while (((c1 >= 0) || (c2 >= 0)) && (tw > sw)) 341 while (((c1 >= 0) || (c2 >= 0)) && (tw > sw))
338 { 342 {
@@ -422,7 +426,10 @@ _edje_text_fit_x(Edje *ed, Edje_Real_Part *ep,
422 evas_object_text_text_set(ep->object, buf); 426 evas_object_text_text_set(ep->object, buf);
423 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th); 427 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
424 } 428 }
425 if (loop > 0) text = buf; 429
430 *free_text = 1;
431
432 return buf;
426} 433}
427 434
428void 435void
@@ -435,9 +442,8 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
435 int size; 442 int size;
436 Evas_Coord tw, th; 443 Evas_Coord tw, th;
437 Evas_Coord ox, oy, sw, sh; 444 Evas_Coord ox, oy, sw, sh;
438 char *buf = NULL;
439 char font_buf[4096]; 445 char font_buf[4096];
440 int inlined_font = 0; 446 int inlined_font = 0, free_text = 0;
441 447
442 448
443 text = chosen_desc->text.text; 449 text = chosen_desc->text.text;
@@ -600,7 +606,8 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
600 if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path); 606 if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
601 else evas_object_text_font_source_set(ep->object, NULL); 607 else evas_object_text_font_source_set(ep->object, NULL);
602 608
603 _edje_text_fit_x(ed, ep, params, text, font, size, sw); 609 text = _edje_text_fit_x(ed, ep, params, text, font, size, sw,
610 &free_text);
604 } 611 }
605 612
606 if (ep->text.cache.out_str) free(ep->text.cache.out_str); 613 if (ep->text.cache.out_str) free(ep->text.cache.out_str);
@@ -670,5 +677,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
670 else evas_object_hide(o); 677 else evas_object_hide(o);
671 } 678 }
672 } 679 }
673 if (buf) free(buf); 680
681 if (free_text)
682 free(text);
674} 683}