Eina_List *samplelist;
Eina_List *tonelist;
Eina_List *vibrationlist;
+ Eina_List *fontlist;
};
typedef struct _Edje_Pick_File_Params Edje_Pick_File_Params;
struct _Edje_Pick_Font
{
Edje_Font *f;
+
+ void *data; /* Font data as take from source edj file */
+ int size; /* data size */
Eina_Bool used;
};
typedef struct _Edje_Pick_Font Edje_Pick_Font;
{
Eina_Bool v; /* Verbose */
Edje_Pick_File_Params *current_file;
- Eina_List *fontlist;
};
typedef struct _Edje_Pick Edje_Pick;
-static Edje_Pick context = { EINA_FALSE, NULL, NULL };
+static Edje_Pick context = { EINA_FALSE, NULL };
#define VERBOSE(COMMAND) if (context.v) { COMMAND; }
free(p);
}
- EINA_LIST_FREE(context.fontlist, ft)
+ EINA_LIST_FREE(p->fontlist, ft)
{
Edje_Font *st = ft->f;
eina_stringshare_del(st->name);
eina_stringshare_del(st->file);
+ free(ft->data);
free(st);
free(ft);
}
o->base_scale = edf->base_scale;
o->collection = eina_hash_string_small_new(NULL);
o->data = eina_hash_string_small_new(NULL);
+ o->fonts = eina_hash_string_small_new(NULL);
/* Open output file */
o->ef = eet_open(name, EET_FILE_MODE_WRITE);
}
static int
-_Edje_Pick_Fonts_add(Edje_File *edf)
+_Edje_Pick_Fonts_add(Edje_File *out_file, Edje_File *edf)
{
- Eet_Data_Descriptor *_font_list_edd = NULL;
- Eet_Data_Descriptor *_font_edd;
- Edje_Font_List *fl;
+ Eina_Iterator *it;
Edje_Font *f;
- Eina_List *l;
+ char buf[1024];
+
+ if (!edf->fonts) return -1;
- _edje_data_font_list_desc_make(&_font_list_edd, &_font_edd);
- fl = eet_data_read(edf->ef, _font_list_edd, "edje_source_fontmap");
+ it = eina_hash_iterator_data_new(edf->fonts);
+ if (!it) return -1;
- EINA_LIST_FOREACH(fl->list, l, f)
+ EINA_ITERATOR_FOREACH(it, f)
{
- if (!eina_list_search_unsorted(context.fontlist,
- _font_cmp, f))
+ if (!eina_list_search_unsorted(context.current_file->fontlist, _font_cmp, f))
+ continue;
+ /* Add only fonts that are NOT regestered in our list */
+ Edje_Pick_Font *ft = malloc(sizeof(*ft));
+ Edje_Font *st = malloc(sizeof(*st));
+ ft->size = 0;
+
+ st->name = (char *) eina_stringshare_add(f->name);
+ st->file = (char *) eina_stringshare_add(f->file);
+
+ snprintf(buf, sizeof(buf), "edje/fonts/%s", f->name);
+ VERBOSE(EINA_LOG_INFO("Trying to read <%s>\n", f->name));
+ ft->data = eet_read(edf->ef, buf, &ft->size);
+ if (!ft->size)
{
- /* Add only fonts that are NOT regestered in our list */
- Edje_Pick_Font *ft = malloc(sizeof(*ft));
- Edje_Font *st = malloc(sizeof(*st));
-
- st->name = (char *) eina_stringshare_add(f->name);
- st->file = (char *) eina_stringshare_add(f->file);
-
- ft->f = st;
- ft->used = EINA_TRUE; /* TODO: Fix this later */
- context.fontlist = eina_list_append(context.fontlist, ft);
+ eina_stringshare_del(st->name);
+ eina_stringshare_del(st->file);
+ free(st);
+ free(ft);
+ VERBOSE(EINA_LOG_INFO("Enable to read <%s>. Skip.\n", f->name));
+ continue;
}
- }
- free(fl);
- eet_data_descriptor_free(_font_list_edd);
- eet_data_descriptor_free(_font_edd);
+ ft->f = st;
+ ft->used = EINA_TRUE; /* TODO: Fix this later */
+ context.current_file->fontlist = eina_list_append(context.current_file->fontlist, ft);
+ eina_hash_direct_add(out_file->fonts, st->name, st);
+ };
+
+ eina_iterator_free(it);
return EDJE_PICK_NO_ERROR;
}
Edje_Part_Collection *edc;
Edje_Part_Collection_Directory_Entry *ce;
Eet_File *ef;
- Edje_Font_List *fl;
Eina_List *f, *l;
char buf[1024];
- void *n;
int k, bytes;
ecore_app_no_system_modules();
/* Build lists of all samples and fonts of input files */
_edje_pick_sounds_add(edf); /* Add Sounds to samplelist */
_edje_pick_vibrations_add(edf); /* Add Vibrations to samplelist */
- _Edje_Pick_Fonts_add(edf); /* Add fonts from file to fonts list */
_edje_pick_data_update(out_file, edf);
_edje_pick_images_copy(edf, out_file); /* Add Images to imagelist */
_edje_cache_file_unref(edf);
+ _Edje_Pick_Fonts_add(out_file, edf); /* Add fonts from file to fonts list */
/* We SKIP writing source, just can't compose it */
/* FIXME: use Edje_Edit code to generate source */
/* Write Scripts from ALL files */
Edje_Pick_Data *s;
Edje_Pick_Tone *tn;
+ Edje_Pick_Font *fn;
Eina_List *t;
EINA_LIST_FOREACH(context.current_file->scriptlist, t, s)
}
}
+ EINA_LIST_FOREACH(context.current_file->fontlist, t, fn)
+ {
+ if (context.current_file->append || fn->used)
+ {
+ snprintf(buf, sizeof(buf), "edje/fonts/%s", fn->f->name);
+ eet_write(out_file->ef, buf, fn->data, fn->size, EINA_TRUE);
+ VERBOSE(EINA_LOG_INFO("Wrote <%s> fonts data <%p> size <%d>\n", buf, fn->data, fn->size));
+ }
+ }
+
EINA_LIST_FOREACH(context.current_file->samplelist, l, s)
{
if (context.current_file->append || s->id.used)
eina_list_free(samples);
eina_list_free(tones);
- fl = calloc(1, sizeof(*fl));
-
- EINA_LIST_FOREACH(context.fontlist, l, n)
- {
- /* Create a font list from used fonts */
- Edje_Pick_Font *fnt = n;
- if (context.current_file->append || fnt->used)
- fl->list = eina_list_append(fl->list, fnt->f);
- }
-
- if (out_file)
- {
- /* Write Fonts from all files */
- Eet_Data_Descriptor *_font_list_edd = NULL;
- Eet_Data_Descriptor *_font_edd;
-
- _edje_data_font_list_desc_make(&_font_list_edd, &_font_edd);
- bytes = eet_data_write(out_file->ef, _font_list_edd,
- "edje_source_fontmap", fl, comp_mode);
- VERBOSE(EINA_LOG_INFO("Wrote <%d> bytes for fontmap.\n", bytes));
-
- eet_data_descriptor_free(_font_list_edd);
- eet_data_descriptor_free(_font_edd);
- }
-
- free(fl);
-
if (output_filename)
printf("Wrote <%s> output file.\n", output_filename);