summaryrefslogtreecommitdiff
path: root/legacy/edje/src/lib/edje_text.c
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2011-02-27 18:09:00 +0000
committerTom Hacohen <tom@stosb.com>2011-02-27 18:09:00 +0000
commit54f4d4bf2f8e1dcc40da31a3947163e0465329b4 (patch)
tree8194a6490ad234e3aa1c37896ac18e1b868bf42f /legacy/edje/src/lib/edje_text.c
parenta19a9010dff3c5e30185f3ec234c44c55385c540 (diff)
Edje text: Fixed a bug with fit_x and cleaned everything up.
There was a bug that cause bad sizing (by 1pt) when fit was set, this is now fixed. Furthermore, for some reason we had a loop although we already jumped to the last value right at the start. That didn't make any sense, so I removed that as well. SVN revision: 57394
Diffstat (limited to 'legacy/edje/src/lib/edje_text.c')
-rw-r--r--legacy/edje/src/lib/edje_text.c53
1 files changed, 23 insertions, 30 deletions
diff --git a/legacy/edje/src/lib/edje_text.c b/legacy/edje/src/lib/edje_text.c
index 425f047..655288f 100644
--- a/legacy/edje/src/lib/edje_text.c
+++ b/legacy/edje/src/lib/edje_text.c
@@ -428,39 +428,32 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
428 evas_object_text_font_set(ep->object, font, size); 428 evas_object_text_font_set(ep->object, font, size);
429 evas_object_text_text_set(ep->object, text); 429 evas_object_text_text_set(ep->object, text);
430 part_get_geometry(ep, &tw, &th); 430 part_get_geometry(ep, &tw, &th);
431 if (tw > sw) 431 /* Find the wanted font size */
432 { 432 if ((tw > sw) && (size > 0) && (tw != 0))
433 while ((tw > sw) && (size > 0) && (tw != 0)) 433 {
434 { 434 size = (size * sw) / tw;
435 int psize = size;
436 size = (size * sw) / tw;
437 if ((psize - size) <= 0) size = psize - 1;
438 if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
439 else evas_object_text_font_source_set(ep->object, NULL);
440 435
441 if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc)); 436 if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
442 evas_object_text_font_set(ep->object, font, size); 437 else evas_object_text_font_source_set(ep->object, NULL);
443 part_get_geometry(ep, &tw, &th);
444 if ((size > 0) && (tw == 0)) break;
445 }
446 }
447 else if (tw < sw)
448 {
449 while ((tw < sw) && (size > 0) && (tw != 0))
450 {
451 int psize = size;
452 size = (size * sw) / tw;
453 /* fprintf(stderr, "size = %i (%i, %i)\n", size, sw, tw); */
454 if ((psize - size) >= 0) size = psize + 1;
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 438
458 if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc)); 439 if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
459 evas_object_text_font_set(ep->object, font, size); 440 evas_object_text_font_set(ep->object, font, size);
460 part_get_geometry(ep, &tw, &th); 441 part_get_geometry(ep, &tw, &th);
461 if ((size > 0) && (tw == 0)) break;
462 }
463 } 442 }
443 else if ((tw < sw) && (size > 0) && (tw != 0))
444 {
445 size = (size * sw) / tw;
446
447 if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
448 else evas_object_text_font_source_set(ep->object, NULL);
449
450 if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
451 evas_object_text_font_set(ep->object, font, size);
452 part_get_geometry(ep, &tw, &th);
453 }
454 /* FIXME: This should possibly be replaced by more proper handling,
455 * but it's still way better than what was here before. */
456 if (tw > sw) size--;
464 } 457 }
465 if (chosen_desc->text.fit_y && (ep->text.cache.in_str && eina_stringshare_strlen(ep->text.cache.in_str) > 0)) 458 if (chosen_desc->text.fit_y && (ep->text.cache.in_str && eina_stringshare_strlen(ep->text.cache.in_str) > 0))
466 { 459 {