summaryrefslogtreecommitdiff
path: root/legacy/edje/src/lib/edje_text.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2007-03-30 23:39:41 +0000
committerCarsten Haitzler <raster@rasterman.com>2007-03-30 23:39:41 +0000
commit6d5551939d1ad3064fbef657df7d4a5bcc870df2 (patch)
tree4249a870fa4010fc1954af5b83537ca40257f6ca /legacy/edje/src/lib/edje_text.c
parent12215d740c065b238cbe615404c00419efd28b26 (diff)
tilman's edje font metrics patch
SVN revision: 29266
Diffstat (limited to 'legacy/edje/src/lib/edje_text.c')
-rw-r--r--legacy/edje/src/lib/edje_text.c43
1 files changed, 34 insertions, 9 deletions
diff --git a/legacy/edje/src/lib/edje_text.c b/legacy/edje/src/lib/edje_text.c
index 3a85704..7c639be 100644
--- a/legacy/edje/src/lib/edje_text.c
+++ b/legacy/edje/src/lib/edje_text.c
@@ -10,6 +10,31 @@
10#endif 10#endif
11#include <assert.h> 11#include <assert.h>
12 12
13/* returns with and height for this part.
14 *
15 * depending on the value of the use_alternate_font_metrics flag, it will
16 * either use evas_object_geometry_get() or the _advance_get() functions.
17 *
18 * The latter is useful if you want to make sure that width and height
19 * are the same value for the same number of characters in the text.
20 * This usually only makes sense for monospaced fonts.
21 *
22 * In future changes to this file, you probably should use this wrapper
23 * function everywhere instead of calling evas_object_geometry_get()
24 * directly.
25 */
26static inline void
27part_get_geometry(Edje_Real_Part *rp, Evas_Coord *w, Evas_Coord *h)
28{
29 if (!rp->part->use_alternate_font_metrics)
30 evas_object_geometry_get(rp->object, NULL, NULL, w, h);
31 else
32 {
33 if (w) *w = evas_object_text_horiz_advance_get(rp->object);
34 if (h) *h = evas_object_text_vert_advance_get(rp->object);
35 }
36}
37
13void 38void
14_edje_text_init(void) 39_edje_text_init(void)
15{ 40{
@@ -140,7 +165,7 @@ _edje_text_fit_x(Edje *ed, Edje_Real_Part *ep,
140 evas_object_text_font_set(ep->object, font, size); 165 evas_object_text_font_set(ep->object, font, size);
141 evas_object_text_text_set(ep->object, text); 166 evas_object_text_text_set(ep->object, text);
142 167
143 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th); 168 part_get_geometry(ep, &tw, &th);
144 169
145 p = ((sw - tw) * params->text.elipsis); 170 p = ((sw - tw) * params->text.elipsis);
146 171
@@ -237,7 +262,7 @@ _edje_text_fit_x(Edje *ed, Edje_Real_Part *ep,
237 _edje_text_fit_set(buf, text, c1, c2); 262 _edje_text_fit_set(buf, text, c1, c2);
238 263
239 evas_object_text_text_set(ep->object, buf); 264 evas_object_text_text_set(ep->object, buf);
240 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th); 265 part_get_geometry(ep, &tw, &th);
241 } 266 }
242 267
243 *free_text = 1; 268 *free_text = 1;
@@ -352,7 +377,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
352 377
353 evas_object_text_font_set(ep->object, font, size); 378 evas_object_text_font_set(ep->object, font, size);
354 evas_object_text_text_set(ep->object, text); 379 evas_object_text_text_set(ep->object, text);
355 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th); 380 part_get_geometry(ep, &tw, &th);
356 if (tw > sw) 381 if (tw > sw)
357 { 382 {
358 int psize; 383 int psize;
@@ -367,7 +392,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
367 else evas_object_text_font_source_set(ep->object, NULL); 392 else evas_object_text_font_source_set(ep->object, NULL);
368 393
369 evas_object_text_font_set(ep->object, font, size); 394 evas_object_text_font_set(ep->object, font, size);
370 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th); 395 part_get_geometry(ep, &tw, &th);
371 if ((size > 0) && (tw == 0)) break; 396 if ((size > 0) && (tw == 0)) break;
372 } 397 }
373 } 398 }
@@ -385,7 +410,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
385 else evas_object_text_font_source_set(ep->object, NULL); 410 else evas_object_text_font_source_set(ep->object, NULL);
386 411
387 evas_object_text_font_set(ep->object, font, size); 412 evas_object_text_font_set(ep->object, font, size);
388 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th); 413 part_get_geometry(ep, &tw, &th);
389 if ((size > 0) && (tw == 0)) break; 414 if ((size > 0) && (tw == 0)) break;
390 } 415 }
391 } 416 }
@@ -403,7 +428,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
403 428
404 evas_object_text_font_set(ep->object, font, size); 429 evas_object_text_font_set(ep->object, font, size);
405 evas_object_text_text_set(ep->object, text); 430 evas_object_text_text_set(ep->object, text);
406 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th); 431 part_get_geometry(ep, &tw, &th);
407 432
408 /* only grow the font size if we didn't already reach the max size 433 /* only grow the font size if we didn't already reach the max size
409 * for the x axis 434 * for the x axis
@@ -422,7 +447,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
422 else evas_object_text_font_source_set(ep->object, NULL); 447 else evas_object_text_font_source_set(ep->object, NULL);
423 448
424 evas_object_text_font_set(ep->object, font, size); 449 evas_object_text_font_set(ep->object, font, size);
425 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th); 450 part_get_geometry(ep, &tw, &th);
426 if ((size > 0) && (th == 0)) break; 451 if ((size > 0) && (th == 0)) break;
427 } 452 }
428 size -= dif; 453 size -= dif;
@@ -441,7 +466,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
441 else evas_object_text_font_source_set(ep->object, NULL); 466 else evas_object_text_font_source_set(ep->object, NULL);
442 467
443 evas_object_text_font_set(ep->object, font, size); 468 evas_object_text_font_set(ep->object, font, size);
444 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th); 469 part_get_geometry(ep, &tw, &th);
445 if ((size > 0) && (th == 0)) break; 470 if ((size > 0) && (th == 0)) break;
446 } 471 }
447 } 472 }
@@ -473,7 +498,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
473 498
474 evas_object_text_font_set(ep->object, font, size); 499 evas_object_text_font_set(ep->object, font, size);
475 evas_object_text_text_set(ep->object, text); 500 evas_object_text_text_set(ep->object, text);
476 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th); 501 part_get_geometry(ep, &tw, &th);
477 ep->offset.x = ((sw - tw) * params->text.align.x); 502 ep->offset.x = ((sw - tw) * params->text.align.x);
478 ep->offset.y = ((sh - th) * params->text.align.y); 503 ep->offset.y = ((sh - th) * params->text.align.y);
479 504