Enlightenment CVS committal

Author  : raster
Project : e17
Module  : libs/evas

Dir     : e17/libs/evas/src/lib/engines/common


Modified Files:
        evas_font_query.c 


Log Message:


fixing minor arithmeic stuff in text queries. all happy now.

===================================================================
RCS file: 
/cvsroot/enlightenment/e17/libs/evas/src/lib/engines/common/evas_font_query.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- evas_font_query.c   30 May 2003 05:05:52 -0000      1.7
+++ evas_font_query.c   7 Jun 2003 02:32:30 -0000       1.8
@@ -43,11 +43,11 @@
        chr_y = (pen_y >> 8)  + fg->glyph_out->top;
        chr_w = fg->glyph_out->bitmap.width;
        
-       if (chr_x < start_x) start_x = chr_x;
+       if (!prev_index) start_x = chr_x;
        if ((chr_x + chr_w) > end_x) end_x = chr_x + chr_w;
        
        pen_x += fg->glyph->advance.x >> 8;
-       prev_index = index;     
+       prev_index = index;
      }
    if (w) *w = end_x - start_x;
    if (h) *h = evas_common_font_max_ascent_get(fn) + 
evas_common_font_max_descent_get(fn);
@@ -125,51 +125,67 @@
 {
    int use_kerning;
    int pen_x, pen_y;
+   int prev_chr_end;
    int chr;
+   int asc, desc;
    FT_UInt prev_index;
    
    pen_x = 0;
    pen_y = 0;
    use_kerning = FT_HAS_KERNING(fn->ft.face);
    prev_index = 0;
+   prev_chr_end = 0;
+   asc = evas_common_font_max_ascent_get(fn);
+   desc = evas_common_font_max_descent_get(fn);
    for (chr = 0; text[chr];)
      {
        int pchr;
        FT_UInt index;
        RGBA_Font_Glyph *fg;
-       int chr_x, chr_y, chr_w;        
-        int gl;
+       int chr_x, chr_y, chr_w;
+        int gl, kern;
        FT_Vector delta;
-       
+
        pchr = chr;
        gl = evas_common_font_utf8_get_next((unsigned char *)text, &chr);
        if (gl == 0) break;
        index = FT_Get_Char_Index(fn->ft.face, gl);
+       kern = 0;
        if ((use_kerning) && (prev_index) && (index))
          {
             FT_Get_Kerning(fn->ft.face, prev_index, index,
                            ft_kerning_default, &delta);
-            pen_x += delta.x << 2;
+            kern = delta.x << 2;
+            pen_x += kern;
          }
        fg = evas_common_font_cache_glyph_get(fn, index);
        if (!fg) continue;
        
-       chr_x = (pen_x >> 8) + fg->glyph_out->left;
+       if (kern < 0) kern = 0; 
+       chr_x = ((pen_x - kern) >> 8) + fg->glyph_out->left;
        chr_y = (pen_y >> 8) + fg->glyph_out->top;
-       chr_w = fg->glyph_out->bitmap.width;
+       chr_w = fg->glyph_out->bitmap.width + (kern >> 8);
        if (text[chr])
          {
-            if (chr_w < (fg->glyph->advance.x >> 16))
-              chr_w = fg->glyph->advance.x >> 16;
+            int advw;
+            
+            advw = ((fg->glyph->advance.x + (kern << 8)) >> 16);
+            if (chr_w < advw) chr_w = advw;
+         }
+       if (chr_x > prev_chr_end)
+         {
+            chr_w += (chr_x - prev_chr_end);
+            chr_x = prev_chr_end;
          }
        if (pchr == pos)
          {
             if (cx) *cx = chr_x;
-            if (cy) *cy = - evas_common_font_max_ascent_get(fn);
+            if (cy) *cy = -asc;
             if (cw) *cw = chr_w;
-            if (ch) *ch = evas_common_font_max_ascent_get(fn) + 
evas_common_font_max_descent_get(fn);
+            if (ch) *ch = asc + desc;
             return 1;
          }
+       prev_chr_end = chr_x + chr_w;
        pen_x += fg->glyph->advance.x >> 8;
        prev_index = index;
      }
@@ -182,13 +198,18 @@
 {
    int use_kerning;
    int pen_x, pen_y;
+   int prev_chr_end;
    int chr;
+   int asc, desc;
    FT_UInt prev_index;
    
    pen_x = 0;
    pen_y = 0;
    use_kerning = FT_HAS_KERNING(fn->ft.face);
    prev_index = 0;
+   prev_chr_end = 0;
+   asc = evas_common_font_max_ascent_get(fn);
+   desc = evas_common_font_max_descent_get(fn);
    for (chr = 0; text[chr];)
      {
        int pchr;
@@ -207,32 +228,38 @@
          {
             FT_Get_Kerning(fn->ft.face, prev_index, index,
                            ft_kerning_default, &delta);
-            kern = delta.x << 6;
+            kern = delta.x << 2;
             pen_x += kern;
          }
        fg = evas_common_font_cache_glyph_get(fn, index);
        if (!fg) continue;
        
+       if (kern < 0) kern = 0; 
        chr_x = ((pen_x - kern) >> 8) + fg->glyph_out->left;
        chr_y = (pen_y >> 8) + fg->glyph_out->top;
        chr_w = fg->glyph_out->bitmap.width + (kern >> 8);
        if (text[chr])
          {
-            if (chr_w < (((fg->glyph->advance.x + 0xffff) >> 16) + 
-                         (((pen_x & 0xff) + 0xff) >> 8) + 1))
-              chr_w = ((fg->glyph->advance.x + 0xffff) >> 16) +
-                (((pen_x & 0xff) + 0xff) >> 8) + 1;
+            int advw;
+            
+            advw = ((fg->glyph->advance.x + (kern << 8)) >> 16);
+            if (chr_w < advw) chr_w = advw;
+         }
+       if (chr_x > prev_chr_end)
+         {
+            chr_w += (chr_x - prev_chr_end);
+            chr_x = prev_chr_end;
          }
        if ((x >= chr_x) && (x <= (chr_x + chr_w)) &&
-           (y > - evas_common_font_max_ascent_get(fn)) &&
-           (y < evas_common_font_max_descent_get(fn)))
+           (y > -asc) && (y < desc))
          {
             if (cx) *cx = chr_x;
-            if (cy) *cy = - evas_common_font_max_ascent_get(fn);
+            if (cy) *cy = -asc;
             if (cw) *cw = chr_w;
-            if (ch) *ch = evas_common_font_max_ascent_get(fn) + 
evas_common_font_max_descent_get(fn);
+            if (ch) *ch = asc + desc;
             return pchr;
          }
+       prev_chr_end = chr_x + chr_w;
        pen_x += fg->glyph->advance.x >> 8;
        prev_index = index;
      }




-------------------------------------------------------
This SF.net email is sponsored by:  Etnus, makers of TotalView, The best
thread debugger on the planet. Designed with thread debugging features
you've never dreamed of, try TotalView 6 free at www.etnus.com.
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to