summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2013-05-10 17:44:30 +0100
committerTom Hacohen <tom@stosb.com>2013-05-10 17:48:26 +0100
commitcc4cf7786595710b5c53a80dd61bc632cf682ac5 (patch)
treeb8979cc12220bba087f067eb683e5ba5c9b3fff5
parent7d5583530e8a7f72f44d2d2dd476ea3ce0ee5666 (diff)
downloadefl-cc4cf7786595710b5c53a80dd61bc632cf682ac5.tar.gz
Evas font/text: Fixed an issue with asc/desc calculation in text object.
Added font_int asc/desc getters in order to achieve that. Thanks to MinSu Seo for reporting.
-rw-r--r--ChangeLog5
-rw-r--r--NEWS1
-rw-r--r--src/lib/evas/canvas/evas_object_text.c32
-rw-r--r--src/lib/evas/common/evas_font.h4
-rw-r--r--src/lib/evas/common/evas_font_main.c73
5 files changed, 74 insertions, 41 deletions
diff --git a/ChangeLog b/ChangeLog
index 6bcd3a67fb..a5ced2c454 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-05-10 Tom Hacohen
+
+ * Evas text: Fixed line size calculation when using multiple
+ fonts.
+
2013-05-10 ChunEon Park (Hermet)
* Evas: don't try blend on gl backened if the render option is COPY
diff --git a/NEWS b/NEWS
index 1f5c49a85e..0d45ad439e 100644
--- a/NEWS
+++ b/NEWS
@@ -265,3 +265,4 @@ Fixes:
* Ecore_Input_Evas: Fix ecore_input_evas didn't check the device id of mouse event
* Edje: fix custom states for proxy parts
* Evas: Don't try blend on gl backened if the render option is COPY
+ * Evas text: Fixed line size calculation when using multiple fonts.
diff --git a/src/lib/evas/canvas/evas_object_text.c b/src/lib/evas/canvas/evas_object_text.c
index fc2965b595..4664367c5d 100644
--- a/src/lib/evas/canvas/evas_object_text.c
+++ b/src/lib/evas/canvas/evas_object_text.c
@@ -2399,6 +2399,38 @@ _evas_object_text_recalc(Evas_Object *eo_obj, Eina_Unicode *text)
_evas_object_text_layout(eo_obj, o, text);
+ /* Calc ascent/descent. */
+ {
+ Evas_Object_Text_Item *item;
+
+ for (item = o->items ; item ;
+ item = EINA_INLIST_CONTAINER_GET(
+ EINA_INLIST_GET(item)->next, Evas_Object_Text_Item))
+ {
+ int asc = 0, desc = 0;
+ int max_asc = 0, max_desc = 0;
+
+ /* Skip items without meaning full information. */
+ if (!item->text_props.font_instance)
+ continue;
+
+ asc = evas_common_font_instance_ascent_get(item->text_props.font_instance);
+ desc = evas_common_font_instance_descent_get(item->text_props.font_instance);
+ if (asc > o->ascent)
+ o->ascent = asc;
+ if (desc > o->descent)
+ o->descent = desc;
+
+ max_asc = evas_common_font_instance_max_ascent_get(item->text_props.font_instance);
+ max_desc = evas_common_font_instance_max_descent_get(item->text_props.font_instance);
+
+ if (max_asc > o->max_ascent)
+ o->max_ascent = max_asc;
+ if (max_desc > o->max_descent)
+ o->max_descent = max_desc;
+ }
+ }
+
if ((o->font) && (o->items))
{
int w, h;
diff --git a/src/lib/evas/common/evas_font.h b/src/lib/evas/common/evas_font.h
index 205d0f757a..403b501941 100644
--- a/src/lib/evas/common/evas_font.h
+++ b/src/lib/evas/common/evas_font.h
@@ -14,6 +14,10 @@ EAPI int evas_common_font_ascent_get (RGBA_Font *fn);
EAPI int evas_common_font_descent_get (RGBA_Font *fn);
EAPI int evas_common_font_max_ascent_get (RGBA_Font *fn);
EAPI int evas_common_font_max_descent_get (RGBA_Font *fn);
+EAPI int evas_common_font_instance_ascent_get (RGBA_Font_Int *fi);
+EAPI int evas_common_font_instance_descent_get (RGBA_Font_Int *fi);
+EAPI int evas_common_font_instance_max_ascent_get (RGBA_Font_Int *fi);
+EAPI int evas_common_font_instance_max_descent_get (RGBA_Font_Int *fi);
EAPI int evas_common_font_get_line_advance (RGBA_Font *fn);
/* draw */
diff --git a/src/lib/evas/common/evas_font_main.c b/src/lib/evas/common/evas_font_main.c
index ef1fb2b0c9..43d467c0b9 100644
--- a/src/lib/evas/common/evas_font_main.c
+++ b/src/lib/evas/common/evas_font_main.c
@@ -73,36 +73,9 @@ evas_common_font_font_all_unload(void)
}
EAPI int
-evas_common_font_ascent_get(RGBA_Font *fn)
+evas_common_font_instance_ascent_get(RGBA_Font_Int *fi)
{
int val;
- RGBA_Font_Int *fi;
-
-// evas_common_font_size_use(fn);
-#if 0
- {
- Eina_List *l;
-
- EINA_LIST_FOREACH(fn->fonts, l, fi)
- {
- if (!fi->src->ft.face) continue;
- if (fi->src->current_size != fi->size)
- {
- FTLOCK();
- FT_Activate_Size(fi->ft.size);
- FTUNLOCK();
- fi->src->current_size = fi->size;
- }
- val = (int)fi->src->ft.face->size->metrics.ascender;
- if (fi->src->ft.face->units_per_EM == 0)
- return val;
- dv = (fi->src->ft.orig_upem * 2048) / fi->src->ft.face->units_per_EM;
- ret = (val * fi->src->ft.face->size->metrics.y_scale) / (dv * dv);
- printf(" ==== %p: %i\n", fi, ret);
- }
- }
-#endif
- fi = fn->fonts->data;
evas_common_font_int_reload(fi);
if (fi->src->current_size != fi->size)
{
@@ -126,13 +99,9 @@ evas_common_font_ascent_get(RGBA_Font *fn)
}
EAPI int
-evas_common_font_descent_get(RGBA_Font *fn)
+evas_common_font_instance_descent_get(RGBA_Font_Int *fi)
{
int val;
- RGBA_Font_Int *fi;
-
-// evas_common_font_size_use(fn);
- fi = fn->fonts->data;
evas_common_font_int_reload(fi);
if (fi->src->current_size != fi->size)
{
@@ -151,14 +120,11 @@ evas_common_font_descent_get(RGBA_Font *fn)
}
EAPI int
-evas_common_font_max_ascent_get(RGBA_Font *fn)
+evas_common_font_instance_max_ascent_get(RGBA_Font_Int *fi)
{
int val, dv;
int ret;
- RGBA_Font_Int *fi;
-// evas_common_font_size_use(fn);
- fi = fn->fonts->data;
evas_common_font_int_reload(fi);
if (fi->src->current_size != fi->size)
{
@@ -181,14 +147,11 @@ evas_common_font_max_ascent_get(RGBA_Font *fn)
}
EAPI int
-evas_common_font_max_descent_get(RGBA_Font *fn)
+evas_common_font_instance_max_descent_get(RGBA_Font_Int *fi)
{
int val, dv;
int ret;
- RGBA_Font_Int *fi;
-// evas_common_font_size_use(fn);
- fi = fn->fonts->data;
evas_common_font_int_reload(fi);
if (fi->src->current_size != fi->size)
{
@@ -211,6 +174,34 @@ evas_common_font_max_descent_get(RGBA_Font *fn)
}
EAPI int
+evas_common_font_ascent_get(RGBA_Font *fn)
+{
+// evas_common_font_size_use(fn);
+ return evas_common_font_instance_ascent_get(fn->fonts->data);
+}
+
+EAPI int
+evas_common_font_descent_get(RGBA_Font *fn)
+{
+// evas_common_font_size_use(fn);
+ return evas_common_font_instance_descent_get(fn->fonts->data);
+}
+
+EAPI int
+evas_common_font_max_ascent_get(RGBA_Font *fn)
+{
+// evas_common_font_size_use(fn);
+ return evas_common_font_instance_max_ascent_get(fn->fonts->data);
+}
+
+EAPI int
+evas_common_font_max_descent_get(RGBA_Font *fn)
+{
+// evas_common_font_size_use(fn);
+ return evas_common_font_instance_max_descent_get(fn->fonts->data);
+}
+
+EAPI int
evas_common_font_get_line_advance(RGBA_Font *fn)
{
int val;