Enlightenment CVS committal

Author  : shorne
Project : e17
Module  : libs/evas

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


Modified Files:
        evas_font_draw.c evas_font_load.c 


Log Message:
Evas on-demand font loading
 * When fonts are added from files we will only load the details
 * The first font is always loaded
 * I know there is a patch for this on the list but this way seems better to me


===================================================================
RCS file: /cvs/e/e17/libs/evas/src/lib/engines/common/evas_font_draw.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -3 -r1.22 -r1.23
--- evas_font_draw.c    1 Mar 2006 03:48:02 -0000       1.22
+++ evas_font_draw.c    9 Apr 2006 00:02:47 -0000       1.23
@@ -64,6 +64,13 @@
        int index;
 
        fi = l->data;
+       if (!fi->ft.size)
+         {
+            if (!fi->src->ft.face)
+              evas_common_font_source_load_complete(fi->src);
+            evas_common_font_int_load_complete(fi);
+         }
+         
         index = FT_Get_Char_Index(fi->src->ft.face, gl);
        if (index != 0)
          {
@@ -90,7 +97,7 @@
    FT_Face pface = NULL;
 
    fi = fn->fonts->data;
-
+   
    im = dst->image->data;
    im_w = dst->image->w;
    im_h = dst->image->h;
===================================================================
RCS file: /cvs/e/e17/libs/evas/src/lib/engines/common/evas_font_load.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -3 -r1.32 -r1.33
--- evas_font_load.c    19 Mar 2006 04:29:57 -0000      1.32
+++ evas_font_load.c    9 Apr 2006 00:02:47 -0000       1.33
@@ -48,21 +48,33 @@
    fs->data = NULL;
    fs->data_size = 0;
    fs->current_size = 0;
-   error = FT_New_Face(evas_ft_lib, name, 0, &(fs->ft.face));
-   if (error)
-     {
-       free(fs);
-       return NULL;
-     }
+   fs->ft.face = NULL;
+   
    fs->name = evas_stringshare_add(name);
    fs->file = fs->name;
-   error = FT_Select_Charmap(fs->ft.face, ft_encoding_unicode);
-   fs->ft.orig_upem = fs->ft.face->units_per_EM;
+   
+   fs->ft.orig_upem = 0;
+   
    fs->references = 1;
    fonts_src = evas_object_list_prepend(fonts_src, fs);
    return fs;
 }
 
+int
+evas_common_font_source_load_complete(RGBA_Font_Source *fs)
+{
+   int error;
+  
+   error = FT_New_Face(evas_ft_lib, fs->name, 0, &(fs->ft.face));
+   if (error) return error;
+   
+   error = FT_Select_Charmap(fs->ft.face, ft_encoding_unicode);
+   if (error) return error;
+   
+   fs->ft.orig_upem = fs->ft.face->units_per_EM;
+   return error;
+}
+
 RGBA_Font_Source *
 evas_common_font_source_find(const char *name)
 {
@@ -127,7 +139,8 @@
    if (!fi) return NULL;
 
    fi->src = evas_common_font_source_find(name);
-   if (!fi->src) fi->src = evas_common_font_source_memory_load(name, data, 
data_size);
+   if (!fi->src) 
+     fi->src = evas_common_font_source_memory_load(name, data, data_size);
 
    if (!fi->src)
      {
@@ -148,6 +161,8 @@
    fi = evas_common_font_int_find(name, size);
    if (fi) return fi;
 
+   if (!evas_file_path_is_file(name)) return NULL;
+   
    fi = calloc(1, sizeof(RGBA_Font_Int));
    if (!fi) return NULL;
 
@@ -169,6 +184,16 @@
 RGBA_Font_Int *
 evas_common_font_int_load_init(RGBA_Font_Int *fi)
 {
+   fi->glyphs = NULL;
+   fi->usage = 0;
+   fi->references = 1;
+   fonts = evas_object_list_prepend(fonts, fi);
+   return fi;
+}
+
+RGBA_Font_Int *
+evas_common_font_int_load_complete(RGBA_Font_Int *fi)
+{
    int error;
 
    error = FT_New_Size(fi->src->ft.face, &(fi->ft.size));
@@ -214,14 +239,9 @@
          }
      }
    fi->src->current_size = fi->size;
-
-   fi->glyphs = NULL;
-   fi->usage = 0;
-   fi->references = 1;
-   fonts = evas_object_list_prepend(fonts, fi);
+   
    return fi;
 }
-
 RGBA_Font *
 evas_common_font_memory_load(const char *name, int size, const void *data, int 
data_size)
 {
@@ -250,6 +270,22 @@
 
    fi = evas_common_font_int_load(name, size);
    if (!fi) return NULL;
+   /* First font, complete load */ 
+   if (!fi->ft.size)
+     {
+       if (!fi->src->ft.face)
+         {
+            if (evas_common_font_source_load_complete(fi->src))
+              {
+                 fonts = evas_object_list_remove(fonts, fi);
+                 evas_common_font_source_free(fi->src);
+                 free(fi);
+                 return NULL;
+              }
+         }
+       evas_common_font_int_load_complete(fi);
+     }
+   
    fn = calloc(1, sizeof(RGBA_Font));
    if (!fn)
      {
@@ -259,6 +295,7 @@
    fn->fonts = evas_list_append(fn->fonts, fi);
    fn->hinting = FONT_BYTECODE_HINT;
    fi->hinting = fn->hinting;
+
    return fn;
 }
 




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to