Evas font-engine: Change EVAS_FONT_WALK_TEXT_* functions to advance pen_x at the...
authorTom Hacohen <tom@stosb.com>
Sun, 30 Jan 2011 10:34:36 +0000 (10:34 +0000)
committerTom Hacohen <tom@stosb.com>
Sun, 30 Jan 2011 10:34:36 +0000 (10:34 +0000)
SVN revision: 56437

legacy/evas/src/lib/engines/common/evas_font_private.h
legacy/evas/src/lib/engines/common/evas_font_query.c

index 9d8be42..1b782f5 100644 (file)
@@ -87,7 +87,6 @@ void evas_common_font_int_reload(RGBA_Font_Int *fi);
 #define EVAS_FONT_WALK_TEXT_INIT() \
         int pen_x = 0, pen_y = 0; \
         int char_index; \
-        int last_adv; \
         FT_UInt prev_index; \
         FT_Face pface = NULL; \
         (void) pen_y; /* Sometimes it won't be used */
@@ -115,7 +114,6 @@ void evas_common_font_int_reload(RGBA_Font_Int *fi);
         int adv; \
         int visible; \
         prev_index = 0; \
-        last_adv = 0; \
         for (char_index = 0 ; *text ; text++, char_index++) \
           { \
              FT_UInt index; \
@@ -168,17 +166,6 @@ void evas_common_font_int_reload(RGBA_Font_Int *fi);
  \
              pface = fi->src->ft.face; \
              LKU(fi->ft_mutex); \
-             /* If the current one is not a compositing char, do the */ \
-             /* previous advance and set the current advance as the next */ \
-             /* advance to do. If it's an invisible char (i.e one that shouldn't
-              * be printed anyhow, we want to advance everything as if it's
-              * a visible char. FIXME: use a proper way to detect diacritic
-              * instead. */ \
-             if ((adv > 0) || !visible) \
-               { \
-                  pen_x += last_adv; \
-                  last_adv = adv; \
-               } \
 
 /**
  * @def EVAS_FONT_WALK_TEXT_END
@@ -189,6 +176,10 @@ void evas_common_font_int_reload(RGBA_Font_Int *fi);
  * @see EVAS_FONT_WALK_TEXT_WORK
  */
 #define EVAS_FONT_WALK_TEXT_END() \
+             if (visible) \
+               { \
+                  pen_x += adv; \
+               } \
              prev_index = index; \
           } \
      } \
index aed3478..a092edb 100644 (file)
@@ -140,6 +140,7 @@ EAPI void
 evas_common_font_query_size(RGBA_Font *fn, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props __UNUSED__, int *w, int *h)
 {
    int keep_width = 0;
+   int prev_pen_x = 0;
    int use_kerning;
    RGBA_Font_Int *fi;
    EVAS_FONT_WALK_TEXT_INIT();
@@ -150,9 +151,11 @@ evas_common_font_query_size(RGBA_Font *fn, const Eina_Unicode *text, const Evas_
         EVAS_FONT_WALK_TEXT_WORK();
         /* Keep the width because we'll need it for the last char */
         keep_width = width + bear_x;
+        /* Keep the previous pen_x, before it's advanced in TEXT_END */
+        prev_pen_x = pen_x;
      }
    EVAS_FONT_WALK_TEXT_END();
-   if (w) *w = pen_x + keep_width;
+   if (w) *w = prev_pen_x + keep_width;
    if (h) *h = evas_common_font_max_ascent_get(fn) + evas_common_font_max_descent_get(fn);
   evas_common_font_int_use_trim();
 }
@@ -167,7 +170,6 @@ evas_common_font_query_size(RGBA_Font *fn, const Eina_Unicode *text, const Evas_
 EAPI void
 evas_common_font_query_advance(RGBA_Font *fn, const Eina_Unicode *text, const Evas_BiDi_Props *intl_props, int *h_adv, int *v_adv)
 {
-   int keep_adv = 0;
    int use_kerning;
    RGBA_Font_Int *fi;
    EVAS_FONT_WALK_TEXT_INIT();
@@ -176,14 +178,11 @@ evas_common_font_query_advance(RGBA_Font *fn, const Eina_Unicode *text, const Ev
    EVAS_FONT_WALK_TEXT_START()
      {
         EVAS_FONT_WALK_TEXT_WORK();
-        /* Keep the advancement because we want to also do the last
-         * advancement */
-        keep_adv = adv;
      }
    EVAS_FONT_WALK_TEXT_END();
 
    if (v_adv) *v_adv = evas_common_font_get_line_advance(fn);
-   if (h_adv) *h_adv = pen_x + keep_adv;
+   if (h_adv) *h_adv = pen_x;
   evas_common_font_int_use_trim();
 }