Evas font: Iterate with pointers, not indexes.
authortasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 20 Mar 2011 15:05:05 +0000 (15:05 +0000)
committertasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 20 Mar 2011 15:05:05 +0000 (15:05 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@57917 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/engines/common/evas_font_ot.c
src/lib/engines/common/evas_text_utils.c

index 62ed99a..6a6a4e4 100644 (file)
@@ -194,6 +194,8 @@ evas_common_font_ot_populate_text_props(void *_fn, const Eina_Unicode *text,
    hb_glyph_info_t *infos;
    int slen;
    unsigned int i;
+   Evas_Font_Glyph_Info *gl_itr;
+   Evas_Font_OT_Info *ot_itr;
 
    fi = fn->fonts->data;
    /* Load the font needed for this script */
@@ -246,13 +248,20 @@ evas_common_font_ot_populate_text_props(void *_fn, const Eina_Unicode *text,
               sizeof(Evas_Font_Glyph_Info));
    positions = hb_buffer_get_glyph_positions(buffer);
    infos = hb_buffer_get_glyph_infos(buffer);
+   gl_itr = props->info->glyph;
+   ot_itr = props->info->ot;
    for (i = 0 ; i < props->len ; i++)
      {
-        props->info->ot[i].source_cluster = infos[i].cluster;
-        props->info->ot[i].x_offset = positions[i].x_offset;
-        props->info->ot[i].y_offset = positions[i].y_offset;
-        props->info->glyph[i].index = infos[i].codepoint;
-        props->info->glyph[i].advance = positions[i].x_advance;
+        ot_itr->source_cluster = infos->cluster;
+        ot_itr->x_offset = positions->x_offset;
+        ot_itr->y_offset = positions->y_offset;
+        gl_itr->index = infos->codepoint;
+        gl_itr->advance = positions->x_advance;
+
+        ot_itr++;
+        gl_itr++;
+        infos++;
+        positions++;
      }
 
    hb_buffer_destroy(buffer);
index fe54ca4..616cd7e 100644 (file)
@@ -175,7 +175,6 @@ evas_common_text_props_content_create(void *_fn, const Eina_Unicode *text,
 {
    RGBA_Font *fn = (RGBA_Font *) _fn;
    RGBA_Font_Int *fi;
-   size_t char_index;
 
    if (text_props->info)
      {
@@ -200,6 +199,8 @@ evas_common_text_props_content_create(void *_fn, const Eina_Unicode *text,
      }
 
 #ifdef OT_SUPPORT
+   size_t char_index;
+   Evas_Font_Glyph_Info *gl_itr;
    const Eina_Unicode *base_char;
    evas_common_font_ot_populate_text_props(fn, text, text_props, len);
 
@@ -217,19 +218,20 @@ evas_common_text_props_content_create(void *_fn, const Eina_Unicode *text,
         evas_common_font_glyph_search(fn, &fi, *base_char);
      }
 
+   gl_itr = text_props->info->glyph;
    for (char_index = 0 ; char_index < text_props->len ; char_index++)
      {
         FT_UInt index;
         RGBA_Font_Glyph *fg;
         Eina_Bool is_replacement = EINA_FALSE;
         /* If we got a malformed index, show the replacement char instead */
-        if (text_props->info->glyph[char_index].index == 0)
+        if (gl_itr->index == 0)
           {
-             text_props->info->glyph[char_index].index =
+             gl_itr->index =
                 evas_common_font_glyph_search(fn, &fi, REPLACEMENT_CHAR);
              is_replacement = EINA_TRUE;
           }
-        index = text_props->info->glyph[char_index].index;
+        index = gl_itr->index;
         LKL(fi->ft_mutex);
         fg = evas_common_font_int_cache_glyph_get(fi, index);
         if (!fg)
@@ -241,25 +243,25 @@ evas_common_text_props_content_create(void *_fn, const Eina_Unicode *text,
         if (is_replacement)
           {
              /* Update the advance accordingly */
-             text_props->info->glyph[char_index].advance =
+             gl_itr->advance =
                 fg->glyph->advance.x >> 10;
              /* FIXME: reload fi, a bit slow, but I have no choice. */
              evas_common_font_glyph_search(fn, &fi, *base_char);
           }
-        text_props->info->glyph[char_index].x_bear =
-           fg->glyph_out->left;
-        text_props->info->glyph[char_index].width =
-           fg->glyph_out->bitmap.width;
+        gl_itr->x_bear = fg->glyph_out->left;
+        gl_itr->width = fg->glyph_out->bitmap.width;
         /* text_props->info->glyph[char_index].advance =
          * text_props->info->glyph[char_index].index =
          * already done by the ot function */
         if (EVAS_FONT_CHARACTER_IS_INVISIBLE(
               text[text_props->info->ot[char_index].source_cluster]))
-           text_props->info->glyph[char_index].index = 0;
+           gl_itr->index = 0;
 
+        gl_itr++;
      }
 #else
    /* We are walking the string in visual ordering */
+   Evas_Font_Glyph_Info *gl_itr;
    Eina_Bool use_kerning;
    FT_UInt prev_index;
    FT_Face pface = NULL;
@@ -282,8 +284,9 @@ evas_common_text_props_content_create(void *_fn, const Eina_Unicode *text,
      {
         adv_d = 1;
      }
-   char_index = 0;
-   for ( ; i > 0 ; char_index++, text += adv_d, i--)
+
+   gl_itr = text_props->info->glyph;
+   for ( ; i > 0 ; gl_itr++, text += adv_d, i--)
      {
         FT_UInt index;
         RGBA_Font_Glyph *fg;
@@ -331,8 +334,7 @@ evas_common_text_props_content_create(void *_fn, const Eina_Unicode *text,
                {
                   if (evas_common_font_query_kerning(fi, index, prev_index, &kern))
                     {
-                       text_props->info->glyph[char_index - 1].advance +=
-                          kern;
+                       (gl_itr - 1)->advance += kern;
                     }
                }
              else
@@ -340,8 +342,7 @@ evas_common_text_props_content_create(void *_fn, const Eina_Unicode *text,
                {
                   if (evas_common_font_query_kerning(fi, prev_index, index, &kern))
                     {
-                       text_props->info->glyph[char_index - 1].advance +=
-                          kern;
+                       (gl_itr - 1)->advance += kern;
                     }
                }
           }
@@ -350,15 +351,12 @@ evas_common_text_props_content_create(void *_fn, const Eina_Unicode *text,
         LKU(fi->ft_mutex);
 
         if (EVAS_FONT_CHARACTER_IS_INVISIBLE(_gl))
-           text_props->info->glyph[char_index].index = 0;
-
-        text_props->info->glyph[char_index].index = index;
-        text_props->info->glyph[char_index].x_bear =
-           fg->glyph_out->left;
-        text_props->info->glyph[char_index].advance =
-           fg->glyph->advance.x >> 10;
-        text_props->info->glyph[char_index].width =
-           fg->glyph_out->bitmap.width;
+           gl_itr->index = 0;
+
+        gl_itr->index = index;
+        gl_itr->x_bear = fg->glyph_out->left;
+        gl_itr->advance = fg->glyph->advance.x >> 10;
+        gl_itr->width = fg->glyph_out->bitmap.width;
 
         prev_index = index;
      }