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
devs/princeamd/enlightenment-0.17-elive
Stafford Mitchell Horne 17 years ago
parent 362b6bb159
commit ba3f5839ea
  1. 1
      AUTHORS
  2. 89
      src/bin/e_font.c
  3. 2
      src/bin/e_font.h
  4. 3
      src/bin/e_ipc_codec.c

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

@ -8,8 +8,6 @@
* - 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];
EAPI int
@ -91,34 +89,49 @@ e_font_apply(void)
EAPI Evas_List *
e_font_available_list(void)
{
Evas_List *dir_list;
Evas_List *next;
Evas_List *available;
Evas_List *evas_fonts;
Evas_List *e_fonts;
Evas_List *l;
E_Manager *man;
E_Container *con;
man = e_manager_current_get();
if (!man) return NULL;
con = e_container_current_get(man);
if (!con) con = e_container_number_get(man, 0);
if (!con) return NULL;
dir_list = e_path_dir_list_get(path_fonts);
available = NULL;
for ( next = dir_list; next; next = next->next)
evas_fonts = evas_font_available_list(con->bg_evas);
e_fonts = NULL;
for (l = evas_fonts; l; l = l->next)
{
E_Path_Dir *epd = next->data;
available = _e_font_font_dir_available_get(available, epd->dir);
}
e_path_dir_list_free(dir_list);
return available;
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
e_font_available_list_free(Evas_List *available)
{
E_Font_Available *efa;
while (available)
{
{
efa = available->data;
available = evas_list_remove_list(available, available);
if (efa->name) evas_stringshare_del(efa->name);
E_FREE(efa);
}
E_FREE(efa);
}
}
EAPI void
@ -330,43 +343,3 @@ e_font_default_string_get(const char *text_class, int *size_ret)
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;
}

@ -5,7 +5,7 @@
typedef struct _E_Font_Default E_Font_Default;
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
#ifndef E_FONT_H

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

Loading…
Cancel
Save