forked from enlightenment/efl
edje_pick: implement fonts copy
Previously this functional was miss. Edje_Pick was tried to copy fonts from data block "edje_source_fontmap" what always empty because edje_cc never fill it. This patch rework the fonts copy from input files. @fix
This commit is contained in:
parent
853adace69
commit
3f92bfc45b
|
@ -68,6 +68,7 @@ struct _Edje_Pick_File_Params
|
||||||
Eina_List *samplelist;
|
Eina_List *samplelist;
|
||||||
Eina_List *tonelist;
|
Eina_List *tonelist;
|
||||||
Eina_List *vibrationlist;
|
Eina_List *vibrationlist;
|
||||||
|
Eina_List *fontlist;
|
||||||
};
|
};
|
||||||
typedef struct _Edje_Pick_File_Params Edje_Pick_File_Params;
|
typedef struct _Edje_Pick_File_Params Edje_Pick_File_Params;
|
||||||
|
|
||||||
|
@ -92,6 +93,9 @@ typedef struct _Edje_Pick_Tone Edje_Pick_Tone;
|
||||||
struct _Edje_Pick_Font
|
struct _Edje_Pick_Font
|
||||||
{
|
{
|
||||||
Edje_Font *f;
|
Edje_Font *f;
|
||||||
|
|
||||||
|
void *data; /* Font data as take from source edj file */
|
||||||
|
int size; /* data size */
|
||||||
Eina_Bool used;
|
Eina_Bool used;
|
||||||
};
|
};
|
||||||
typedef struct _Edje_Pick_Font Edje_Pick_Font;
|
typedef struct _Edje_Pick_Font Edje_Pick_Font;
|
||||||
|
@ -100,11 +104,10 @@ struct _Edje_Pick
|
||||||
{
|
{
|
||||||
Eina_Bool v; /* Verbose */
|
Eina_Bool v; /* Verbose */
|
||||||
Edje_Pick_File_Params *current_file;
|
Edje_Pick_File_Params *current_file;
|
||||||
Eina_List *fontlist;
|
|
||||||
};
|
};
|
||||||
typedef struct _Edje_Pick Edje_Pick;
|
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; }
|
#define VERBOSE(COMMAND) if (context.v) { COMMAND; }
|
||||||
|
|
||||||
|
@ -256,12 +259,13 @@ _edje_pick_cleanup(Eina_List *ifs, Edje_File *out_file, Edje_Pick_Status s)
|
||||||
free(p);
|
free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
EINA_LIST_FREE(context.fontlist, ft)
|
EINA_LIST_FREE(p->fontlist, ft)
|
||||||
{
|
{
|
||||||
Edje_Font *st = ft->f;
|
Edje_Font *st = ft->f;
|
||||||
|
|
||||||
eina_stringshare_del(st->name);
|
eina_stringshare_del(st->name);
|
||||||
eina_stringshare_del(st->file);
|
eina_stringshare_del(st->file);
|
||||||
|
free(ft->data);
|
||||||
free(st);
|
free(st);
|
||||||
free(ft);
|
free(ft);
|
||||||
}
|
}
|
||||||
|
@ -536,6 +540,7 @@ _edje_pick_output_prepare(Edje_File *o, Edje_File *edf, char *name)
|
||||||
o->base_scale = edf->base_scale;
|
o->base_scale = edf->base_scale;
|
||||||
o->collection = eina_hash_string_small_new(NULL);
|
o->collection = eina_hash_string_small_new(NULL);
|
||||||
o->data = 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 */
|
/* Open output file */
|
||||||
o->ef = eet_open(name, EET_FILE_MODE_WRITE);
|
o->ef = eet_open(name, EET_FILE_MODE_WRITE);
|
||||||
|
@ -1103,38 +1108,49 @@ _font_cmp(const void *d1, const void *d2)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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;
|
Eina_Iterator *it;
|
||||||
Eet_Data_Descriptor *_font_edd;
|
|
||||||
Edje_Font_List *fl;
|
|
||||||
Edje_Font *f;
|
Edje_Font *f;
|
||||||
Eina_List *l;
|
char buf[1024];
|
||||||
|
|
||||||
_edje_data_font_list_desc_make(&_font_list_edd, &_font_edd);
|
if (!edf->fonts) return -1;
|
||||||
fl = eet_data_read(edf->ef, _font_list_edd, "edje_source_fontmap");
|
|
||||||
|
|
||||||
EINA_LIST_FOREACH(fl->list, l, f)
|
it = eina_hash_iterator_data_new(edf->fonts);
|
||||||
{
|
if (!it) return -1;
|
||||||
if (!eina_list_search_unsorted(context.fontlist,
|
|
||||||
_font_cmp, f))
|
EINA_ITERATOR_FOREACH(it, f)
|
||||||
{
|
{
|
||||||
|
if (!eina_list_search_unsorted(context.current_file->fontlist, _font_cmp, f))
|
||||||
|
continue;
|
||||||
/* Add only fonts that are NOT regestered in our list */
|
/* Add only fonts that are NOT regestered in our list */
|
||||||
Edje_Pick_Font *ft = malloc(sizeof(*ft));
|
Edje_Pick_Font *ft = malloc(sizeof(*ft));
|
||||||
Edje_Font *st = malloc(sizeof(*st));
|
Edje_Font *st = malloc(sizeof(*st));
|
||||||
|
ft->size = 0;
|
||||||
|
|
||||||
st->name = (char *) eina_stringshare_add(f->name);
|
st->name = (char *) eina_stringshare_add(f->name);
|
||||||
st->file = (char *) eina_stringshare_add(f->file);
|
st->file = (char *) eina_stringshare_add(f->file);
|
||||||
|
|
||||||
ft->f = st;
|
snprintf(buf, sizeof(buf), "edje/fonts/%s", f->name);
|
||||||
ft->used = EINA_TRUE; /* TODO: Fix this later */
|
VERBOSE(EINA_LOG_INFO("Trying to read <%s>\n", f->name));
|
||||||
context.fontlist = eina_list_append(context.fontlist, ft);
|
ft->data = eet_read(edf->ef, buf, &ft->size);
|
||||||
}
|
if (!ft->size)
|
||||||
|
{
|
||||||
|
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);
|
ft->f = st;
|
||||||
eet_data_descriptor_free(_font_list_edd);
|
ft->used = EINA_TRUE; /* TODO: Fix this later */
|
||||||
eet_data_descriptor_free(_font_edd);
|
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;
|
return EDJE_PICK_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -1659,10 +1675,8 @@ main(int argc, char **argv)
|
||||||
Edje_Part_Collection *edc;
|
Edje_Part_Collection *edc;
|
||||||
Edje_Part_Collection_Directory_Entry *ce;
|
Edje_Part_Collection_Directory_Entry *ce;
|
||||||
Eet_File *ef;
|
Eet_File *ef;
|
||||||
Edje_Font_List *fl;
|
|
||||||
Eina_List *f, *l;
|
Eina_List *f, *l;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
void *n;
|
|
||||||
int k, bytes;
|
int k, bytes;
|
||||||
|
|
||||||
ecore_app_no_system_modules();
|
ecore_app_no_system_modules();
|
||||||
|
@ -1716,7 +1730,6 @@ main(int argc, char **argv)
|
||||||
/* Build lists of all samples and fonts of input files */
|
/* Build lists of all samples and fonts of input files */
|
||||||
_edje_pick_sounds_add(edf); /* Add Sounds to samplelist */
|
_edje_pick_sounds_add(edf); /* Add Sounds to samplelist */
|
||||||
_edje_pick_vibrations_add(edf); /* Add Vibrations 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_data_update(out_file, edf);
|
||||||
|
|
||||||
|
@ -1771,6 +1784,7 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
_edje_pick_images_copy(edf, out_file); /* Add Images to imagelist */
|
_edje_pick_images_copy(edf, out_file); /* Add Images to imagelist */
|
||||||
_edje_cache_file_unref(edf);
|
_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 */
|
/* We SKIP writing source, just can't compose it */
|
||||||
/* FIXME: use Edje_Edit code to generate source */
|
/* FIXME: use Edje_Edit code to generate source */
|
||||||
|
@ -1783,6 +1797,7 @@ main(int argc, char **argv)
|
||||||
/* Write Scripts from ALL files */
|
/* Write Scripts from ALL files */
|
||||||
Edje_Pick_Data *s;
|
Edje_Pick_Data *s;
|
||||||
Edje_Pick_Tone *tn;
|
Edje_Pick_Tone *tn;
|
||||||
|
Edje_Pick_Font *fn;
|
||||||
Eina_List *t;
|
Eina_List *t;
|
||||||
|
|
||||||
EINA_LIST_FOREACH(context.current_file->scriptlist, t, s)
|
EINA_LIST_FOREACH(context.current_file->scriptlist, t, s)
|
||||||
|
@ -1825,6 +1840,16 @@ main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
EINA_LIST_FOREACH(context.current_file->samplelist, l, s)
|
||||||
{
|
{
|
||||||
if (context.current_file->append || s->id.used)
|
if (context.current_file->append || s->id.used)
|
||||||
|
@ -1877,33 +1902,6 @@ main(int argc, char **argv)
|
||||||
eina_list_free(samples);
|
eina_list_free(samples);
|
||||||
eina_list_free(tones);
|
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)
|
if (output_filename)
|
||||||
printf("Wrote <%s> output file.\n", output_filename);
|
printf("Wrote <%s> output file.\n", output_filename);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue