Use evas API to get font list

* new api is much faster
 * may be a bit of a hack the way I get the evas (anyone have another way?)
 * I guess I am an author (now that I have fulfilled my dodgy code quota)


SVN revision: 22417
This commit is contained in:
Stafford Mitchell Horne 2006-04-30 11:54:04 +00:00
parent 362b6bb159
commit ba3f5839ea
4 changed files with 36 additions and 61 deletions

View File

@ -10,3 +10,4 @@ Brian Mattern <rephorm@rephorm.com>
Christopher Michael <devilhorns@comcast.net> Christopher Michael <devilhorns@comcast.net>
Viktor Kojouharov <vkojouharov@gmail.com> Viktor Kojouharov <vkojouharov@gmail.com>
ilLogict <illogict@online.fr> ilLogict <illogict@online.fr>
Stafford Horne <shorne@softhome.net>

View File

@ -8,8 +8,6 @@
* - use e_path to search for available fonts * - use e_path to search for available fonts
*/ */
static Evas_List *_e_font_font_dir_available_get (Evas_List * available_fonts, const char *font_dir);
static char _fn_buf[1024]; static char _fn_buf[1024];
EAPI int EAPI int
@ -91,34 +89,49 @@ e_font_apply(void)
EAPI Evas_List * EAPI Evas_List *
e_font_available_list(void) e_font_available_list(void)
{ {
Evas_List *dir_list; Evas_List *evas_fonts;
Evas_List *next; Evas_List *e_fonts;
Evas_List *available; Evas_List *l;
E_Manager *man;
dir_list = e_path_dir_list_get(path_fonts); E_Container *con;
available = NULL;
for ( next = dir_list; next; next = next->next)
{
E_Path_Dir *epd = next->data;
available = _e_font_font_dir_available_get(available, epd->dir);
}
e_path_dir_list_free(dir_list); man = e_manager_current_get();
return available; if (!man) return NULL;
con = e_container_current_get(man);
if (!con) con = e_container_number_get(man, 0);
if (!con) return NULL;
evas_fonts = evas_font_available_list(con->bg_evas);
e_fonts = NULL;
for (l = evas_fonts; l; l = l->next)
{
E_Font_Available *efa;
const char *evas_font;
efa = E_NEW(E_Font_Available, 1);
evas_font = l->data;
efa->name = evas_stringshare_add(evas_font);
e_fonts = evas_list_append(e_fonts, efa);
}
evas_font_available_list_free(con->bg_evas, evas_fonts);
return e_fonts;
} }
EAPI void EAPI void
e_font_available_list_free(Evas_List *available) e_font_available_list_free(Evas_List *available)
{ {
E_Font_Available *efa; E_Font_Available *efa;
while (available) while (available)
{ {
efa = available->data; efa = available->data;
available = evas_list_remove_list(available, available); available = evas_list_remove_list(available, available);
if (efa->name) evas_stringshare_del(efa->name); if (efa->name) evas_stringshare_del(efa->name);
E_FREE(efa); E_FREE(efa);
} }
} }
EAPI void EAPI void
@ -330,43 +343,3 @@ e_font_default_string_get(const char *text_class, int *size_ret)
return _fn_buf; return _fn_buf;
} }
static Evas_List *
_e_font_font_dir_available_get(Evas_List *available_fonts, const char *font_dir)
{
char buf[4096];
FILE *f;
snprintf(buf, sizeof(buf), "%s/fonts.alias", font_dir);
f = fopen(buf, "r");
if (f)
{
char fname[4096], fdef[4096];
Evas_List *next;
/* read font alias lines */
while (fscanf(f, "%4090s %[^\n]\n", fname, fdef) == 2)
{
E_Font_Available *efa;
/* skip comments */
if ((fdef[0] == '!') || (fdef[0] == '#'))
continue;
/* skip duplicates */
for (next = available_fonts; next; next = evas_list_next(next))
{
efa = (E_Font_Available *)evas_list_data(next);
if (!strcmp(efa->name, fname))
continue;
}
efa = malloc(sizeof(E_Font_Available));
efa->name = evas_stringshare_add(fname);
available_fonts = evas_list_append(available_fonts, efa);
}
fclose (f);
}
return available_fonts;
}

View File

@ -5,7 +5,7 @@
typedef struct _E_Font_Default E_Font_Default; typedef struct _E_Font_Default E_Font_Default;
typedef struct _E_Font_Fallback E_Font_Fallback; typedef struct _E_Font_Fallback E_Font_Fallback;
typedef struct _E_Font_Fallback E_Font_Available; typedef struct _E_Font_Available E_Font_Available;
#else #else
#ifndef E_FONT_H #ifndef E_FONT_H

View File

@ -671,4 +671,5 @@ e_ipc_codec_str_4int_list_enc(Evas_List *list, int *size_ret)
/* local subsystem globals */ /* local subsystem globals */
#endif #endif