tasn pushed a commit to branch evas-1.7.

commit 41aa29e3e68bb9c5320ae84260d45ee8457cb7d6
Author: Tom Hacohen <[email protected]>
Date:   Tue Aug 13 15:35:43 2013 +0100

    Evas textblock: Use max ascent/descent at the edges of the textblock.
    
    Thanks to Youngbok Shin for reporting the difference in behaviour between
    textblock and text object.
---
 src/lib/canvas/evas_object_textblock.c | 62 ++++++++++++++++++++++++----------
 1 file changed, 44 insertions(+), 18 deletions(-)

diff --git a/src/lib/canvas/evas_object_textblock.c 
b/src/lib/canvas/evas_object_textblock.c
index 9168686..84e7ab3 100644
--- a/src/lib/canvas/evas_object_textblock.c
+++ b/src/lib/canvas/evas_object_textblock.c
@@ -2558,23 +2558,48 @@ _layout_format_ascent_descent_adjust(const Evas_Object 
*obj,
  * @param position The position inside the textblock
  */
 static void
-_layout_item_ascent_descent_adjust(const Evas_Object *eo_obj,
+_layout_item_ascent_descent_adjust(const Evas_Object *obj,
       Evas_Coord *maxascent, Evas_Coord *maxdescent,
       Evas_Object_Textblock_Item *it, Textblock_Position position)
 {
-   _layout_format_ascent_descent_adjust(eo_obj, maxascent, maxdescent, 
it->format);
+   _layout_format_ascent_descent_adjust(obj, maxascent, maxdescent, 
it->format);
 
-   if ((it->type == EVAS_TEXTBLOCK_ITEM_TEXT) &&
-         (position == TEXTBLOCK_POSITION_START))
+   if (it->type == EVAS_TEXTBLOCK_ITEM_TEXT)
      {
-        int asc = 0, desc = 0;
-        evas_common_font_ascent_descent_get((void *) it->format->font.font,
-              &_ITEM_TEXT(it)->text_props, &asc, &desc);
+        void *fi = _ITEM_TEXT(it)->text_props.font_instance;
+
+        if (position == TEXTBLOCK_POSITION_START)
+          {
+             int asc = 0;
+
+             if (fi)
+               {
+                  asc = evas_common_font_instance_max_ascent_get(fi);
+               }
+             else
+               {
+                  asc = ENFN->font_max_ascent_get(ENDT, it->format->font.font);
+               }
+             if (maxascent && (asc > *maxascent))
+                *maxascent = asc;
+          }
+        else if (position == TEXTBLOCK_POSITION_END)
+          {
+             int desc = 0;
 
-        if (maxascent && (asc > *maxascent))
-           *maxascent = asc;
-        if (maxdescent && (desc < *maxdescent))
-           *maxdescent = desc;
+             if (fi)
+               {
+                  desc = evas_common_font_instance_max_descent_get(fi);
+               }
+             else
+               {
+                  desc =
+                     ENFN->font_max_descent_get(ENDT, it->format->font.font);
+               }
+
+             if (maxdescent && (desc < *maxdescent))
+                *maxdescent = desc;
+          }
      }
 }
 
@@ -9786,13 +9811,13 @@ static void
 _size_native_calc_paragraph_size(const Evas_Object *obj,
       const Evas_Object_Textblock *o,
       const Evas_Object_Textblock_Paragraph *par,
+      Textblock_Position *position,
       Evas_Coord *_w, Evas_Coord *_h)
 {
    Eina_List *i;
    Evas_Object_Textblock_Item *it;
    Eina_List *line_items = NULL;
    Evas_Coord w = 0, y = 0, wmax = 0, h = 0, ascent = 0, descent = 0;
-   Textblock_Position position = TEXTBLOCK_POSITION_START;
 
    EINA_LIST_FOREACH(par->logical_items, i, it)
      {
@@ -9804,7 +9829,7 @@ _size_native_calc_paragraph_size(const Evas_Object *obj,
                       _IS_PARAGRAPH_SEPARATOR(o, fi->item)))
                {
                   _size_native_calc_line_finalize(obj, line_items, &ascent,
-                        &descent, &w, position);
+                        &descent, &w, *position);
 
                   if (ascent + descent > h)
                      h = ascent + descent;
@@ -9814,7 +9839,7 @@ _size_native_calc_paragraph_size(const Evas_Object *obj,
                      wmax = w;
                   h = 0;
                   ascent = descent = 0;
-                  position = TEXTBLOCK_POSITION_ELSE;
+                  *position = TEXTBLOCK_POSITION_ELSE;
                   line_items = eina_list_free(line_items);
                }
              else
@@ -9824,7 +9849,7 @@ _size_native_calc_paragraph_size(const Evas_Object *obj,
                    * according to the current format. */
                   if (it && (ascent + descent == 0))
                      _layout_item_ascent_descent_adjust(obj, &ascent,
-                           &descent, it, position);
+                           &descent, it, *position);
 
                   _layout_calculate_format_item_size(obj, fi, &ascent,
                         &descent, &fy, &fw, &fh);
@@ -9833,11 +9858,11 @@ _size_native_calc_paragraph_size(const Evas_Object *obj,
         else
           {
              _layout_item_ascent_descent_adjust(obj, &ascent,
-                   &descent, it, position);
+                   &descent, it, *position);
           }
      }
 
-   _size_native_calc_line_finalize(obj, line_items, &ascent, &descent, &w, 
position);
+   _size_native_calc_line_finalize(obj, line_items, &ascent, &descent, &w, 
*position);
 
    line_items = eina_list_free(line_items);
 
@@ -9860,13 +9885,14 @@ evas_object_textblock_size_native_get(const Evas_Object 
*obj, Evas_Coord *w, Eva
      {
         Evas_Coord wmax = 0, hmax = 0;
         Evas_Object_Textblock_Paragraph *par;
+        Textblock_Position position = TEXTBLOCK_POSITION_START;
         /* We just want the layout objects to update, should probably
          * split that. */
         if (!o->formatted.valid) _relayout(obj);
         EINA_INLIST_FOREACH(o->paragraphs, par)
           {
              Evas_Coord tw, th;
-             _size_native_calc_paragraph_size(obj, o, par, &tw, &th);
+             _size_native_calc_paragraph_size(obj, o, par, &position, &tw, 
&th);
              if (tw > wmax)
                 wmax = tw;
              hmax += th;

-- 

------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk

Reply via email to