summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVyacheslav Reutskiy <v.reutskiy@samsung.com>2017-01-31 10:11:36 +0200
committerVyacheslav Reutskiy <v.reutskiy@samsung.com>2017-01-31 10:15:13 +0200
commit3f92bfc45bae5f74b18ac98b989da4e7a14c1fd1 (patch)
tree4d10b9cfaabdfd42b32308a9d2dd7436c8e44059
parent853adace69f2532dfb5427737054b3c94c30f93b (diff)
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
-rw-r--r--src/bin/edje/edje_pick.c112
1 files changed, 55 insertions, 57 deletions
diff --git a/src/bin/edje/edje_pick.c b/src/bin/edje/edje_pick.c
index c7d41f6da1..44c43b8305 100644
--- a/src/bin/edje/edje_pick.c
+++ b/src/bin/edje/edje_pick.c
@@ -68,6 +68,7 @@ struct _Edje_Pick_File_Params
68 Eina_List *samplelist; 68 Eina_List *samplelist;
69 Eina_List *tonelist; 69 Eina_List *tonelist;
70 Eina_List *vibrationlist; 70 Eina_List *vibrationlist;
71 Eina_List *fontlist;
71}; 72};
72typedef struct _Edje_Pick_File_Params Edje_Pick_File_Params; 73typedef struct _Edje_Pick_File_Params Edje_Pick_File_Params;
73 74
@@ -92,6 +93,9 @@ typedef struct _Edje_Pick_Tone Edje_Pick_Tone;
92struct _Edje_Pick_Font 93struct _Edje_Pick_Font
93{ 94{
94 Edje_Font *f; 95 Edje_Font *f;
96
97 void *data; /* Font data as take from source edj file */
98 int size; /* data size */
95 Eina_Bool used; 99 Eina_Bool used;
96}; 100};
97typedef struct _Edje_Pick_Font Edje_Pick_Font; 101typedef struct _Edje_Pick_Font Edje_Pick_Font;
@@ -100,11 +104,10 @@ struct _Edje_Pick
100{ 104{
101 Eina_Bool v; /* Verbose */ 105 Eina_Bool v; /* Verbose */
102 Edje_Pick_File_Params *current_file; 106 Edje_Pick_File_Params *current_file;
103 Eina_List *fontlist;
104}; 107};
105typedef struct _Edje_Pick Edje_Pick; 108typedef struct _Edje_Pick Edje_Pick;
106 109
107static Edje_Pick context = { EINA_FALSE, NULL, NULL }; 110static Edje_Pick context = { EINA_FALSE, NULL };
108 111
109#define VERBOSE(COMMAND) if (context.v) { COMMAND; } 112#define VERBOSE(COMMAND) if (context.v) { COMMAND; }
110 113
@@ -256,12 +259,13 @@ _edje_pick_cleanup(Eina_List *ifs, Edje_File *out_file, Edje_Pick_Status s)
256 free(p); 259 free(p);
257 } 260 }
258 261
259 EINA_LIST_FREE(context.fontlist, ft) 262 EINA_LIST_FREE(p->fontlist, ft)
260 { 263 {
261 Edje_Font *st = ft->f; 264 Edje_Font *st = ft->f;
262 265
263 eina_stringshare_del(st->name); 266 eina_stringshare_del(st->name);
264 eina_stringshare_del(st->file); 267 eina_stringshare_del(st->file);
268 free(ft->data);
265 free(st); 269 free(st);
266 free(ft); 270 free(ft);
267 } 271 }
@@ -536,6 +540,7 @@ _edje_pick_output_prepare(Edje_File *o, Edje_File *edf, char *name)
536 o->base_scale = edf->base_scale; 540 o->base_scale = edf->base_scale;
537 o->collection = eina_hash_string_small_new(NULL); 541 o->collection = eina_hash_string_small_new(NULL);
538 o->data = eina_hash_string_small_new(NULL); 542 o->data = eina_hash_string_small_new(NULL);
543 o->fonts = eina_hash_string_small_new(NULL);
539 544
540 /* Open output file */ 545 /* Open output file */
541 o->ef = eet_open(name, EET_FILE_MODE_WRITE); 546 o->ef = eet_open(name, EET_FILE_MODE_WRITE);
@@ -1103,38 +1108,49 @@ _font_cmp(const void *d1, const void *d2)
1103} 1108}
1104 1109
1105static int 1110static int
1106_Edje_Pick_Fonts_add(Edje_File *edf) 1111_Edje_Pick_Fonts_add(Edje_File *out_file, Edje_File *edf)
1107{ 1112{
1108 Eet_Data_Descriptor *_font_list_edd = NULL; 1113 Eina_Iterator *it;
1109 Eet_Data_Descriptor *_font_edd;
1110 Edje_Font_List *fl;
1111 Edje_Font *f; 1114 Edje_Font *f;
1112 Eina_List *l; 1115 char buf[1024];
1116
1117 if (!edf->fonts) return -1;
1113 1118
1114 _edje_data_font_list_desc_make(&_font_list_edd, &_font_edd); 1119 it = eina_hash_iterator_data_new(edf->fonts);
1115 fl = eet_data_read(edf->ef, _font_list_edd, "edje_source_fontmap"); 1120 if (!it) return -1;
1116 1121
1117 EINA_LIST_FOREACH(fl->list, l, f) 1122 EINA_ITERATOR_FOREACH(it, f)
1118 { 1123 {
1119 if (!eina_list_search_unsorted(context.fontlist, 1124 if (!eina_list_search_unsorted(context.current_file->fontlist, _font_cmp, f))
1120 _font_cmp, f)) 1125 continue;
1126 /* Add only fonts that are NOT regestered in our list */
1127 Edje_Pick_Font *ft = malloc(sizeof(*ft));
1128 Edje_Font *st = malloc(sizeof(*st));
1129 ft->size = 0;
1130
1131 st->name = (char *) eina_stringshare_add(f->name);
1132 st->file = (char *) eina_stringshare_add(f->file);
1133
1134 snprintf(buf, sizeof(buf), "edje/fonts/%s", f->name);
1135 VERBOSE(EINA_LOG_INFO("Trying to read <%s>\n", f->name));
1136 ft->data = eet_read(edf->ef, buf, &ft->size);
1137 if (!ft->size)
1121 { 1138 {
1122 /* Add only fonts that are NOT regestered in our list */ 1139 eina_stringshare_del(st->name);
1123 Edje_Pick_Font *ft = malloc(sizeof(*ft)); 1140 eina_stringshare_del(st->file);
1124 Edje_Font *st = malloc(sizeof(*st)); 1141 free(st);
1125 1142 free(ft);
1126 st->name = (char *) eina_stringshare_add(f->name); 1143 VERBOSE(EINA_LOG_INFO("Enable to read <%s>. Skip.\n", f->name));
1127 st->file = (char *) eina_stringshare_add(f->file); 1144 continue;
1128
1129 ft->f = st;
1130 ft->used = EINA_TRUE; /* TODO: Fix this later */
1131 context.fontlist = eina_list_append(context.fontlist, ft);
1132 } 1145 }
1133 }
1134 1146
1135 free(fl); 1147 ft->f = st;
1136 eet_data_descriptor_free(_font_list_edd); 1148 ft->used = EINA_TRUE; /* TODO: Fix this later */
1137 eet_data_descriptor_free(_font_edd); 1149 context.current_file->fontlist = eina_list_append(context.current_file->fontlist, ft);
1150 eina_hash_direct_add(out_file->fonts, st->name, st);
1151 };
1152
1153 eina_iterator_free(it);
1138 1154
1139 return EDJE_PICK_NO_ERROR; 1155 return EDJE_PICK_NO_ERROR;
1140} 1156}
@@ -1659,10 +1675,8 @@ main(int argc, char **argv)
1659 Edje_Part_Collection *edc; 1675 Edje_Part_Collection *edc;
1660 Edje_Part_Collection_Directory_Entry *ce; 1676 Edje_Part_Collection_Directory_Entry *ce;
1661 Eet_File *ef; 1677 Eet_File *ef;
1662 Edje_Font_List *fl;
1663 Eina_List *f, *l; 1678 Eina_List *f, *l;
1664 char buf[1024]; 1679 char buf[1024];
1665 void *n;
1666 int k, bytes; 1680 int k, bytes;
1667 1681
1668 ecore_app_no_system_modules(); 1682 ecore_app_no_system_modules();
@@ -1716,7 +1730,6 @@ main(int argc, char **argv)
1716 /* Build lists of all samples and fonts of input files */ 1730 /* Build lists of all samples and fonts of input files */
1717 _edje_pick_sounds_add(edf); /* Add Sounds to samplelist */ 1731 _edje_pick_sounds_add(edf); /* Add Sounds to samplelist */
1718 _edje_pick_vibrations_add(edf); /* Add Vibrations to samplelist */ 1732 _edje_pick_vibrations_add(edf); /* Add Vibrations to samplelist */
1719 _Edje_Pick_Fonts_add(edf); /* Add fonts from file to fonts list */
1720 1733
1721 _edje_pick_data_update(out_file, edf); 1734 _edje_pick_data_update(out_file, edf);
1722 1735
@@ -1771,6 +1784,7 @@ main(int argc, char **argv)
1771 1784
1772 _edje_pick_images_copy(edf, out_file); /* Add Images to imagelist */ 1785 _edje_pick_images_copy(edf, out_file); /* Add Images to imagelist */
1773 _edje_cache_file_unref(edf); 1786 _edje_cache_file_unref(edf);
1787 _Edje_Pick_Fonts_add(out_file, edf); /* Add fonts from file to fonts list */
1774 1788
1775 /* We SKIP writing source, just can't compose it */ 1789 /* We SKIP writing source, just can't compose it */
1776 /* FIXME: use Edje_Edit code to generate source */ 1790 /* FIXME: use Edje_Edit code to generate source */
@@ -1783,6 +1797,7 @@ main(int argc, char **argv)
1783 /* Write Scripts from ALL files */ 1797 /* Write Scripts from ALL files */
1784 Edje_Pick_Data *s; 1798 Edje_Pick_Data *s;
1785 Edje_Pick_Tone *tn; 1799 Edje_Pick_Tone *tn;
1800 Edje_Pick_Font *fn;
1786 Eina_List *t; 1801 Eina_List *t;
1787 1802
1788 EINA_LIST_FOREACH(context.current_file->scriptlist, t, s) 1803 EINA_LIST_FOREACH(context.current_file->scriptlist, t, s)
@@ -1825,6 +1840,16 @@ main(int argc, char **argv)
1825 } 1840 }
1826 } 1841 }
1827 1842
1843 EINA_LIST_FOREACH(context.current_file->fontlist, t, fn)
1844 {
1845 if (context.current_file->append || fn->used)
1846 {
1847 snprintf(buf, sizeof(buf), "edje/fonts/%s", fn->f->name);
1848 eet_write(out_file->ef, buf, fn->data, fn->size, EINA_TRUE);
1849 VERBOSE(EINA_LOG_INFO("Wrote <%s> fonts data <%p> size <%d>\n", buf, fn->data, fn->size));
1850 }
1851 }
1852
1828 EINA_LIST_FOREACH(context.current_file->samplelist, l, s) 1853 EINA_LIST_FOREACH(context.current_file->samplelist, l, s)
1829 { 1854 {
1830 if (context.current_file->append || s->id.used) 1855 if (context.current_file->append || s->id.used)
@@ -1877,33 +1902,6 @@ main(int argc, char **argv)
1877 eina_list_free(samples); 1902 eina_list_free(samples);
1878 eina_list_free(tones); 1903 eina_list_free(tones);
1879 1904
1880 fl = calloc(1, sizeof(*fl));
1881
1882 EINA_LIST_FOREACH(context.fontlist, l, n)
1883 {
1884 /* Create a font list from used fonts */
1885 Edje_Pick_Font *fnt = n;
1886 if (context.current_file->append || fnt->used)
1887 fl->list = eina_list_append(fl->list, fnt->f);
1888 }
1889
1890 if (out_file)
1891 {
1892 /* Write Fonts from all files */
1893 Eet_Data_Descriptor *_font_list_edd = NULL;
1894 Eet_Data_Descriptor *_font_edd;
1895
1896 _edje_data_font_list_desc_make(&_font_list_edd, &_font_edd);
1897 bytes = eet_data_write(out_file->ef, _font_list_edd,
1898 "edje_source_fontmap", fl, comp_mode);
1899 VERBOSE(EINA_LOG_INFO("Wrote <%d> bytes for fontmap.\n", bytes));
1900
1901 eet_data_descriptor_free(_font_list_edd);
1902 eet_data_descriptor_free(_font_edd);
1903 }
1904
1905 free(fl);
1906
1907 if (output_filename) 1905 if (output_filename)
1908 printf("Wrote <%s> output file.\n", output_filename); 1906 printf("Wrote <%s> output file.\n", output_filename);
1909 1907