tasn pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=8c6effae8ee027a928bcee79968a0b21d8250487

commit 8c6effae8ee027a928bcee79968a0b21d8250487
Author: Tom Hacohen <[email protected]>
Date:   Thu Jul 14 17:31:09 2016 +0100

    Evas font: Fix width query for OpenType fonts. (rewrite)
    
    This is essentially a cleaner redo of 
ef817f15f0eaec9704ec25d9468c2c8497a5bc13.
    Logic should be exactly the same as there, the different is that this
    one shares the code between OT and non OT.
    
    Please refer to that commit for more information.
---
 src/lib/evas/common/evas_font_query.c | 48 +++++++++++++++++++++++++++--------
 1 file changed, 37 insertions(+), 11 deletions(-)

diff --git a/src/lib/evas/common/evas_font_query.c 
b/src/lib/evas/common/evas_font_query.c
index f435b9b..1d9b7dc 100644
--- a/src/lib/evas/common/evas_font_query.c
+++ b/src/lib/evas/common/evas_font_query.c
@@ -333,22 +333,48 @@ evas_common_font_query_size(RGBA_Font *fn, const 
Evas_Text_Props *text_props, in
 
    if (text_props->len > 0)
      {
-        const Evas_Font_Glyph_Info *glyph = text_props->info->glyph +
+        size_t off = text_props->start + text_props->len - 1;
+        const Evas_Font_Glyph_Info *first_glyph = text_props->info->glyph +
            text_props->start;
-        const Evas_Font_Glyph_Info *last_glyph = glyph;
+        const Evas_Font_Glyph_Info *last_glyph = text_props->info->glyph + 
off;;
+
+        const Evas_Font_Glyph_Info *glyph = last_glyph;
+        size_t cluster = 0;
+        size_t cur_cluster = 0;
+
+#ifdef OT_SUPPORT
+        Evas_Font_OT_Info *ot = text_props->info->ot + off;
+        cluster = ot->source_cluster;
+        cur_cluster = ot->source_cluster;
+#endif
 
-        if (text_props->len > 1)
+        do
           {
-             last_glyph += text_props->len - 1;
-             ret_w = last_glyph[-1].pen_after;
-             if (text_props->start > 0)
-                ret_w -= glyph[-1].pen_after;
-          }
+             Evas_Coord cur_w = 0;
+             if (text_props->len > 1)
+               {
+                  cur_w = last_glyph[-1].pen_after;
+                  if (text_props->start > 0)
+                     cur_w -= first_glyph[-1].pen_after;
+               }
+             cur_w += last_glyph->width + last_glyph->x_bear;
 #ifdef OT_SUPPORT
-        ret_w += EVAS_FONT_ROUND_26_6_TO_INT(EVAS_FONT_OT_X_OFF_GET(
-              text_props->info->ot[text_props->start + text_props->len - 1]));
+             cur_w += EVAS_FONT_ROUND_26_6_TO_INT(EVAS_FONT_OT_X_OFF_GET(
+                      text_props->info->ot[text_props->start + text_props->len 
- 1]));
+
+             cur_cluster = ot->source_cluster;
+             ot--;
+#else
+             cur_cluster = cluster + 1; /* Change cluster manually for no OT */
 #endif
-        ret_w += last_glyph->width + last_glyph->x_bear;
+             glyph--;
+
+             if (cur_w > ret_w)
+               {
+                  ret_w = cur_w;
+               }
+          }
+        while ((glyph > first_glyph) && (cur_cluster == cluster));
      }
 
    if (w) *w = ret_w;

-- 


Reply via email to