diff options
author | subhransu mohanty <sub.mohanty@samsung.com> | 2017-11-07 11:22:09 +0900 |
---|---|---|
committer | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2017-11-07 11:34:53 +0900 |
commit | b038d7df25f9cecaa4f0d8c1c7355e4852e5348a (patch) | |
tree | 595da7d0114056e147d4a40fedc72d5b71b3927a | |
parent | a75b3dcdfbe0760972c8b4d55a90dc6250bd1e45 (diff) |
Remove evas internal dependency from the evas_font module
Summary:
dev branch : devs/subhransu/font
The Final goal is to move the evas_font module to ector so that both ector and evas can reuse the code.
make the api simple so that sam eapi can be used by evas_textblock and ector text.
This is the 1st stage to achive that gola, first remove the evas internal dependancy as much as possible before moving to ector library.
Reviewers: jpeg, raster, herdsman, cedric, id213sin
Subscribers: cedric, jpeg
Differential Revision: https://phab.enlightenment.org/D5419
22 files changed, 1316 insertions, 1208 deletions
diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index 8b82e1aaed..d80e1c2015 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am | |||
@@ -493,7 +493,8 @@ lib/evas/common/language/evas_bidi_utils.h \ | |||
493 | lib/evas/common/language/evas_language_utils.h \ | 493 | lib/evas/common/language/evas_language_utils.h \ |
494 | lib/evas/common/language/evas_script_table.h \ | 494 | lib/evas/common/language/evas_script_table.h \ |
495 | lib/evas/common/evas_text_utils.h \ | 495 | lib/evas/common/evas_text_utils.h \ |
496 | lib/evas/common/evas_font_ot.h | 496 | lib/evas/common/evas_font_ot.h \ |
497 | lib/evas/common/evas_font_draw.h | ||
497 | 498 | ||
498 | lib_evas_libevas_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ | 499 | lib_evas_libevas_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ |
499 | -I$(top_srcdir)/src/lib/evas/canvas \ | 500 | -I$(top_srcdir)/src/lib/evas/canvas \ |
@@ -1608,7 +1609,7 @@ if BUILD_VG_LOADER_SVG | |||
1608 | if EVAS_STATIC_BUILD_VG_SVG | 1609 | if EVAS_STATIC_BUILD_VG_SVG |
1609 | lib_evas_libevas_la_SOURCES += modules/evas/vg_loaders/svg/evas_vg_load_svg.c \ | 1610 | lib_evas_libevas_la_SOURCES += modules/evas/vg_loaders/svg/evas_vg_load_svg.c \ |
1610 | static_libs/vg_common/vg_common.c \ | 1611 | static_libs/vg_common/vg_common.c \ |
1611 | static_libs/vg_common/vg_common.h | 1612 | static_libs/vg_common/vg_common.h |
1612 | lib_evas_libevas_la_CPPFLAGS += -I$(top_srcdir)/src/static_libs/vg_common \ | 1613 | lib_evas_libevas_la_CPPFLAGS += -I$(top_srcdir)/src/static_libs/vg_common \ |
1613 | @evas_vg_loader_svg_cflags@ | 1614 | @evas_vg_loader_svg_cflags@ |
1614 | lib_evas_libevas_la_LIBADD += @evas_vg_loader_svg_libs@ | 1615 | lib_evas_libevas_la_LIBADD += @evas_vg_loader_svg_libs@ |
diff --git a/src/lib/evas/canvas/evas_font_dir.c b/src/lib/evas/canvas/evas_font_dir.c index e120f682d6..cbdef108ff 100644 --- a/src/lib/evas/canvas/evas_font_dir.c +++ b/src/lib/evas/canvas/evas_font_dir.c | |||
@@ -13,8 +13,14 @@ | |||
13 | #include <fontconfig/fcfreetype.h> | 13 | #include <fontconfig/fcfreetype.h> |
14 | #endif | 14 | #endif |
15 | 15 | ||
16 | #include "evas_common_private.h" | 16 | #include "evas_font.h" |
17 | #include "evas_private.h" | 17 | |
18 | /* General types - used for script type chceking */ | ||
19 | #define OPAQUE_TYPE(type) struct __##type { int a; }; \ | ||
20 | typedef struct __##type type | ||
21 | |||
22 | OPAQUE_TYPE(Evas_Font_Set); /* General type for RGBA_Font */ | ||
23 | OPAQUE_TYPE(Evas_Font_Instance); /* General type for RGBA_Font_Int */ | ||
18 | 24 | ||
19 | /* font dir cache */ | 25 | /* font dir cache */ |
20 | static Eina_Hash *font_dirs = NULL; | 26 | static Eina_Hash *font_dirs = NULL; |
@@ -57,6 +63,70 @@ static int evas_object_text_font_string_parse(char *buffer, char dest[14][256]); | |||
57 | static FcConfig *fc_config = NULL; | 63 | static FcConfig *fc_config = NULL; |
58 | #endif | 64 | #endif |
59 | 65 | ||
66 | /* FIXME move these helper function to eina_file or eina_path */ | ||
67 | /* get the casefold feature! */ | ||
68 | #include <fnmatch.h> | ||
69 | #ifndef _MSC_VER | ||
70 | # include <unistd.h> | ||
71 | # include <sys/param.h> | ||
72 | #endif | ||
73 | int | ||
74 | _file_path_is_full_path(const char *path) | ||
75 | { | ||
76 | if (!path) return 0; | ||
77 | #ifdef _WIN32 | ||
78 | if (evil_path_is_absolute(path)) return 1; | ||
79 | #else | ||
80 | if (path[0] == '/') return 1; | ||
81 | #endif | ||
82 | return 0; | ||
83 | } | ||
84 | |||
85 | static DATA64 | ||
86 | _file_modified_time(const char *file) | ||
87 | { | ||
88 | struct stat st; | ||
89 | |||
90 | if (stat(file, &st) < 0) return 0; | ||
91 | if (st.st_ctime > st.st_mtime) return (DATA64)st.st_ctime; | ||
92 | else return (DATA64)st.st_mtime; | ||
93 | return 0; | ||
94 | } | ||
95 | |||
96 | Eina_List * | ||
97 | _file_path_list(char *path, const char *match, int match_case) | ||
98 | { | ||
99 | Eina_File_Direct_Info *info; | ||
100 | Eina_Iterator *it; | ||
101 | Eina_List *files = NULL; | ||
102 | int flags; | ||
103 | |||
104 | flags = FNM_PATHNAME; | ||
105 | #ifdef FNM_CASEFOLD | ||
106 | if (!match_case) | ||
107 | flags |= FNM_CASEFOLD; | ||
108 | #elif defined FNM_IGNORECASE | ||
109 | if (!match_case) | ||
110 | flags |= FNM_IGNORECASE; | ||
111 | #else | ||
112 | /*#warning "Your libc does not provide case-insensitive matching!"*/ | ||
113 | #endif | ||
114 | |||
115 | it = eina_file_direct_ls(path); | ||
116 | EINA_ITERATOR_FOREACH(it, info) | ||
117 | { | ||
118 | if (match) | ||
119 | { | ||
120 | if (fnmatch(match, info->path + info->name_start, flags) == 0) | ||
121 | files = eina_list_append(files, strdup(info->path + info->name_start)); | ||
122 | } | ||
123 | else | ||
124 | files = eina_list_append(files, strdup(info->path + info->name_start)); | ||
125 | } | ||
126 | if (it) eina_iterator_free(it); | ||
127 | return files; | ||
128 | } | ||
129 | |||
60 | static void | 130 | static void |
61 | evas_font_init(void) | 131 | evas_font_init(void) |
62 | { | 132 | { |
@@ -102,13 +172,13 @@ evas_font_dir_cache_find(char *dir, char *font) | |||
102 | fd = object_text_font_cache_dir_update(dir, fd); | 172 | fd = object_text_font_cache_dir_update(dir, fd); |
103 | if (fd) | 173 | if (fd) |
104 | { | 174 | { |
105 | Evas_Font *fn; | 175 | Evas_Font *fn; |
106 | 176 | ||
107 | fn = object_text_font_cache_font_find(fd, font); | 177 | fn = object_text_font_cache_font_find(fd, font); |
108 | if (fn) | 178 | if (fn) |
109 | { | 179 | { |
110 | return fn->path; | 180 | return fn->path; |
111 | } | 181 | } |
112 | } | 182 | } |
113 | return NULL; | 183 | return NULL; |
114 | } | 184 | } |
@@ -122,123 +192,117 @@ evas_font_set_get(const char *name) | |||
122 | p = strchr(name, ','); | 192 | p = strchr(name, ','); |
123 | if (!p) | 193 | if (!p) |
124 | { | 194 | { |
125 | fonts = eina_list_append(fonts, eina_stringshare_add(name)); | 195 | fonts = eina_list_append(fonts, eina_stringshare_add(name)); |
126 | } | 196 | } |
127 | else | 197 | else |
128 | { | 198 | { |
129 | const char *pp; | 199 | const char *pp; |
130 | char *nm; | 200 | char *nm; |
131 | 201 | ||
132 | pp = name; | 202 | pp = name; |
133 | while (p) | 203 | while (p) |
134 | { | 204 | { |
135 | nm = alloca(p - pp + 1); | 205 | nm = alloca(p - pp + 1); |
136 | strncpy(nm, pp, p - pp); | 206 | strncpy(nm, pp, p - pp); |
137 | nm[p - pp] = 0; | 207 | nm[p - pp] = 0; |
138 | fonts = eina_list_append(fonts, eina_stringshare_add(nm)); | 208 | fonts = eina_list_append(fonts, eina_stringshare_add(nm)); |
139 | pp = p + 1; | 209 | pp = p + 1; |
140 | p = strchr(pp, ','); | 210 | p = strchr(pp, ','); |
141 | if (!p) fonts = eina_list_append(fonts, eina_stringshare_add(pp)); | 211 | if (!p) fonts = eina_list_append(fonts, eina_stringshare_add(pp)); |
142 | } | 212 | } |
143 | } | 213 | } |
144 | return fonts; | 214 | return fonts; |
145 | } | 215 | } |
146 | 216 | ||
147 | void | 217 | void |
148 | evas_fonts_zero_free(Evas *eo_evas) | 218 | evas_fonts_zero_free() |
149 | { | 219 | { |
150 | Fndat *fd; | 220 | Fndat *fd; |
151 | Evas_Public_Data *evas = efl_data_scope_get(eo_evas, EVAS_CANVAS_CLASS); | ||
152 | 221 | ||
153 | EINA_LIST_FREE(fonts_zero, fd) | 222 | EINA_LIST_FREE(fonts_zero, fd) |
154 | { | 223 | { |
155 | if (fd->fdesc) evas_font_desc_unref(fd->fdesc); | 224 | if (fd->fdesc) evas_font_desc_unref(fd->fdesc); |
156 | if (fd->source) eina_stringshare_del(fd->source); | 225 | if (fd->source) eina_stringshare_del(fd->source); |
157 | if ((evas->engine.func) && (evas->engine.func->font_free)) | 226 | evas_common_font_free((RGBA_Font *)fd->font); |
158 | evas->engine.func->font_free(_evas_engine_context(evas), fd->font); | ||
159 | #ifdef HAVE_FONTCONFIG | 227 | #ifdef HAVE_FONTCONFIG |
160 | if (fd->set) FcFontSetDestroy(fd->set); | 228 | if (fd->set) FcFontSetDestroy(fd->set); |
161 | if (fd->p_nm) FcPatternDestroy(fd->p_nm); | 229 | if (fd->p_nm) FcPatternDestroy(fd->p_nm); |
162 | #endif | 230 | #endif |
163 | free(fd); | 231 | free(fd); |
164 | } | 232 | } |
165 | } | 233 | } |
166 | 234 | ||
167 | void | 235 | void |
168 | evas_fonts_zero_pressure(Evas *eo_evas) | 236 | evas_fonts_zero_pressure() |
169 | { | 237 | { |
170 | Fndat *fd; | 238 | Fndat *fd; |
171 | Evas_Public_Data *evas = efl_data_scope_get(eo_evas, EVAS_CANVAS_CLASS); | ||
172 | 239 | ||
173 | while (fonts_zero | 240 | while (fonts_zero |
174 | && eina_list_count(fonts_zero) > 4) /* 4 is arbitrary */ | 241 | && eina_list_count(fonts_zero) > 4) /* 4 is arbitrary */ |
175 | { | 242 | { |
176 | fd = eina_list_data_get(fonts_zero); | 243 | fd = eina_list_data_get(fonts_zero); |
177 | 244 | ||
178 | if (fd->ref != 0) break; | 245 | if (fd->ref != 0) break; |
179 | fonts_zero = eina_list_remove_list(fonts_zero, fonts_zero); | 246 | fonts_zero = eina_list_remove_list(fonts_zero, fonts_zero); |
180 | 247 | ||
181 | if (fd->fdesc) evas_font_desc_unref(fd->fdesc); | 248 | if (fd->fdesc) evas_font_desc_unref(fd->fdesc); |
182 | if (fd->source) eina_stringshare_del(fd->source); | 249 | if (fd->source) eina_stringshare_del(fd->source); |
183 | if ((evas->engine.func) && (evas->engine.func->font_free)) | 250 | evas_common_font_free((RGBA_Font *)fd->font); |
184 | evas->engine.func->font_free(_evas_engine_context(evas), fd->font); | 251 | #ifdef HAVE_FONTCONFIG |
185 | #ifdef HAVE_FONTCONFIG | 252 | if (fd->set) FcFontSetDestroy(fd->set); |
186 | if (fd->set) FcFontSetDestroy(fd->set); | 253 | if (fd->p_nm) FcPatternDestroy(fd->p_nm); |
187 | if (fd->p_nm) FcPatternDestroy(fd->p_nm); | 254 | #endif |
188 | #endif | 255 | free(fd); |
189 | free(fd); | 256 | |
190 | 257 | if (eina_list_count(fonts_zero) < 5) break; | |
191 | if (eina_list_count(fonts_zero) < 5) break; | ||
192 | } | 258 | } |
193 | } | 259 | } |
194 | 260 | ||
195 | void | 261 | void |
196 | evas_font_free(Evas *eo_evas, void *font) | 262 | evas_font_free(void *font) |
197 | { | 263 | { |
198 | Eina_List *l; | 264 | Eina_List *l; |
199 | Fndat *fd; | 265 | Fndat *fd; |
200 | Evas_Public_Data *evas = efl_data_scope_get(eo_evas, EVAS_CANVAS_CLASS); | ||
201 | 266 | ||
202 | EINA_LIST_FOREACH(fonts_cache, l, fd) | 267 | EINA_LIST_FOREACH(fonts_cache, l, fd) |
203 | { | 268 | { |
204 | if (fd->font == font) | 269 | if (fd->font == font) |
205 | { | 270 | { |
206 | fd->ref--; | 271 | fd->ref--; |
207 | if (fd->ref == 0) | 272 | if (fd->ref == 0) |
208 | { | 273 | { |
209 | fonts_cache = eina_list_remove_list(fonts_cache, l); | 274 | fonts_cache = eina_list_remove_list(fonts_cache, l); |
210 | fonts_zero = eina_list_append(fonts_zero, fd); | 275 | fonts_zero = eina_list_append(fonts_zero, fd); |
211 | } | 276 | } |
212 | break; | 277 | break; |
213 | } | 278 | } |
214 | } | 279 | } |
215 | while (fonts_zero | 280 | while (fonts_zero |
216 | && eina_list_count(fonts_zero) > 42) /* 42 is arbitrary */ | 281 | && eina_list_count(fonts_zero) > 42) /* 42 is arbitrary */ |
217 | { | 282 | { |
218 | fd = eina_list_data_get(fonts_zero); | 283 | fd = eina_list_data_get(fonts_zero); |
219 | 284 | ||
220 | if (fd->ref != 0) break; | 285 | if (fd->ref != 0) break; |
221 | fonts_zero = eina_list_remove_list(fonts_zero, fonts_zero); | 286 | fonts_zero = eina_list_remove_list(fonts_zero, fonts_zero); |
222 | 287 | ||
223 | if (fd->fdesc) evas_font_desc_unref(fd->fdesc); | 288 | if (fd->fdesc) evas_font_desc_unref(fd->fdesc); |
224 | if (fd->source) eina_stringshare_del(fd->source); | 289 | if (fd->source) eina_stringshare_del(fd->source); |
225 | evas->engine.func->font_free(_evas_engine_context(evas), fd->font); | 290 | evas_common_font_free((RGBA_Font *)fd->font); |
226 | #ifdef HAVE_FONTCONFIG | 291 | #ifdef HAVE_FONTCONFIG |
227 | if (fd->set) FcFontSetDestroy(fd->set); | 292 | if (fd->set) FcFontSetDestroy(fd->set); |
228 | if (fd->p_nm) FcPatternDestroy(fd->p_nm); | 293 | if (fd->p_nm) FcPatternDestroy(fd->p_nm); |
229 | #endif | 294 | #endif |
230 | free(fd); | 295 | free(fd); |
231 | 296 | ||
232 | if (eina_list_count(fonts_zero) < 43) break; | 297 | if (eina_list_count(fonts_zero) < 43) break; |
233 | } | 298 | } |
234 | } | 299 | } |
235 | 300 | ||
236 | #ifdef HAVE_FONTCONFIG | 301 | #ifdef HAVE_FONTCONFIG |
237 | static Evas_Font_Set * | 302 | static Evas_Font_Set * |
238 | _evas_load_fontconfig(Evas_Font_Set *font, Evas *eo_evas, FcFontSet *set, int size, | 303 | _evas_load_fontconfig(Evas_Font_Set *font, FcFontSet *set, int size, |
239 | Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable) | 304 | Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable) |
240 | { | 305 | { |
241 | Evas_Public_Data *evas = efl_data_scope_get(eo_evas, EVAS_CANVAS_CLASS); | ||
242 | int i; | 306 | int i; |
243 | 307 | ||
244 | /* Do loading for all in family */ | 308 | /* Do loading for all in family */ |
@@ -249,9 +313,9 @@ _evas_load_fontconfig(Evas_Font_Set *font, Evas *eo_evas, FcFontSet *set, int si | |||
249 | if (FcPatternGet(set->fonts[i], FC_FILE, 0, &filename) == FcResultMatch) | 313 | if (FcPatternGet(set->fonts[i], FC_FILE, 0, &filename) == FcResultMatch) |
250 | { | 314 | { |
251 | if (font) | 315 | if (font) |
252 | evas->engine.func->font_add(_evas_engine_context(evas), font, (char *)filename.u.s, size, wanted_rend, bitmap_scalable); | 316 | evas_common_font_add((RGBA_Font *)font, (char *)filename.u.s, size, wanted_rend, bitmap_scalable); |
253 | else | 317 | else |
254 | font = evas->engine.func->font_load(_evas_engine_context(evas), (char *)filename.u.s, size, wanted_rend, bitmap_scalable); | 318 | font = (Evas_Font_Set *)evas_common_font_load((char *)filename.u.s, size, wanted_rend, bitmap_scalable); |
255 | } | 319 | } |
256 | } | 320 | } |
257 | 321 | ||
@@ -385,7 +449,7 @@ _evas_font_style_find_internal(const char *style, const char *style_end, | |||
385 | const char *cur = _map[i].name; | 449 | const char *cur = _map[i].name; |
386 | len = strlen(cur); | 450 | len = strlen(cur); |
387 | if (!strncasecmp(style, cur, len) && | 451 | if (!strncasecmp(style, cur, len) && |
388 | (!cur[len] || (cur[len] == ' '))) | 452 | (!cur[len] || (cur[len] == ' '))) |
389 | { | 453 | { |
390 | return _map[i].type; | 454 | return _map[i].type; |
391 | } | 455 | } |
@@ -474,8 +538,8 @@ evas_font_desc_cmp(const Evas_Font_Description *a, | |||
474 | { | 538 | { |
475 | /* FIXME: Do actual comparison, i.e less than and bigger than. */ | 539 | /* FIXME: Do actual comparison, i.e less than and bigger than. */ |
476 | return !((a->name == b->name) && (a->weight == b->weight) && | 540 | return !((a->name == b->name) && (a->weight == b->weight) && |
477 | (a->slant == b->slant) && (a->width == b->width) && | 541 | (a->slant == b->slant) && (a->width == b->width) && |
478 | (a->spacing == b->spacing) && (a->lang == b->lang)); | 542 | (a->spacing == b->spacing) && (a->lang == b->lang)); |
479 | } | 543 | } |
480 | 544 | ||
481 | const char * | 545 | const char * |
@@ -552,9 +616,8 @@ evas_font_name_parse(Evas_Font_Description *fdesc, const char *name) | |||
552 | } | 616 | } |
553 | 617 | ||
554 | void * | 618 | void * |
555 | evas_font_load(Evas *eo_evas, Evas_Font_Description *fdesc, const char *source, Evas_Font_Size size, Efl_Text_Font_Bitmap_Scalable bitmap_scalable) | 619 | evas_font_load(const Eina_List *font_paths, int hinting, Evas_Font_Description *fdesc, const char *source, Evas_Font_Size size, Efl_Text_Font_Bitmap_Scalable bitmap_scalable) |
556 | { | 620 | { |
557 | Evas_Public_Data *evas = efl_data_scope_get(eo_evas, EVAS_CANVAS_CLASS); | ||
558 | #ifdef HAVE_FONTCONFIG | 621 | #ifdef HAVE_FONTCONFIG |
559 | FcPattern *p_nm = NULL; | 622 | FcPattern *p_nm = NULL; |
560 | FcFontSet *set = NULL; | 623 | FcFontSet *set = NULL; |
@@ -583,32 +646,32 @@ evas_font_load(Evas *eo_evas, Evas_Font_Description *fdesc, const char *source, | |||
583 | EINA_LIST_FOREACH(fonts_cache, l, fd) | 646 | EINA_LIST_FOREACH(fonts_cache, l, fd) |
584 | { | 647 | { |
585 | if (!evas_font_desc_cmp(fdesc, fd->fdesc)) | 648 | if (!evas_font_desc_cmp(fdesc, fd->fdesc)) |
586 | { | 649 | { |
587 | if (((!source) && (!fd->source)) || | 650 | if (((!source) && (!fd->source)) || |
588 | ((source) && (fd->source) && (!strcmp(source, fd->source)))) | 651 | ((source) && (fd->source) && (!strcmp(source, fd->source)))) |
589 | { | 652 | { |
590 | if ((size == fd->size) && | 653 | if ((size == fd->size) && |
591 | (wanted_rend == fd->wanted_rend) && | 654 | (wanted_rend == fd->wanted_rend) && |
592 | (bitmap_scalable == fd->bitmap_scalable)) | 655 | (bitmap_scalable == fd->bitmap_scalable)) |
593 | { | 656 | { |
594 | fonts_cache = eina_list_promote_list(fonts_cache, l); | 657 | fonts_cache = eina_list_promote_list(fonts_cache, l); |
595 | fd->ref++; | 658 | fd->ref++; |
596 | return fd->font; | 659 | return fd->font; |
597 | } | 660 | } |
598 | #ifdef HAVE_FONTCONFIG | 661 | #ifdef HAVE_FONTCONFIG |
599 | else if (fd->set && fd->p_nm && !fd->file_font) | 662 | else if (fd->set && fd->p_nm && !fd->file_font) |
600 | { | 663 | { |
601 | found_fd = fd; | 664 | found_fd = fd; |
602 | } | 665 | } |
603 | #endif | 666 | #endif |
604 | } | 667 | } |
605 | } | 668 | } |
606 | } | 669 | } |
607 | 670 | ||
608 | #ifdef HAVE_FONTCONFIG | 671 | #ifdef HAVE_FONTCONFIG |
609 | if (found_fd) | 672 | if (found_fd) |
610 | { | 673 | { |
611 | font = _evas_load_fontconfig(font, evas->evas, found_fd->set, size, wanted_rend, bitmap_scalable); | 674 | font = _evas_load_fontconfig(font, found_fd->set, size, wanted_rend, bitmap_scalable); |
612 | goto on_find; | 675 | goto on_find; |
613 | } | 676 | } |
614 | #endif | 677 | #endif |
@@ -616,32 +679,32 @@ evas_font_load(Evas *eo_evas, Evas_Font_Description *fdesc, const char *source, | |||
616 | EINA_LIST_FOREACH_SAFE(fonts_zero, l, l_next, fd) | 679 | EINA_LIST_FOREACH_SAFE(fonts_zero, l, l_next, fd) |
617 | { | 680 | { |
618 | if (!evas_font_desc_cmp(fdesc, fd->fdesc)) | 681 | if (!evas_font_desc_cmp(fdesc, fd->fdesc)) |
619 | { | 682 | { |
620 | if (((!source) && (!fd->source)) || | 683 | if (((!source) && (!fd->source)) || |
621 | ((source) && (fd->source) && (!strcmp(source, fd->source)))) | 684 | ((source) && (fd->source) && (!strcmp(source, fd->source)))) |
622 | { | 685 | { |
623 | if ((size == fd->size) && | 686 | if ((size == fd->size) && |
624 | (wanted_rend == fd->wanted_rend)) | 687 | (wanted_rend == fd->wanted_rend)) |
625 | { | 688 | { |
626 | fonts_zero = eina_list_remove_list(fonts_zero, l); | 689 | fonts_zero = eina_list_remove_list(fonts_zero, l); |
627 | fonts_cache = eina_list_prepend(fonts_cache, fd); | 690 | fonts_cache = eina_list_prepend(fonts_cache, fd); |
628 | fd->ref++; | 691 | fd->ref++; |
629 | return fd->font; | 692 | return fd->font; |
630 | } | 693 | } |
631 | #ifdef HAVE_FONTCONFIG | 694 | #ifdef HAVE_FONTCONFIG |
632 | else if (fd->set && fd->p_nm && !fd->file_font) | 695 | else if (fd->set && fd->p_nm && !fd->file_font) |
633 | { | 696 | { |
634 | found_fd = fd; | 697 | found_fd = fd; |
635 | } | 698 | } |
636 | #endif | 699 | #endif |
637 | } | 700 | } |
638 | } | 701 | } |
639 | } | 702 | } |
640 | 703 | ||
641 | #ifdef HAVE_FONTCONFIG | 704 | #ifdef HAVE_FONTCONFIG |
642 | if (found_fd) | 705 | if (found_fd) |
643 | { | 706 | { |
644 | font = _evas_load_fontconfig(font, evas->evas, found_fd->set, size, wanted_rend, bitmap_scalable); | 707 | font = _evas_load_fontconfig(font, found_fd->set, size, wanted_rend, bitmap_scalable); |
645 | goto on_find; | 708 | goto on_find; |
646 | } | 709 | } |
647 | #endif | 710 | #endif |
@@ -649,57 +712,53 @@ evas_font_load(Evas *eo_evas, Evas_Font_Description *fdesc, const char *source, | |||
649 | fonts = evas_font_set_get(fdesc->name); | 712 | fonts = evas_font_set_get(fdesc->name); |
650 | EINA_LIST_FOREACH(fonts, l, nm) /* Load each font in append */ | 713 | EINA_LIST_FOREACH(fonts, l, nm) /* Load each font in append */ |
651 | { | 714 | { |
652 | if (l == fonts || !font) /* First iteration OR no font */ | 715 | if (l == fonts || !font) /* First iteration OR no font */ |
653 | { | 716 | { |
654 | if (source) /* Load Font from "eet" source */ | 717 | if (source) /* Load Font from "eet" source */ |
655 | { | 718 | { |
656 | Eet_File *ef; | 719 | Eet_File *ef; |
657 | char *fake_name; | 720 | char fake_name[PATH_MAX]; |
658 | 721 | ||
659 | fake_name = evas_file_path_join(source, nm); | 722 | eina_file_path_join(fake_name, PATH_MAX, source, nm); |
660 | if (fake_name) | 723 | font = (Evas_Font_Set *)evas_common_font_load(fake_name, size, wanted_rend, bitmap_scalable); |
661 | { | 724 | if (!font) /* Load from fake name failed, probably not cached */ |
662 | font = evas->engine.func->font_load(_evas_engine_context(evas), fake_name, size, wanted_rend, bitmap_scalable); | 725 | { |
663 | if (!font) /* Load from fake name failed, probably not cached */ | 726 | /* read original!!! */ |
664 | { | 727 | ef = eet_open(source, EET_FILE_MODE_READ); |
665 | /* read original!!! */ | 728 | if (ef) |
666 | ef = eet_open(source, EET_FILE_MODE_READ); | 729 | { |
667 | if (ef) | 730 | void *fdata; |
668 | { | 731 | int fsize = 0; |
669 | void *fdata; | 732 | |
670 | int fsize = 0; | 733 | fdata = eet_read(ef, nm, &fsize); |
671 | 734 | if (fdata) | |
672 | fdata = eet_read(ef, nm, &fsize); | 735 | { |
673 | if (fdata) | 736 | font = (Evas_Font_Set *)evas_common_font_memory_load(source, nm, size, fdata, fsize, wanted_rend, bitmap_scalable); |
674 | { | 737 | free(fdata); |
675 | font = evas->engine.func->font_memory_load(_evas_engine_context(evas), source, nm, size, fdata, fsize, wanted_rend, bitmap_scalable); | 738 | } |
676 | free(fdata); | 739 | eet_close(ef); |
677 | } | 740 | } |
678 | eet_close(ef); | 741 | } |
679 | } | 742 | } |
680 | } | 743 | if (!font) /* Source load failed */ |
681 | free(fake_name); | 744 | { |
682 | } | 745 | if (_file_path_is_full_path((char *)nm)) /* Try filename */ |
683 | } | 746 | font = (Evas_Font_Set *)evas_common_font_load((char *)nm, size, wanted_rend, bitmap_scalable); |
684 | if (!font) /* Source load failed */ | 747 | else /* search font path */ |
685 | { | 748 | { |
686 | if (evas_file_path_is_full_path((char *)nm)) /* Try filename */ | 749 | const Eina_List *ll; |
687 | font = evas->engine.func->font_load(_evas_engine_context(evas), (char *)nm, size, wanted_rend, bitmap_scalable); | 750 | char *dir; |
688 | else /* search font path */ | 751 | |
689 | { | 752 | EINA_LIST_FOREACH(font_paths, ll, dir) |
690 | Eina_List *ll; | 753 | { |
691 | char *dir; | 754 | const char *f_file; |
692 | 755 | ||
693 | EINA_LIST_FOREACH(evas->font_path, ll, dir) | 756 | f_file = evas_font_dir_cache_find(dir, (char *)nm); |
694 | { | 757 | if (f_file) |
695 | const char *f_file; | 758 | { |
696 | 759 | font = (Evas_Font_Set *)evas_common_font_load(f_file, size, wanted_rend, bitmap_scalable); | |
697 | f_file = evas_font_dir_cache_find(dir, (char *)nm); | 760 | if (font) break; |
698 | if (f_file) | 761 | } |
699 | { | ||
700 | font = evas->engine.func->font_load(_evas_engine_context(evas), f_file, size, wanted_rend, bitmap_scalable); | ||
701 | if (font) break; | ||
702 | } | ||
703 | } | 762 | } |
704 | 763 | ||
705 | if (!font) | 764 | if (!font) |
@@ -711,71 +770,66 @@ evas_font_load(Evas *eo_evas, Evas_Font_Description *fdesc, const char *source, | |||
711 | f_file = evas_font_dir_cache_find(dir, (char *)nm); | 770 | f_file = evas_font_dir_cache_find(dir, (char *)nm); |
712 | if (f_file) | 771 | if (f_file) |
713 | { | 772 | { |
714 | font = evas->engine.func->font_load(_evas_engine_context(evas), f_file, size, wanted_rend, bitmap_scalable); | 773 | font = (Evas_Font_Set *)evas_common_font_load(f_file, size, wanted_rend, bitmap_scalable); |
715 | if (font) break; | 774 | if (font) break; |
716 | } | 775 | } |
717 | } | 776 | } |
718 | } | 777 | } |
719 | } | 778 | } |
720 | } | 779 | } |
721 | } | 780 | } |
722 | else /* Base font loaded, append others */ | 781 | else /* Base font loaded, append others */ |
723 | { | 782 | { |
724 | void *ok = NULL; | 783 | void *ok = NULL; |
725 | 784 | ||
726 | if (source) | 785 | if (source) |
727 | { | 786 | { |
728 | Eet_File *ef; | 787 | Eet_File *ef; |
729 | char *fake_name; | 788 | char fake_name[PATH_MAX]; |
730 | 789 | ||
731 | fake_name = evas_file_path_join(source, nm); | 790 | eina_file_path_join(fake_name, PATH_MAX, source, nm); |
732 | if (fake_name) | 791 | if (!evas_common_font_add((RGBA_Font *)font, fake_name, size, wanted_rend, bitmap_scalable)) |
733 | { | 792 | { |
734 | /* FIXME: make an engine func */ | 793 | /* read original!!! */ |
735 | if (!evas->engine.func->font_add(_evas_engine_context(evas), font, fake_name, size, wanted_rend, bitmap_scalable)) | 794 | ef = eet_open(source, EET_FILE_MODE_READ); |
736 | { | 795 | if (ef) |
737 | /* read original!!! */ | 796 | { |
738 | ef = eet_open(source, EET_FILE_MODE_READ); | 797 | void *fdata; |
739 | if (ef) | 798 | int fsize = 0; |
740 | { | 799 | |
741 | void *fdata; | 800 | fdata = eet_read(ef, nm, &fsize); |
742 | int fsize = 0; | 801 | if ((fdata) && (fsize > 0)) |
743 | 802 | { | |
744 | fdata = eet_read(ef, nm, &fsize); | 803 | ok = evas_common_font_memory_add((RGBA_Font *)font, source, nm, size, fdata, fsize, wanted_rend, bitmap_scalable); |
745 | if ((fdata) && (fsize > 0)) | 804 | } |
746 | { | 805 | eet_close(ef); |
747 | ok = evas->engine.func->font_memory_add(_evas_engine_context(evas), font, source, nm, size, fdata, fsize, wanted_rend, bitmap_scalable); | 806 | free(fdata); |
748 | } | 807 | } |
749 | eet_close(ef); | 808 | } |
750 | free(fdata); | 809 | else |
751 | } | 810 | ok = (void *)1; |
752 | } | 811 | } |
753 | else | 812 | if (!ok) |
754 | ok = (void *)1; | 813 | { |
755 | free(fake_name); | 814 | if (_file_path_is_full_path((char *)nm)) |
756 | } | 815 | evas_common_font_add((RGBA_Font *)font, (char *)nm, size, wanted_rend, bitmap_scalable); |
757 | } | 816 | else |
758 | if (!ok) | 817 | { |
759 | { | 818 | const Eina_List *ll; |
760 | if (evas_file_path_is_full_path((char *)nm)) | 819 | char *dir; |
761 | evas->engine.func->font_add(_evas_engine_context(evas), font, (char *)nm, size, wanted_rend, bitmap_scalable); | 820 | RGBA_Font *fn = NULL; |
762 | else | 821 | |
763 | { | 822 | EINA_LIST_FOREACH(font_paths, ll, dir) |
764 | Eina_List *ll; | 823 | { |
765 | char *dir; | 824 | const char *f_file; |
766 | RGBA_Font *fn = NULL; | 825 | |
767 | 826 | f_file = evas_font_dir_cache_find(dir, (char *)nm); | |
768 | EINA_LIST_FOREACH(evas->font_path, ll, dir) | 827 | if (f_file) |
769 | { | 828 | { |
770 | const char *f_file; | 829 | fn = evas_common_font_add((RGBA_Font *)font, f_file, size, wanted_rend, bitmap_scalable); |
771 | 830 | if (fn) | |
772 | f_file = evas_font_dir_cache_find(dir, (char *)nm); | 831 | break; |
773 | if (f_file) | 832 | } |
774 | { | ||
775 | fn = (RGBA_Font *)evas->engine.func->font_add(_evas_engine_context(evas), font, f_file, size, wanted_rend, bitmap_scalable); | ||
776 | if (fn) | ||
777 | break; | ||
778 | } | ||
779 | } | 833 | } |
780 | 834 | ||
781 | if (!fn) | 835 | if (!fn) |
@@ -787,23 +841,23 @@ evas_font_load(Evas *eo_evas, Evas_Font_Description *fdesc, const char *source, | |||
787 | f_file = evas_font_dir_cache_find(dir, (char *)nm); | 841 | f_file = evas_font_dir_cache_find(dir, (char *)nm); |
788 | if (f_file) | 842 | if (f_file) |
789 | { | 843 | { |
790 | fn = (RGBA_Font *)evas->engine.func->font_add(_evas_engine_context(evas), font, f_file, size, wanted_rend, bitmap_scalable); | 844 | fn = evas_common_font_add((RGBA_Font *)font, f_file, size, wanted_rend, bitmap_scalable); |
791 | if (fn) | 845 | if (fn) |
792 | break; | 846 | break; |
793 | } | 847 | } |
794 | } | 848 | } |
795 | } | 849 | } |
796 | } | 850 | } |
797 | } | 851 | } |
798 | } | 852 | } |
799 | eina_stringshare_del(nm); | 853 | eina_stringshare_del(nm); |
800 | } | 854 | } |
801 | eina_list_free(fonts); | 855 | eina_list_free(fonts); |
802 | 856 | ||
803 | #ifdef HAVE_FONTCONFIG | 857 | #ifdef HAVE_FONTCONFIG |
804 | if (!font) /* Search using fontconfig */ | 858 | if (!font) /* Search using fontconfig */ |
805 | { | 859 | { |
806 | FcResult res; | 860 | FcResult res; |
807 | 861 | ||
808 | p_nm = FcPatternBuild (NULL, | 862 | p_nm = FcPatternBuild (NULL, |
809 | FC_WEIGHT, FcTypeInteger, _fc_weight_map[fdesc->weight], | 863 | FC_WEIGHT, FcTypeInteger, _fc_weight_map[fdesc->weight], |
@@ -844,26 +898,27 @@ evas_font_load(Evas *eo_evas, Evas_Font_Description *fdesc, const char *source, | |||
844 | if (fdesc->lang) | 898 | if (fdesc->lang) |
845 | FcPatternAddString (p_nm, FC_LANG, (FcChar8 *) fdesc->lang); | 899 | FcPatternAddString (p_nm, FC_LANG, (FcChar8 *) fdesc->lang); |
846 | 900 | ||
847 | FcConfigSubstitute(fc_config, p_nm, FcMatchPattern); | 901 | FcConfigSubstitute(fc_config, p_nm, FcMatchPattern); |
848 | FcDefaultSubstitute(p_nm); | 902 | FcDefaultSubstitute(p_nm); |
849 | 903 | ||
850 | /* do matching */ | 904 | /* do matching */ |
851 | set = FcFontSort(fc_config, p_nm, FcTrue, NULL, &res); | 905 | set = FcFontSort(fc_config, p_nm, FcTrue, NULL, &res); |
852 | if (!set) | 906 | if (!set) |
853 | { | 907 | { |
854 | ERR("No fontconfig font matches '%s'. It was the last resource, no font found!", fdesc->name); | 908 | //FIXME add ERR log capability |
855 | FcPatternDestroy(p_nm); | 909 | //ERR("No fontconfig font matches '%s'. It was the last resource, no font found!", fdesc->name); |
856 | p_nm = NULL; | 910 | FcPatternDestroy(p_nm); |
857 | } | 911 | p_nm = NULL; |
858 | else | 912 | } |
913 | else | ||
859 | { | 914 | { |
860 | font = _evas_load_fontconfig(font, evas->evas, set, size, wanted_rend, bitmap_scalable); | 915 | font = _evas_load_fontconfig(font, set, size, wanted_rend, bitmap_scalable); |
861 | } | 916 | } |
862 | } | 917 | } |
863 | else /* Add a fallback list from fontconfig according to the found font. */ | 918 | else /* Add a fallback list from fontconfig according to the found font. */ |
864 | { | 919 | { |
865 | #if FC_MAJOR >= 2 && FC_MINOR >= 11 | 920 | #if FC_MAJOR >= 2 && FC_MINOR >= 11 |
866 | FcResult res; | 921 | FcResult res; |
867 | 922 | ||
868 | FT_Face face = evas_common_font_freetype_face_get((RGBA_Font *) font); | 923 | FT_Face face = evas_common_font_freetype_face_get((RGBA_Font *) font); |
869 | 924 | ||
@@ -884,7 +939,7 @@ evas_font_load(Evas *eo_evas, Evas_Font_Description *fdesc, const char *source, | |||
884 | } | 939 | } |
885 | else | 940 | else |
886 | { | 941 | { |
887 | font = _evas_load_fontconfig(font, evas->evas, set, size, wanted_rend, bitmap_scalable); | 942 | font = _evas_load_fontconfig(font, set, size, wanted_rend, bitmap_scalable); |
888 | } | 943 | } |
889 | } | 944 | } |
890 | #endif | 945 | #endif |
@@ -913,24 +968,20 @@ evas_font_load(Evas *eo_evas, Evas_Font_Description *fdesc, const char *source, | |||
913 | } | 968 | } |
914 | 969 | ||
915 | if (font) | 970 | if (font) |
916 | evas->engine.func->font_hinting_set(_evas_engine_context(evas), font, | 971 | evas_common_font_hinting_set((RGBA_Font *)font, hinting); |
917 | evas->hinting); | ||
918 | return font; | 972 | return font; |
919 | } | 973 | } |
920 | 974 | ||
921 | void | 975 | void |
922 | evas_font_load_hinting_set(Evas *eo_evas, void *font, int hinting) | 976 | evas_font_load_hinting_set(void *font, int hinting) |
923 | { | 977 | { |
924 | Evas_Public_Data *evas = efl_data_scope_get(eo_evas, EVAS_CANVAS_CLASS); | 978 | evas_common_font_hinting_set((RGBA_Font *) font, hinting); |
925 | evas->engine.func->font_hinting_set(_evas_engine_context(evas), font, | ||
926 | hinting); | ||
927 | } | 979 | } |
928 | 980 | ||
929 | Eina_List * | 981 | Eina_List * |
930 | evas_font_dir_available_list(const Evas *eo_evas) | 982 | evas_font_dir_available_list(const Eina_List *font_paths) |
931 | { | 983 | { |
932 | const Evas_Public_Data *evas = efl_data_scope_get(eo_evas, EVAS_CANVAS_CLASS); | 984 | const Eina_List *l; |
933 | Eina_List *l; | ||
934 | Eina_List *ll; | 985 | Eina_List *ll; |
935 | Eina_List *available = NULL; | 986 | Eina_List *available = NULL; |
936 | char *dir; | 987 | char *dir; |
@@ -954,25 +1005,25 @@ evas_font_dir_available_list(const Evas *eo_evas) | |||
954 | 1005 | ||
955 | if (set) | 1006 | if (set) |
956 | { | 1007 | { |
957 | for (i = 0; i < set->nfont; i++) | 1008 | for (i = 0; i < set->nfont; i++) |
958 | { | 1009 | { |
959 | char *font; | 1010 | char *font; |
960 | 1011 | ||
961 | font = (char *)FcNameUnparse(set->fonts[i]); | 1012 | font = (char *)FcNameUnparse(set->fonts[i]); |
962 | available = eina_list_append(available, eina_stringshare_add(font)); | 1013 | available = eina_list_append(available, eina_stringshare_add(font)); |
963 | free(font); | 1014 | free(font); |
964 | } | 1015 | } |
965 | 1016 | ||
966 | FcFontSetDestroy(set); | 1017 | FcFontSetDestroy(set); |
967 | } | 1018 | } |
968 | #endif | 1019 | #endif |
969 | 1020 | ||
970 | /* Add fonts in evas font_path*/ | 1021 | /* Add fonts in font_paths*/ |
971 | if (evas->font_path) | 1022 | if (font_paths) |
972 | { | 1023 | { |
973 | if (!font_dirs) font_dirs = eina_hash_string_superfast_new(NULL); | 1024 | if (!font_dirs) font_dirs = eina_hash_string_superfast_new(NULL); |
974 | 1025 | ||
975 | EINA_LIST_FOREACH(evas->font_path, l, dir) | 1026 | EINA_LIST_FOREACH(font_paths, l, dir) |
976 | { | 1027 | { |
977 | Evas_Font_Dir *fd; | 1028 | Evas_Font_Dir *fd; |
978 | 1029 | ||
@@ -1016,8 +1067,8 @@ evas_font_dir_available_list_free(Eina_List *available) | |||
1016 | { | 1067 | { |
1017 | while (available) | 1068 | while (available) |
1018 | { | 1069 | { |
1019 | eina_stringshare_del(available->data); | 1070 | eina_stringshare_del(available->data); |
1020 | available = eina_list_remove(available, available->data); | 1071 | available = eina_list_remove(available, available->data); |
1021 | } | 1072 | } |
1022 | } | 1073 | } |
1023 | 1074 | ||
@@ -1032,47 +1083,39 @@ font_cache_dir_free(const Eina_Hash *hash EINA_UNUSED, const void *key, void *da | |||
1032 | static Evas_Font_Dir * | 1083 | static Evas_Font_Dir * |
1033 | object_text_font_cache_dir_update(char *dir, Evas_Font_Dir *fd) | 1084 | object_text_font_cache_dir_update(char *dir, Evas_Font_Dir *fd) |
1034 | { | 1085 | { |
1086 | char file_path[PATH_MAX]; | ||
1035 | DATA64 mt; | 1087 | DATA64 mt; |
1036 | char *tmp; | ||
1037 | 1088 | ||
1038 | if (fd) | 1089 | if (fd) |
1039 | { | 1090 | { |
1040 | mt = evas_file_modified_time(dir); | 1091 | mt = _file_modified_time(dir); |
1041 | if (mt != fd->dir_mod_time) | 1092 | if (mt != fd->dir_mod_time) |
1042 | { | 1093 | { |
1043 | eina_hash_del(font_dirs, dir, fd); | 1094 | eina_hash_del(font_dirs, dir, fd); |
1044 | object_text_font_cache_dir_del(dir, fd); | 1095 | object_text_font_cache_dir_del(dir, fd); |
1045 | } | 1096 | } |
1046 | else | 1097 | else |
1047 | { | 1098 | { |
1048 | tmp = evas_file_path_join(dir, "fonts.dir"); | 1099 | eina_file_path_join(file_path, PATH_MAX, dir, "fonts.dir"); |
1049 | if (tmp) | 1100 | mt = _file_modified_time(file_path); |
1050 | { | 1101 | if (mt != fd->fonts_dir_mod_time) |
1051 | mt = evas_file_modified_time(tmp); | 1102 | { |
1052 | free(tmp); | 1103 | eina_hash_del(font_dirs, dir, fd); |
1053 | if (mt != fd->fonts_dir_mod_time) | 1104 | object_text_font_cache_dir_del(dir, fd); |
1054 | { | 1105 | } |
1055 | eina_hash_del(font_dirs, dir, fd); | 1106 | else |
1056 | object_text_font_cache_dir_del(dir, fd); | 1107 | { |
1057 | } | 1108 | eina_file_path_join(file_path, PATH_MAX, dir, "fonts.alias"); |
1058 | else | 1109 | mt = _file_modified_time(file_path); |
1059 | { | 1110 | if (mt != fd->fonts_alias_mod_time) |
1060 | tmp = evas_file_path_join(dir, "fonts.alias"); | 1111 | { |
1061 | if (tmp) | 1112 | eina_hash_del(font_dirs, dir, fd); |
1062 | { | 1113 | object_text_font_cache_dir_del(dir, fd); |
1063 | mt = evas_file_modified_time(tmp); | 1114 | } |
1064 | free(tmp); | 1115 | else |
1065 | } | 1116 | return fd; |
1066 | if (mt != fd->fonts_alias_mod_time) | 1117 | } |
1067 | { | 1118 | } |
1068 | eina_hash_del(font_dirs, dir, fd); | ||
1069 | object_text_font_cache_dir_del(dir, fd); | ||
1070 | } | ||
1071 | else | ||
1072 | return fd; | ||
1073 | } | ||
1074 | } | ||
1075 | } | ||
1076 | } | 1119 | } |
1077 | return object_text_font_cache_dir_add(dir); | 1120 | return object_text_font_cache_dir_add(dir); |
1078 | } | 1121 | } |
@@ -1089,23 +1132,23 @@ object_text_font_cache_font_find_x(Evas_Font_Dir *fd, char *font) | |||
1089 | if (num != 14) return NULL; | 1132 | if (num != 14) return NULL; |
1090 | EINA_LIST_FOREACH(fd->fonts, l, fn) | 1133 | EINA_LIST_FOREACH(fd->fonts, l, fn) |
1091 | { | 1134 | { |
1092 | if (fn->type == 1) | 1135 | if (fn->type == 1) |
1093 | { | 1136 | { |
1094 | int i; | 1137 | int i; |
1095 | int match = 0; | 1138 | int match = 0; |
1096 | 1139 | ||
1097 | for (i = 0; i < 14; i++) | 1140 | for (i = 0; i < 14; i++) |
1098 | { | 1141 | { |
1099 | if ((font_prop[i][0] == '*') && (font_prop[i][1] == 0)) | 1142 | if ((font_prop[i][0] == '*') && (font_prop[i][1] == 0)) |
1100 | match++; | 1143 | match++; |
1101 | else | 1144 | else |
1102 | { | 1145 | { |
1103 | if (!strcasecmp(font_prop[i], fn->x.prop[i])) match++; | 1146 | if (!strcasecmp(font_prop[i], fn->x.prop[i])) match++; |
1104 | else break; | 1147 | else break; |
1105 | } | 1148 | } |
1106 | } | 1149 | } |
1107 | if (match == 14) return fn; | 1150 | if (match == 14) return fn; |
1108 | } | 1151 | } |
1109 | } | 1152 | } |
1110 | return NULL; | 1153 | return NULL; |
1111 | } | 1154 | } |
@@ -1118,10 +1161,10 @@ object_text_font_cache_font_find_file(Evas_Font_Dir *fd, char *font) | |||
1118 | 1161 | ||
1119 | EINA_LIST_FOREACH(fd->fonts, l, fn) | 1162 | EINA_LIST_FOREACH(fd->fonts, l, fn) |
1120 | { | 1163 | { |
1121 | if (fn->type == 0) | 1164 | if (fn->type == 0) |
1122 | { | 1165 | { |
1123 | if (!strcasecmp(font, fn->simple.name)) return fn; | 1166 | if (!strcasecmp(font, fn->simple.name)) return fn; |
1124 | } | 1167 | } |
1125 | } | 1168 | } |
1126 | return NULL; | 1169 | return NULL; |
1127 | } | 1170 | } |
@@ -1155,10 +1198,13 @@ object_text_font_cache_font_find(Evas_Font_Dir *fd, char *font) | |||
1155 | static Evas_Font_Dir * | 1198 | static Evas_Font_Dir * |
1156 | object_text_font_cache_dir_add(char *dir) | 1199 | object_text_font_cache_dir_add(char *dir) |
1157 | { | 1200 | { |
1201 | char file_path[PATH_MAX]; | ||
1158 | Evas_Font_Dir *fd; | 1202 | Evas_Font_Dir *fd; |
1159 | char *tmp, *tmp2, *file; | 1203 | char *file; |
1204 | char tmp2[PATH_MAX]; | ||
1160 | Eina_List *fdir; | 1205 | Eina_List *fdir; |
1161 | Evas_Font *fn; | 1206 | Evas_Font *fn; |
1207 | FILE *f; | ||
1162 | 1208 | ||
1163 | fd = calloc(1, sizeof(Evas_Font_Dir)); | 1209 | fd = calloc(1, sizeof(Evas_Font_Dir)); |
1164 | if (!fd) return NULL; | 1210 | if (!fd) return NULL; |
@@ -1169,134 +1215,105 @@ object_text_font_cache_dir_add(char *dir) | |||
1169 | /* READ fonts.alias, fonts.dir and directory listing */ | 1215 | /* READ fonts.alias, fonts.dir and directory listing */ |
1170 | 1216 | ||
1171 | /* fonts.dir */ | 1217 | /* fonts.dir */ |
1172 | tmp = evas_file_path_join(dir, "fonts.dir"); | 1218 | eina_file_path_join(file_path, PATH_MAX, dir, "fonts.dir"); |
1173 | if (tmp) | 1219 | |
1220 | f = fopen(file_path, "rb"); | ||
1221 | if (f) | ||
1174 | { | 1222 | { |
1175 | FILE *f; | 1223 | int num; |
1176 | 1224 | char fname[4096], fdef[4096]; | |
1177 | f = fopen(tmp, "rb"); | 1225 | |
1178 | if (f) | 1226 | if (fscanf(f, "%i\n", &num) != 1) goto cant_read; |
1179 | { | 1227 | /* read font lines */ |
1180 | int num; | 1228 | while (fscanf(f, "%4090s %[^\n]\n", fname, fdef) == 2) |
1181 | char fname[4096], fdef[4096]; | 1229 | { |
1182 | 1230 | char font_prop[14][256]; | |
1183 | if (fscanf(f, "%i\n", &num) != 1) goto cant_read; | 1231 | int i; |
1184 | /* read font lines */ | 1232 | |
1185 | while (fscanf(f, "%4090s %[^\n]\n", fname, fdef) == 2) | 1233 | /* skip comments */ |
1186 | { | 1234 | if ((fdef[0] == '!') || (fdef[0] == '#')) continue; |
1187 | char font_prop[14][256]; | 1235 | /* parse font def */ |
1188 | int i; | 1236 | num = evas_object_text_font_string_parse((char *)fdef, font_prop); |
1189 | 1237 | if (num == 14) | |
1190 | /* skip comments */ | 1238 | { |
1191 | if ((fdef[0] == '!') || (fdef[0] == '#')) continue; | 1239 | fn = calloc(1, sizeof(Evas_Font)); |
1192 | /* parse font def */ | 1240 | if (fn) |
1193 | num = evas_object_text_font_string_parse((char *)fdef, font_prop); | 1241 | { |
1194 | if (num == 14) | 1242 | fn->type = 1; |
1195 | { | 1243 | for (i = 0; i < 14; i++) |
1196 | fn = calloc(1, sizeof(Evas_Font)); | 1244 | fn->x.prop[i] = eina_stringshare_add(font_prop[i]); |
1197 | if (fn) | 1245 | eina_file_path_join(tmp2, PATH_MAX, dir, fname); |
1198 | { | 1246 | fn->path = eina_stringshare_add(tmp2); |
1199 | fn->type = 1; | 1247 | fd->fonts = eina_list_append(fd->fonts, fn); |
1200 | for (i = 0; i < 14; i++) | 1248 | } |
1201 | fn->x.prop[i] = eina_stringshare_add(font_prop[i]); | 1249 | } |
1202 | tmp2 = evas_file_path_join(dir, fname); | 1250 | } |
1203 | if (tmp2) | 1251 | cant_read: ; |
1204 | { | 1252 | fclose(f); |
1205 | fn->path = eina_stringshare_add(tmp2); | ||
1206 | free(tmp2); | ||
1207 | } | ||
1208 | fd->fonts = eina_list_append(fd->fonts, fn); | ||
1209 | } | ||
1210 | } | ||
1211 | } | ||
1212 | cant_read: ; | ||
1213 | fclose(f); | ||
1214 | } | ||
1215 | free(tmp); | ||
1216 | } | 1253 | } |
1217 | 1254 | ||
1218 | /* directoy listing */ | 1255 | /* directoy listing */ |
1219 | fdir = evas_file_path_list(dir, "*.ttf", 0); | 1256 | fdir = _file_path_list(dir, "*.ttf", 0); |
1220 | EINA_LIST_FREE(fdir, file) | 1257 | EINA_LIST_FREE(fdir, file) |
1221 | { | 1258 | { |
1222 | tmp = evas_file_path_join(dir, file); | 1259 | eina_file_path_join(file_path, PATH_MAX, dir, file); |
1223 | if (tmp) | 1260 | fn = calloc(1, sizeof(Evas_Font)); |
1224 | { | 1261 | if (fn) |
1225 | fn = calloc(1, sizeof(Evas_Font)); | 1262 | { |
1226 | if (fn) | 1263 | char *p; |
1227 | { | 1264 | |
1228 | char *p; | 1265 | fn->type = 0; |
1229 | 1266 | strcpy(tmp2, file); | |
1230 | fn->type = 0; | 1267 | p = strrchr(tmp2, '.'); |
1231 | tmp2 = alloca(strlen(file) + 1); | 1268 | if (p) *p = 0; |
1232 | strcpy(tmp2, file); | 1269 | fn->simple.name = eina_stringshare_add(tmp2); |
1233 | p = strrchr(tmp2, '.'); | 1270 | eina_file_path_join(tmp2, PATH_MAX, dir, file); |
1234 | if (p) *p = 0; | 1271 | fn->path = eina_stringshare_add(tmp2); |
1235 | fn->simple.name = eina_stringshare_add(tmp2); | 1272 | fd->fonts = eina_list_append(fd->fonts, fn); |
1236 | tmp2 = evas_file_path_join(dir, file); | 1273 | } |
1237 | if (tmp2) | 1274 | free(file); |
1238 | { | ||
1239 | fn->path = eina_stringshare_add(tmp2); | ||
1240 | free(tmp2); | ||
1241 | } | ||
1242 | fd->fonts = eina_list_append(fd->fonts, fn); | ||
1243 | } | ||
1244 | free(tmp); | ||
1245 | } | ||
1246 | free(file); | ||
1247 | } | 1275 | } |
1248 | 1276 | ||
1249 | /* fonts.alias */ | 1277 | /* fonts.alias */ |
1250 | tmp = evas_file_path_join(dir, "fonts.alias"); | 1278 | eina_file_path_join(file_path, PATH_MAX, dir, "fonts.alias"); |
1251 | if (tmp) | ||
1252 | { | ||
1253 | FILE *f; | ||
1254 | |||
1255 | f = fopen(tmp, "rb"); | ||
1256 | if (f) | ||
1257 | { | ||
1258 | char fname[4096], fdef[4096]; | ||
1259 | |||
1260 | /* read font alias lines */ | ||
1261 | while (fscanf(f, "%4090s %4090[^\n]\n", fname, fdef) == 2) | ||
1262 | { | ||
1263 | Evas_Font_Alias *fa; | ||
1264 | |||
1265 | /* skip comments */ | ||
1266 | if ((fname[0] == '!') || (fname[0] == '#')) continue; | ||
1267 | fa = calloc(1, sizeof(Evas_Font_Alias)); | ||
1268 | if (fa) | ||
1269 | { | ||
1270 | fa->alias = eina_stringshare_add(fname); | ||
1271 | fa->fn = object_text_font_cache_font_find_x(fd, fdef); | ||
1272 | if ((!fa->alias) || (!fa->fn)) | ||
1273 | { | ||
1274 | if (fa->alias) eina_stringshare_del(fa->alias); | ||
1275 | free(fa); | ||
1276 | } | ||
1277 | else | ||
1278 | fd->aliases = eina_list_append(fd->aliases, fa); | ||
1279 | } | ||
1280 | } | ||
1281 | fclose(f); | ||
1282 | } | ||
1283 | free(tmp); | ||
1284 | } | ||
1285 | 1279 | ||
1286 | fd->dir_mod_time = evas_file_modified_time(dir); | 1280 | f = fopen(file_path, "rb"); |
1287 | tmp = evas_file_path_join(dir, "fonts.dir"); | 1281 | if (f) |
1288 | if (tmp) | ||
1289 | { | 1282 | { |
1290 | fd->fonts_dir_mod_time = evas_file_modified_time(tmp); | 1283 | char fname[4096], fdef[4096]; |
1291 | free(tmp); | 1284 | |
1292 | } | 1285 | /* read font alias lines */ |
1293 | tmp = evas_file_path_join(dir, "fonts.alias"); | 1286 | while (fscanf(f, "%4090s %4090[^\n]\n", fname, fdef) == 2) |
1294 | if (tmp) | 1287 | { |
1295 | { | 1288 | Evas_Font_Alias *fa; |
1296 | fd->fonts_alias_mod_time = evas_file_modified_time(tmp); | 1289 | |
1297 | free(tmp); | 1290 | /* skip comments */ |
1291 | if ((fname[0] == '!') || (fname[0] == '#')) continue; | ||
1292 | fa = calloc(1, sizeof(Evas_Font_Alias)); | ||
1293 | if (fa) | ||
1294 | { | ||
1295 | fa->alias = eina_stringshare_add(fname); | ||
1296 | fa->fn = object_text_font_cache_font_find_x(fd, fdef); | ||
1297 | if ((!fa->alias) || (!fa->fn)) | ||
1298 | { | ||
1299 | if (fa->alias) eina_stringshare_del(fa->alias); | ||
1300 | free(fa); | ||
1301 | } | ||
1302 | else | ||
1303 | fd->aliases = eina_list_append(fd->aliases, fa); | ||
1304 | } | ||
1305 | } | ||
1306 | fclose(f); | ||
1298 | } | 1307 | } |
1299 | 1308 | ||
1309 | fd->dir_mod_time = _file_modified_time(dir); | ||
1310 | |||
1311 | eina_file_path_join(file_path, PATH_MAX, dir, "fonts.dir"); | ||
1312 | fd->fonts_dir_mod_time = _file_modified_time(file_path); | ||
1313 | |||
1314 | eina_file_path_join(file_path, PATH_MAX, dir, "fonts.alias"); | ||
1315 | fd->fonts_alias_mod_time = _file_modified_time(file_path); | ||
1316 | |||
1300 | return fd; | 1317 | return fd; |
1301 | } | 1318 | } |
1302 | 1319 | ||
@@ -1306,27 +1323,27 @@ object_text_font_cache_dir_del(char *dir EINA_UNUSED, Evas_Font_Dir *fd) | |||
1306 | if (fd->lookup) eina_hash_free(fd->lookup); | 1323 | if (fd->lookup) eina_hash_free(fd->lookup); |
1307 | while (fd->fonts) | 1324 | while (fd->fonts) |
1308 | { | 1325 | { |
1309 | Evas_Font *fn; | 1326 | Evas_Font *fn; |
1310 | int i; | 1327 | int i; |
1311 | 1328 | ||
1312 | fn = fd->fonts->data; | 1329 | fn = fd->fonts->data; |
1313 | fd->fonts = eina_list_remove(fd->fonts, fn); | 1330 | fd->fonts = eina_list_remove(fd->fonts, fn); |
1314 | for (i = 0; i < 14; i++) | 1331 | for (i = 0; i < 14; i++) |
1315 | { | 1332 | { |
1316 | if (fn->x.prop[i]) eina_stringshare_del(fn->x.prop[i]); | 1333 | if (fn->x.prop[i]) eina_stringshare_del(fn->x.prop[i]); |
1317 | } | 1334 | } |
1318 | if (fn->simple.name) eina_stringshare_del(fn->simple.name); | 1335 | if (fn->simple.name) eina_stringshare_del(fn->simple.name); |
1319 | if (fn->path) eina_stringshare_del(fn->path); | 1336 | if (fn->path) eina_stringshare_del(fn->path); |
1320 | free(fn); | 1337 | free(fn); |
1321 | } | 1338 | } |
1322 | while (fd->aliases) | 1339 | while (fd->aliases) |
1323 | { | 1340 | { |
1324 | Evas_Font_Alias *fa; | 1341 | Evas_Font_Alias *fa; |
1325 | 1342 | ||
1326 | fa = fd->aliases->data; | 1343 | fa = fd->aliases->data; |
1327 | fd->aliases = eina_list_remove(fd->aliases, fa); | 1344 | fd->aliases = eina_list_remove(fd->aliases, fa); |
1328 | if (fa->alias) eina_stringshare_del(fa->alias); | 1345 | if (fa->alias) eina_stringshare_del(fa->alias); |
1329 | free(fa); | 1346 | free(fa); |
1330 | } | 1347 | } |
1331 | free(fd); | 1348 | free(fd); |
1332 | } | 1349 | } |
@@ -1344,59 +1361,22 @@ evas_object_text_font_string_parse(char *buffer, char dest[14][256]) | |||
1344 | i = 1; | 1361 | i = 1; |
1345 | while (p[i]) | 1362 | while (p[i]) |
1346 | { | 1363 | { |
1347 | dest[n][m] = p[i]; | 1364 | dest[n][m] = p[i]; |
1348 | if ((p[i] == '-') || (m == 255)) | 1365 | if ((p[i] == '-') || (m == 255)) |
1349 | { | 1366 | { |
1350 | dest[n][m] = 0; | 1367 | dest[n][m] = 0; |
1351 | n++; | 1368 | n++; |
1352 | m = -1; | 1369 | m = -1; |
1353 | } | 1370 | } |
1354 | i++; | 1371 | i++; |
1355 | m++; | 1372 | m++; |
1356 | if (n == 14) return n; | 1373 | if (n == 14) return n; |
1357 | } | 1374 | } |
1358 | dest[n][m] = 0; | 1375 | dest[n][m] = 0; |
1359 | n++; | 1376 | n++; |
1360 | return n; | 1377 | return n; |
1361 | } | 1378 | } |
1362 | 1379 | ||
1363 | EOLIAN void | ||
1364 | _evas_canvas_font_path_clear(Eo *eo_e EINA_UNUSED, Evas_Public_Data *evas) | ||
1365 | { | ||
1366 | evas_canvas_async_block(evas); | ||
1367 | while (evas->font_path) | ||
1368 | { | ||
1369 | eina_stringshare_del(evas->font_path->data); | ||
1370 | evas->font_path = eina_list_remove(evas->font_path, evas->font_path->data); | ||
1371 | } | ||
1372 | } | ||
1373 | |||
1374 | EOLIAN void | ||
1375 | _evas_canvas_font_path_append(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e, const char *path) | ||
1376 | { | ||
1377 | if (!path) return; | ||
1378 | evas_canvas_async_block(e); | ||
1379 | e->font_path = eina_list_append(e->font_path, eina_stringshare_add(path)); | ||
1380 | |||
1381 | evas_font_init(); | ||
1382 | } | ||
1383 | |||
1384 | EOLIAN void | ||
1385 | _evas_canvas_font_path_prepend(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e, const char *path) | ||
1386 | { | ||
1387 | if (!path) return; | ||
1388 | evas_canvas_async_block(e); | ||
1389 | e->font_path = eina_list_prepend(e->font_path, eina_stringshare_add(path)); | ||
1390 | |||
1391 | evas_font_init(); | ||
1392 | } | ||
1393 | |||
1394 | EOLIAN const Eina_List* | ||
1395 | _evas_canvas_font_path_list(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e) | ||
1396 | { | ||
1397 | return e->font_path; | ||
1398 | } | ||
1399 | |||
1400 | EAPI void | 1380 | EAPI void |
1401 | evas_font_path_global_append(const char *path) | 1381 | evas_font_path_global_append(const char *path) |
1402 | { | 1382 | { |
@@ -1439,103 +1419,6 @@ evas_font_path_global_list(void) | |||
1439 | return global_font_path; | 1419 | return global_font_path; |
1440 | } | 1420 | } |
1441 | 1421 | ||
1442 | void | ||
1443 | evas_font_object_rehint(Evas_Object *eo_obj) | ||
1444 | { | ||
1445 | Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS); | ||
1446 | if (obj->is_smart) | ||
1447 | { | ||
1448 | EINA_INLIST_FOREACH(evas_object_smart_members_get_direct(eo_obj), obj) | ||
1449 | evas_font_object_rehint(obj->object); | ||
1450 | } | ||
1451 | else | ||
1452 | { | ||
1453 | if (!strcmp(obj->type, "text")) | ||
1454 | _evas_object_text_rehint(eo_obj); | ||
1455 | if (!strcmp(obj->type, "textblock")) | ||
1456 | _evas_object_textblock_rehint(eo_obj); | ||
1457 | } | ||
1458 | } | ||
1459 | |||
1460 | EAPI void | ||
1461 | evas_font_hinting_set(Eo *eo_e, Evas_Font_Hinting_Flags hinting) | ||
1462 | { | ||
1463 | Evas_Layer *lay; | ||
1464 | |||
1465 | EVAS_LEGACY_API(eo_e, e); | ||
1466 | evas_canvas_async_block(e); | ||
1467 | if (e->hinting == hinting) return; | ||
1468 | e->hinting = hinting; | ||
1469 | |||
1470 | EINA_INLIST_FOREACH(e->layers, lay) | ||
1471 | { | ||
1472 | Evas_Object_Protected_Data *obj; | ||
1473 | |||
1474 | EINA_INLIST_FOREACH(lay->objects, obj) | ||
1475 | evas_font_object_rehint(obj->object); | ||
1476 | } | ||
1477 | } | ||
1478 | |||
1479 | EAPI Evas_Font_Hinting_Flags | ||
1480 | evas_font_hinting_get(const Evas *eo_e) | ||
1481 | { | ||
1482 | EVAS_LEGACY_API(eo_e, e, EVAS_FONT_HINTING_NONE); | ||
1483 | return e->hinting; | ||
1484 | } | ||
1485 | |||
1486 | EAPI Eina_Bool | ||
1487 | evas_font_hinting_can_hint(const Evas *eo_e, Evas_Font_Hinting_Flags hinting) | ||
1488 | { | ||
1489 | EVAS_LEGACY_API(eo_e, e, EINA_FALSE); | ||
1490 | if (e->engine.func->font_hinting_can_hint && _evas_engine_context(e)) | ||
1491 | return e->engine.func->font_hinting_can_hint(_evas_engine_context(e), | ||
1492 | hinting); | ||
1493 | else return EINA_FALSE; | ||
1494 | } | ||
1495 | |||
1496 | EOLIAN void | ||
1497 | _evas_canvas_font_cache_flush(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e) | ||
1498 | { | ||
1499 | evas_canvas_async_block(e); | ||
1500 | evas_render_rendering_wait(e); | ||
1501 | if (_evas_engine_context(e)) | ||
1502 | e->engine.func->font_cache_flush(_evas_engine_context(e)); | ||
1503 | } | ||
1504 | |||
1505 | EOLIAN void | ||
1506 | _evas_canvas_font_cache_set(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e, int size) | ||
1507 | { | ||
1508 | if (size < 0) size = 0; | ||
1509 | evas_canvas_async_block(e); | ||
1510 | evas_render_rendering_wait(e); | ||
1511 | if (_evas_engine_context(e)) | ||
1512 | e->engine.func->font_cache_set(_evas_engine_context(e), size); | ||
1513 | } | ||
1514 | |||
1515 | EOLIAN int | ||
1516 | _evas_canvas_font_cache_get(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e) | ||
1517 | { | ||
1518 | if (_evas_engine_context(e)) | ||
1519 | return e->engine.func->font_cache_get(_evas_engine_context(e)); | ||
1520 | return -1; | ||
1521 | } | ||
1522 | |||
1523 | EOLIAN Eina_List* | ||
1524 | _evas_canvas_font_available_list(Eo *eo_e, Evas_Public_Data *_pd EINA_UNUSED) | ||
1525 | { | ||
1526 | return evas_font_dir_available_list(eo_e); | ||
1527 | } | ||
1528 | |||
1529 | EAPI void | ||
1530 | evas_font_available_list_free(Evas *eo_e, Eina_List *available) | ||
1531 | { | ||
1532 | MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS); | ||
1533 | return; | ||
1534 | MAGIC_CHECK_END(); | ||
1535 | |||
1536 | evas_font_dir_available_list_free(available); | ||
1537 | } | ||
1538 | |||
1539 | EAPI void | 1422 | EAPI void |
1540 | evas_font_reinit(void) | 1423 | evas_font_reinit(void) |
1541 | { | 1424 | { |
diff --git a/src/lib/evas/canvas/evas_main.c b/src/lib/evas/canvas/evas_main.c index 04c6cb06a7..f6480e41aa 100644 --- a/src/lib/evas/canvas/evas_main.c +++ b/src/lib/evas/canvas/evas_main.c | |||
@@ -384,7 +384,7 @@ next_zombie: | |||
384 | EINA_LIST_FREE(e->obscures, r) | 384 | EINA_LIST_FREE(e->obscures, r) |
385 | eina_rectangle_free(r); | 385 | eina_rectangle_free(r); |
386 | 386 | ||
387 | evas_fonts_zero_free(eo_e); | 387 | evas_fonts_zero_free(); |
388 | 388 | ||
389 | evas_event_callback_all_del(eo_e); | 389 | evas_event_callback_all_del(eo_e); |
390 | evas_event_callback_cleanup(eo_e); | 390 | evas_event_callback_cleanup(eo_e); |
@@ -1289,6 +1289,139 @@ _evas_pointer_list_in_rect_get(Evas_Public_Data *edata, Evas_Object *obj, | |||
1289 | return list; | 1289 | return list; |
1290 | } | 1290 | } |
1291 | 1291 | ||
1292 | /* font related api */ | ||
1293 | |||
1294 | EOLIAN static void | ||
1295 | _evas_canvas_font_path_clear(Eo *eo_e EINA_UNUSED, Evas_Public_Data *evas) | ||
1296 | { | ||
1297 | evas_canvas_async_block(evas); | ||
1298 | while (evas->font_path) | ||
1299 | { | ||
1300 | eina_stringshare_del(evas->font_path->data); | ||
1301 | evas->font_path = eina_list_remove(evas->font_path, evas->font_path->data); | ||
1302 | } | ||
1303 | } | ||
1304 | |||
1305 | EOLIAN static void | ||
1306 | _evas_canvas_font_path_append(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e, const char *path) | ||
1307 | { | ||
1308 | if (!path) return; | ||
1309 | evas_canvas_async_block(e); | ||
1310 | e->font_path = eina_list_append(e->font_path, eina_stringshare_add(path)); | ||
1311 | } | ||
1312 | |||
1313 | EOLIAN static void | ||
1314 | _evas_canvas_font_path_prepend(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e, const char *path) | ||
1315 | { | ||
1316 | if (!path) return; | ||
1317 | evas_canvas_async_block(e); | ||
1318 | e->font_path = eina_list_prepend(e->font_path, eina_stringshare_add(path)); | ||
1319 | } | ||
1320 | |||
1321 | EOLIAN static const Eina_List* | ||
1322 | _evas_canvas_font_path_list(const Eo *eo_e EINA_UNUSED, Evas_Public_Data *e) | ||
1323 | { | ||
1324 | return e->font_path; | ||
1325 | } | ||
1326 | |||
1327 | EOLIAN static void | ||
1328 | _evas_canvas_font_cache_flush(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e) | ||
1329 | { | ||
1330 | evas_canvas_async_block(e); | ||
1331 | evas_render_rendering_wait(e); | ||
1332 | if (_evas_engine_context(e)) | ||
1333 | e->engine.func->font_cache_flush(_evas_engine_context(e)); | ||
1334 | } | ||
1335 | |||
1336 | EOLIAN static void | ||
1337 | _evas_canvas_font_cache_set(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e, int size) | ||
1338 | { | ||
1339 | if (size < 0) size = 0; | ||
1340 | evas_canvas_async_block(e); | ||
1341 | evas_render_rendering_wait(e); | ||
1342 | if (_evas_engine_context(e)) | ||
1343 | e->engine.func->font_cache_set(_evas_engine_context(e), size); | ||
1344 | } | ||
1345 | |||
1346 | EOLIAN static int | ||
1347 | _evas_canvas_font_cache_get(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e) | ||
1348 | { | ||
1349 | if (_evas_engine_context(e)) | ||
1350 | return e->engine.func->font_cache_get(_evas_engine_context(e)); | ||
1351 | return -1; | ||
1352 | } | ||
1353 | |||
1354 | EOLIAN static Eina_List* | ||
1355 | _evas_canvas_font_available_list(const Eo *eo_e EINA_UNUSED, Evas_Public_Data *pd) | ||
1356 | { | ||
1357 | return evas_font_dir_available_list(pd->font_path); | ||
1358 | } | ||
1359 | |||
1360 | static void | ||
1361 | evas_font_object_rehint(Evas_Object *eo_obj) | ||
1362 | { | ||
1363 | Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS); | ||
1364 | if (obj->is_smart) | ||
1365 | { | ||
1366 | EINA_INLIST_FOREACH(evas_object_smart_members_get_direct(eo_obj), obj) | ||
1367 | evas_font_object_rehint(obj->object); | ||
1368 | } | ||
1369 | else | ||
1370 | { | ||
1371 | if (!strcmp(obj->type, "text")) | ||
1372 | _evas_object_text_rehint(eo_obj); | ||
1373 | if (!strcmp(obj->type, "textblock")) | ||
1374 | _evas_object_textblock_rehint(eo_obj); | ||
1375 | } | ||
1376 | } | ||
1377 | |||
1378 | EAPI void | ||
1379 | evas_font_hinting_set(Eo *eo_e, Evas_Font_Hinting_Flags hinting) | ||
1380 | { | ||
1381 | Evas_Layer *lay; | ||
1382 | |||
1383 | EVAS_LEGACY_API(eo_e, e); | ||
1384 | evas_canvas_async_block(e); | ||
1385 | if (e->hinting == hinting) return; | ||
1386 | e->hinting = hinting; | ||
1387 | |||
1388 | EINA_INLIST_FOREACH(e->layers, lay) | ||
1389 | { | ||
1390 | Evas_Object_Protected_Data *obj; | ||
1391 | |||
1392 | EINA_INLIST_FOREACH(lay->objects, obj) | ||
1393 | evas_font_object_rehint(obj->object); | ||
1394 | } | ||
1395 | } | ||
1396 | |||
1397 | EAPI Evas_Font_Hinting_Flags | ||
1398 | evas_font_hinting_get(const Evas *eo_e) | ||
1399 | { | ||
1400 | EVAS_LEGACY_API(eo_e, e, EVAS_FONT_HINTING_NONE); | ||
1401 | return e->hinting; | ||
1402 | } | ||
1403 | |||
1404 | EAPI Eina_Bool | ||
1405 | evas_font_hinting_can_hint(const Evas *eo_e, Evas_Font_Hinting_Flags hinting) | ||
1406 | { | ||
1407 | EVAS_LEGACY_API(eo_e, e, EINA_FALSE); | ||
1408 | if (e->engine.func->font_hinting_can_hint && _evas_engine_context(e)) | ||
1409 | return e->engine.func->font_hinting_can_hint(_evas_engine_context(e), | ||
1410 | hinting); | ||
1411 | else return EINA_FALSE; | ||
1412 | } | ||
1413 | |||
1414 | EAPI void | ||
1415 | evas_font_available_list_free(Evas *eo_e, Eina_List *available) | ||
1416 | { | ||
1417 | MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS); | ||
1418 | return; | ||
1419 | MAGIC_CHECK_END(); | ||
1420 | |||
1421 | evas_font_dir_available_list_free(available); | ||
1422 | } | ||
1423 | |||
1424 | |||
1292 | /* Legacy EAPI */ | 1425 | /* Legacy EAPI */ |
1293 | 1426 | ||
1294 | EAPI Eina_Bool | 1427 | EAPI Eina_Bool |
diff --git a/src/lib/evas/canvas/evas_object_text.c b/src/lib/evas/canvas/evas_object_text.c index 5cd0da45ce..47f37ff81c 100644 --- a/src/lib/evas/canvas/evas_object_text.c +++ b/src/lib/evas/canvas/evas_object_text.c | |||
@@ -439,12 +439,15 @@ _evas_text_font_reload(Eo *eo_obj, Evas_Text_Data *o) | |||
439 | /* DO IT */ | 439 | /* DO IT */ |
440 | if (o->font) | 440 | if (o->font) |
441 | { | 441 | { |
442 | evas_font_free(obj->layer->evas->evas, o->font); | 442 | evas_font_free(o->font); |
443 | o->font = NULL; | 443 | o->font = NULL; |
444 | } | 444 | } |
445 | 445 | ||
446 | o->font = evas_font_load(obj->layer->evas->evas, o->cur.fdesc, o->cur.source, | 446 | o->font = evas_font_load(obj->layer->evas->font_path, |
447 | (int)(((double) o->cur.size) * obj->cur->scale), o->cur.bitmap_scalable); | 447 | obj->layer->evas->hinting, |
448 | o->cur.fdesc, o->cur.source, | ||
449 | (int)(((double) o->cur.size) * obj->cur->scale), | ||
450 | o->cur.bitmap_scalable); | ||
448 | { | 451 | { |
449 | o->ascent = 0; | 452 | o->ascent = 0; |
450 | o->descent = 0; | 453 | o->descent = 0; |
@@ -1657,7 +1660,7 @@ evas_object_text_free(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj) | |||
1657 | if (o->bidi_delimiters) eina_stringshare_del(o->bidi_delimiters); | 1660 | if (o->bidi_delimiters) eina_stringshare_del(o->bidi_delimiters); |
1658 | if (o->cur.text) free(o->cur.text); | 1661 | if (o->cur.text) free(o->cur.text); |
1659 | if (o->font && obj->layer && obj->layer->evas) | 1662 | if (o->font && obj->layer && obj->layer->evas) |
1660 | evas_font_free(obj->layer->evas->evas, o->font); | 1663 | evas_font_free(o->font); |
1661 | o->font = NULL; | 1664 | o->font = NULL; |
1662 | o->cur.utf8_text = NULL; | 1665 | o->cur.utf8_text = NULL; |
1663 | o->cur.font = NULL; | 1666 | o->cur.font = NULL; |
@@ -2241,8 +2244,7 @@ _evas_object_text_rehint(Evas_Object *eo_obj) | |||
2241 | Eina_List *was = NULL; | 2244 | Eina_List *was = NULL; |
2242 | 2245 | ||
2243 | if (!o->font) return; | 2246 | if (!o->font) return; |
2244 | evas_font_load_hinting_set(obj->layer->evas->evas, o->font, | 2247 | evas_font_load_hinting_set(o->font, obj->layer->evas->hinting); |
2245 | obj->layer->evas->hinting); | ||
2246 | was = _evas_pointer_list_in_rect_get(obj->layer->evas, eo_obj, obj, 1, 1); | 2248 | was = _evas_pointer_list_in_rect_get(obj->layer->evas, eo_obj, obj, 1, 1); |
2247 | /* DO II */ | 2249 | /* DO II */ |
2248 | _evas_object_text_recalc(eo_obj, o->cur.text); | 2250 | _evas_object_text_recalc(eo_obj, o->cur.text); |
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c index c311b58909..0b375e41d5 100644 --- a/src/lib/evas/canvas/evas_object_textblock.c +++ b/src/lib/evas/canvas/evas_object_textblock.c | |||
@@ -1007,7 +1007,7 @@ _format_unref_free(Evas_Object_Protected_Data *evas_o, Evas_Object_Textblock_For | |||
1007 | fmt->gfx_filter = NULL; | 1007 | fmt->gfx_filter = NULL; |
1008 | } | 1008 | } |
1009 | if ((obj->layer) && (obj->layer->evas)) | 1009 | if ((obj->layer) && (obj->layer->evas)) |
1010 | evas_font_free(obj->layer->evas->evas, fmt->font.font); | 1010 | evas_font_free(fmt->font.font); |
1011 | free(fmt); | 1011 | free(fmt); |
1012 | } | 1012 | } |
1013 | 1013 | ||
@@ -2835,8 +2835,12 @@ _format_dup(Evas_Object *eo_obj, const Evas_Object_Textblock_Format *fmt) | |||
2835 | if (fmt->font.source) fmt2->font.source = eina_stringshare_add(fmt->font.source); | 2835 | if (fmt->font.source) fmt2->font.source = eina_stringshare_add(fmt->font.source); |
2836 | 2836 | ||
2837 | /* FIXME: just ref the font here... */ | 2837 | /* FIXME: just ref the font here... */ |
2838 | fmt2->font.font = evas_font_load(obj->layer->evas->evas, fmt2->font.fdesc, | 2838 | fmt2->font.font = evas_font_load(obj->layer->evas->font_path, |
2839 | fmt2->font.source, (int)(((double) fmt2->font.size) * obj->cur->scale), fmt2->font.bitmap_scalable); | 2839 | obj->layer->evas->hinting, |
2840 | fmt2->font.fdesc, | ||
2841 | fmt2->font.source, | ||
2842 | (int)(((double) fmt2->font.size) * obj->cur->scale), | ||
2843 | fmt2->font.bitmap_scalable); | ||
2840 | 2844 | ||
2841 | if (fmt->gfx_filter) | 2845 | if (fmt->gfx_filter) |
2842 | { | 2846 | { |
@@ -3392,8 +3396,12 @@ _layout_format_push(Ctxt *c, Evas_Object_Textblock_Format *fmt, | |||
3392 | fmt->font.fdesc->slant = _FMT_INFO(font_slant); | 3396 | fmt->font.fdesc->slant = _FMT_INFO(font_slant); |
3393 | fmt->font.fdesc->width = _FMT_INFO(font_width); | 3397 | fmt->font.fdesc->width = _FMT_INFO(font_width); |
3394 | fmt->font.fdesc->lang = _FMT_INFO(font_lang); | 3398 | fmt->font.fdesc->lang = _FMT_INFO(font_lang); |
3395 | fmt->font.font = evas_font_load(evas_obj->layer->evas->evas, fmt->font.fdesc, | 3399 | fmt->font.font = evas_font_load(evas_obj->layer->evas->font_path, |
3396 | fmt->font.source, (int)(((double) _FMT_INFO(size)) * evas_obj->cur->scale), fmt->font.bitmap_scalable); | 3400 | evas_obj->layer->evas->hinting, |
3401 | fmt->font.fdesc, | ||
3402 | fmt->font.source, | ||
3403 | (int)(((double) _FMT_INFO(size)) * evas_obj->cur->scale), | ||
3404 | fmt->font.bitmap_scalable); | ||
3397 | } | 3405 | } |
3398 | if (_FMT_INFO(gfx_filter_name)) | 3406 | if (_FMT_INFO(gfx_filter_name)) |
3399 | { | 3407 | { |
@@ -4276,7 +4284,7 @@ _text_item_update_sizes(Ctxt *c, Evas_Object_Textblock_Text_Item *ti) | |||
4276 | if (shx1 < minx) minx = shx1; | 4284 | if (shx1 < minx) minx = shx1; |
4277 | if (shx2 > maxx) maxx = shx2; | 4285 | if (shx2 > maxx) maxx = shx2; |
4278 | ti->x_adjustment = maxx - minx; | 4286 | ti->x_adjustment = maxx - minx; |
4279 | 4287 | ||
4280 | ti->parent.w = tw + ti->x_adjustment; | 4288 | ti->parent.w = tw + ti->x_adjustment; |
4281 | ti->parent.h = th; | 4289 | ti->parent.h = th; |
4282 | ti->parent.adv = advw; | 4290 | ti->parent.adv = advw; |
@@ -4538,9 +4546,13 @@ _format_finalize(Evas_Object *eo_obj, Evas_Object_Textblock_Format *fmt) | |||
4538 | 4546 | ||
4539 | of = fmt->font.font; | 4547 | of = fmt->font.font; |
4540 | 4548 | ||
4541 | fmt->font.font = evas_font_load(obj->layer->evas->evas, fmt->font.fdesc, | 4549 | fmt->font.font = evas_font_load(obj->layer->evas->font_path, |
4542 | fmt->font.source, (int)(((double) fmt->font.size) * obj->cur->scale), fmt->font.bitmap_scalable); | 4550 | obj->layer->evas->hinting, |
4543 | if (of) evas_font_free(obj->layer->evas->evas, of); | 4551 | fmt->font.fdesc, |
4552 | fmt->font.source, | ||
4553 | (int)(((double) fmt->font.size) * obj->cur->scale), | ||
4554 | fmt->font.bitmap_scalable); | ||
4555 | if (of) evas_font_free(of); | ||
4544 | } | 4556 | } |
4545 | 4557 | ||
4546 | static Efl_Canvas_Text_Filter_Program * | 4558 | static Efl_Canvas_Text_Filter_Program * |
@@ -4666,11 +4678,11 @@ _layout_do_format(const Evas_Object *obj, Ctxt *c, | |||
4666 | // item size=20x10 href=name | 4678 | // item size=20x10 href=name |
4667 | // item relsize=20x10 href=name | 4679 | // item relsize=20x10 href=name |
4668 | // item abssize=20x10 href=name | 4680 | // item abssize=20x10 href=name |
4669 | // | 4681 | // |
4670 | // optional arguments: | 4682 | // optional arguments: |
4671 | // vsize=full | 4683 | // vsize=full |
4672 | // vsize=ascent | 4684 | // vsize=ascent |
4673 | // | 4685 | // |
4674 | // size == item size (modifies line size) - can be multiplied by | 4686 | // size == item size (modifies line size) - can be multiplied by |
4675 | // scale factor | 4687 | // scale factor |
4676 | // relsize == relative size (height is current font height, width | 4688 | // relsize == relative size (height is current font height, width |
@@ -5424,7 +5436,7 @@ _item_get_cutoff(Ctxt *c, Evas_Object_Textblock_Item *it, Evas_Coord x, Evas_Coo | |||
5424 | * that don't intersect in whole) will be split, and the rest are set to be | 5436 | * that don't intersect in whole) will be split, and the rest are set to be |
5425 | * visually-deleted. | 5437 | * visually-deleted. |
5426 | * Note that a special case for visible format items does not | 5438 | * Note that a special case for visible format items does not |
5427 | * split them, but instead just visually-deletes them (because there are no | 5439 | * split them, but instead just visually-deletes them (because there are no |
5428 | * characters to split). | 5440 | * characters to split). |
5429 | */ | 5441 | */ |
5430 | static inline void | 5442 | static inline void |
@@ -7903,7 +7915,7 @@ _evas_object_textblock_text_markup_get(Eo *eo_obj, Efl_Canvas_Text_Data *o) | |||
7903 | { | 7915 | { |
7904 | Eina_Unicode tmp_ch; | 7916 | Eina_Unicode tmp_ch; |
7905 | off += fnode->offset; | 7917 | off += fnode->offset; |
7906 | 7918 | ||
7907 | if (off > len) break; | 7919 | if (off > len) break; |
7908 | /* No need to skip on the first run */ | 7920 | /* No need to skip on the first run */ |
7909 | tmp_ch = text[off]; | 7921 | tmp_ch = text[off]; |
@@ -14597,9 +14609,8 @@ _evas_object_textblock_rehint(Evas_Object *eo_obj) | |||
14597 | Evas_Object_Textblock_Text_Item *ti = _ITEM_TEXT(it); | 14609 | Evas_Object_Textblock_Text_Item *ti = _ITEM_TEXT(it); |
14598 | if (ti->parent.format->font.font) | 14610 | if (ti->parent.format->font.font) |
14599 | { | 14611 | { |
14600 | evas_font_load_hinting_set(obj->layer->evas->evas, | 14612 | evas_font_load_hinting_set(ti->parent.format->font.font, |
14601 | ti->parent.format->font.font, | 14613 | obj->layer->evas->hinting); |
14602 | obj->layer->evas->hinting); | ||
14603 | } | 14614 | } |
14604 | } | 14615 | } |
14605 | } | 14616 | } |
diff --git a/src/lib/evas/canvas/evas_object_textgrid.c b/src/lib/evas/canvas/evas_object_textgrid.c index 50a636d18b..e0404a67af 100644 --- a/src/lib/evas/canvas/evas_object_textgrid.c +++ b/src/lib/evas/canvas/evas_object_textgrid.c | |||
@@ -210,7 +210,7 @@ evas_object_textgrid_rows_clear(Evas_Object *eo_obj) | |||
210 | } | 210 | } |
211 | 211 | ||
212 | static void | 212 | static void |
213 | evas_object_textgrid_free(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj) | 213 | evas_object_textgrid_free(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj EINA_UNUSED) |
214 | { | 214 | { |
215 | Evas_Object_Textgrid_Color *c; | 215 | Evas_Object_Textgrid_Color *c; |
216 | Evas_Textgrid_Data *o = efl_data_scope_get(eo_obj, MY_CLASS); | 216 | Evas_Textgrid_Data *o = efl_data_scope_get(eo_obj, MY_CLASS); |
@@ -223,10 +223,10 @@ evas_object_textgrid_free(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj) | |||
223 | 223 | ||
224 | if (o->cur.font_description_normal) | 224 | if (o->cur.font_description_normal) |
225 | evas_font_desc_unref(o->cur.font_description_normal); | 225 | evas_font_desc_unref(o->cur.font_description_normal); |
226 | if (o->font_normal) evas_font_free(obj->layer->evas->evas, o->font_normal); | 226 | if (o->font_normal) evas_font_free(o->font_normal); |
227 | if (o->font_bold) evas_font_free(obj->layer->evas->evas, o->font_bold); | 227 | if (o->font_bold) evas_font_free(o->font_bold); |
228 | if (o->font_italic) evas_font_free(obj->layer->evas->evas, o->font_italic); | 228 | if (o->font_italic) evas_font_free(o->font_italic); |
229 | if (o->font_bolditalic) evas_font_free(obj->layer->evas->evas, o->font_bolditalic); | 229 | if (o->font_bolditalic) evas_font_free(o->font_bolditalic); |
230 | 230 | ||
231 | if (o->cur.cells) free(o->cur.cells); | 231 | if (o->cur.cells) free(o->cur.cells); |
232 | while ((c = eina_array_pop(&o->cur.palette_standard))) | 232 | while ((c = eina_array_pop(&o->cur.palette_standard))) |
@@ -784,17 +784,17 @@ evas_object_textgrid_render_pre(Evas_Object *eo_obj, | |||
784 | if (r->ch1 >= 0) | 784 | if (r->ch1 >= 0) |
785 | { | 785 | { |
786 | Evas_Coord chx, chy, chw, chh; | 786 | Evas_Coord chx, chy, chw, chh; |
787 | 787 | ||
788 | chx = r->ch1 * o->cur.char_width; | 788 | chx = r->ch1 * o->cur.char_width; |
789 | chy = i * o->cur.char_height; | 789 | chy = i * o->cur.char_height; |
790 | chw = (r->ch2 - r->ch1 + 1) * o->cur.char_width; | 790 | chw = (r->ch2 - r->ch1 + 1) * o->cur.char_width; |
791 | chh = o->cur.char_height; | 791 | chh = o->cur.char_height; |
792 | 792 | ||
793 | chx -= o->cur.char_width; | 793 | chx -= o->cur.char_width; |
794 | chy -= o->cur.char_height; | 794 | chy -= o->cur.char_height; |
795 | chw += o->cur.char_width * 2; | 795 | chw += o->cur.char_width * 2; |
796 | chh += o->cur.char_height * 2; | 796 | chh += o->cur.char_height * 2; |
797 | 797 | ||
798 | chx += obj->cur->geometry.x; | 798 | chx += obj->cur->geometry.x; |
799 | chy += obj->cur->geometry.y; | 799 | chy += obj->cur->geometry.y; |
800 | RECTS_CLIP_TO_RECT(chx, chy, chw, chh, | 800 | RECTS_CLIP_TO_RECT(chx, chy, chw, chh, |
@@ -808,7 +808,7 @@ evas_object_textgrid_render_pre(Evas_Object *eo_obj, | |||
808 | } | 808 | } |
809 | } | 809 | } |
810 | } | 810 | } |
811 | 811 | ||
812 | done: | 812 | done: |
813 | o->core_change = 0; | 813 | o->core_change = 0; |
814 | o->row_change = 0; | 814 | o->row_change = 0; |
@@ -1003,11 +1003,12 @@ _alternate_font_weight_slant(Evas_Object_Protected_Data *obj, | |||
1003 | int ret = -1; | 1003 | int ret = -1; |
1004 | Evas_Font_Set *font; | 1004 | Evas_Font_Set *font; |
1005 | 1005 | ||
1006 | font = evas_font_load(obj->layer->evas->evas, | 1006 | font = evas_font_load(obj->layer->evas->font_path, |
1007 | obj->layer->evas->hinting, | ||
1007 | fdesc, | 1008 | fdesc, |
1008 | o->cur.font_source, | 1009 | o->cur.font_source, |
1009 | (int)(((double) o->cur.font_size) * | 1010 | (int)(((double) o->cur.font_size) * |
1010 | obj->cur->scale), | 1011 | obj->cur->scale), |
1011 | o->cur.bitmap_scalable); | 1012 | o->cur.bitmap_scalable); |
1012 | if (font) | 1013 | if (font) |
1013 | { | 1014 | { |
@@ -1040,7 +1041,7 @@ _alternate_font_weight_slant(Evas_Object_Protected_Data *obj, | |||
1040 | (o->cur.char_height != vadvance) || | 1041 | (o->cur.char_height != vadvance) || |
1041 | (o->ascent != ascent)) | 1042 | (o->ascent != ascent)) |
1042 | { | 1043 | { |
1043 | evas_font_free(obj->layer->evas->evas, font); | 1044 | evas_font_free(font); |
1044 | } | 1045 | } |
1045 | else | 1046 | else |
1046 | { | 1047 | { |
@@ -1080,16 +1081,17 @@ _evas_textgrid_font_reload(Eo *eo_obj, Evas_Textgrid_Data *o) | |||
1080 | 1081 | ||
1081 | if (o->font_normal) | 1082 | if (o->font_normal) |
1082 | { | 1083 | { |
1083 | evas_font_free(obj->layer->evas->evas, o->font_normal); | 1084 | evas_font_free(o->font_normal); |
1084 | o->font_normal = NULL; | 1085 | o->font_normal = NULL; |
1085 | } | 1086 | } |
1086 | 1087 | ||
1087 | o->font_normal = evas_font_load(obj->layer->evas->evas, | 1088 | o->font_normal = evas_font_load(obj->layer->evas->font_path, |
1088 | o->cur.font_description_normal, | 1089 | obj->layer->evas->hinting, |
1089 | o->cur.font_source, | 1090 | o->cur.font_description_normal, |
1090 | (int)(((double) o->cur.font_size) * | 1091 | o->cur.font_source, |
1091 | obj->cur->scale), | 1092 | (int)(((double) o->cur.font_size) * |
1092 | o->cur.bitmap_scalable); | 1093 | obj->cur->scale), |
1094 | o->cur.bitmap_scalable); | ||
1093 | if (o->font_normal) | 1095 | if (o->font_normal) |
1094 | { | 1096 | { |
1095 | Eina_Unicode W[2] = { 'O', 0 }; | 1097 | Eina_Unicode W[2] = { 'O', 0 }; |
@@ -1133,7 +1135,7 @@ _evas_textgrid_font_reload(Eo *eo_obj, Evas_Textgrid_Data *o) | |||
1133 | /* Bold */ | 1135 | /* Bold */ |
1134 | if (o->font_bold) | 1136 | if (o->font_bold) |
1135 | { | 1137 | { |
1136 | evas_font_free(obj->layer->evas->evas, o->font_bold); | 1138 | evas_font_free(o->font_bold); |
1137 | o->font_bold = NULL; | 1139 | o->font_bold = NULL; |
1138 | } | 1140 | } |
1139 | if ((fdesc->weight == EVAS_FONT_WEIGHT_NORMAL) || | 1141 | if ((fdesc->weight == EVAS_FONT_WEIGHT_NORMAL) || |
@@ -1153,7 +1155,7 @@ _evas_textgrid_font_reload(Eo *eo_obj, Evas_Textgrid_Data *o) | |||
1153 | /* Italic */ | 1155 | /* Italic */ |
1154 | if (o->font_italic) | 1156 | if (o->font_italic) |
1155 | { | 1157 | { |
1156 | evas_font_free(obj->layer->evas->evas, o->font_italic); | 1158 | evas_font_free(o->font_italic); |
1157 | o->font_italic = NULL; | 1159 | o->font_italic = NULL; |
1158 | } | 1160 | } |
1159 | if (fdesc->slant == EVAS_FONT_SLANT_NORMAL) | 1161 | if (fdesc->slant == EVAS_FONT_SLANT_NORMAL) |
@@ -1180,7 +1182,7 @@ _evas_textgrid_font_reload(Eo *eo_obj, Evas_Textgrid_Data *o) | |||
1180 | /* BoldItalic */ | 1182 | /* BoldItalic */ |
1181 | if (o->font_bolditalic) | 1183 | if (o->font_bolditalic) |
1182 | { | 1184 | { |
1183 | evas_font_free(obj->layer->evas->evas, o->font_bolditalic); | 1185 | evas_font_free(o->font_bolditalic); |
1184 | o->font_bolditalic = NULL; | 1186 | o->font_bolditalic = NULL; |
1185 | } | 1187 | } |
1186 | if (fdesc->slant == EVAS_FONT_SLANT_NORMAL && | 1188 | if (fdesc->slant == EVAS_FONT_SLANT_NORMAL && |
@@ -1384,7 +1386,7 @@ _evas_textgrid_palette_get(const Eo *eo_obj EINA_UNUSED, Evas_Textgrid_Data *o, | |||
1384 | default: | 1386 | default: |
1385 | return; | 1387 | return; |
1386 | } | 1388 | } |
1387 | 1389 | ||
1388 | if (idx >= (int)eina_array_count(palette)) return; | 1390 | if (idx >= (int)eina_array_count(palette)) return; |
1389 | color = eina_array_data_get(palette, idx); | 1391 | color = eina_array_data_get(palette, idx); |
1390 | if (!color) return; | 1392 | if (!color) return; |
@@ -1437,16 +1439,16 @@ _evas_textgrid_update_add(Eo *eo_obj, Evas_Textgrid_Data *o, int x, int y, int w | |||
1437 | { | 1439 | { |
1438 | Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS); | 1440 | Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS); |
1439 | int i, x2; | 1441 | int i, x2; |
1440 | 1442 | ||
1441 | RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, o->cur.w, o->cur.h); | 1443 | RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, o->cur.w, o->cur.h); |
1442 | if ((w <= 0) || (h <= 0)) return; | 1444 | if ((w <= 0) || (h <= 0)) return; |
1443 | 1445 | ||
1444 | evas_object_async_block(obj); | 1446 | evas_object_async_block(obj); |
1445 | x2 = x + w - 1; | 1447 | x2 = x + w - 1; |
1446 | for (i = 0; i < h; i++) | 1448 | for (i = 0; i < h; i++) |
1447 | { | 1449 | { |
1448 | Evas_Object_Textgrid_Row *r = &(o->cur.rows[y + i]); | 1450 | Evas_Object_Textgrid_Row *r = &(o->cur.rows[y + i]); |
1449 | 1451 | ||
1450 | if (r->ch1 < 0) | 1452 | if (r->ch1 < 0) |
1451 | { | 1453 | { |
1452 | evas_object_textgrid_row_clear(o, r); | 1454 | evas_object_textgrid_row_clear(o, r); |
diff --git a/src/lib/evas/canvas/evas_render.c b/src/lib/evas/canvas/evas_render.c index 9e6a65859f..1409f39ebb 100644 --- a/src/lib/evas/canvas/evas_render.c +++ b/src/lib/evas/canvas/evas_render.c | |||
@@ -4001,7 +4001,7 @@ _evas_canvas_render_idle_flush(Eo *eo_e, Evas_Public_Data *evas) | |||
4001 | 4001 | ||
4002 | evas_render_rendering_wait(evas); | 4002 | evas_render_rendering_wait(evas); |
4003 | 4003 | ||
4004 | evas_fonts_zero_pressure(eo_e); | 4004 | evas_fonts_zero_pressure(); |
4005 | 4005 | ||
4006 | if (ENFN && ENFN->output_idle_flush) | 4006 | if (ENFN && ENFN->output_idle_flush) |
4007 | { | 4007 | { |
@@ -4125,7 +4125,7 @@ _evas_canvas_render_dump(Eo *eo_e, Evas_Public_Data *evas) | |||
4125 | GC_ALL(evas_object_image_load_opts_cow); | 4125 | GC_ALL(evas_object_image_load_opts_cow); |
4126 | GC_ALL(evas_object_image_state_cow); | 4126 | GC_ALL(evas_object_image_state_cow); |
4127 | 4127 | ||
4128 | evas_fonts_zero_pressure(eo_e); | 4128 | evas_fonts_zero_pressure(); |
4129 | 4129 | ||
4130 | if (ENFN && ENFN->output_idle_flush) | 4130 | if (ENFN && ENFN->output_idle_flush) |
4131 | { | 4131 | { |
diff --git a/src/lib/evas/canvas/render2/evas_render2_old.c b/src/lib/evas/canvas/render2/evas_render2_old.c index 71eb7307b0..b310ccb267 100644 --- a/src/lib/evas/canvas/render2/evas_render2_old.c +++ b/src/lib/evas/canvas/render2/evas_render2_old.c | |||
@@ -433,7 +433,7 @@ _evas_render2_idle_flush(Eo *eo_e) | |||
433 | // wait for rendering to finish so we don't mess up shared resources | 433 | // wait for rendering to finish so we don't mess up shared resources |
434 | _evas_render2_wait(eo_e); | 434 | _evas_render2_wait(eo_e); |
435 | // clean fonts | 435 | // clean fonts |
436 | evas_fonts_zero_pressure(eo_e); | 436 | evas_fonts_zero_pressure(); |
437 | // call engine idle flush call | 437 | // call engine idle flush call |
438 | if ((e->engine.func) && (e->engine.func->output_idle_flush) && | 438 | if ((e->engine.func) && (e->engine.func->output_idle_flush) && |
439 | (e->engine.data.output)) | 439 | (e->engine.data.output)) |
diff --git a/src/lib/evas/common/evas_font.h b/src/lib/evas/common/evas_font.h index 132b474e2f..8d57476953 100644 --- a/src/lib/evas/common/evas_font.h +++ b/src/lib/evas/common/evas_font.h | |||
@@ -1,9 +1,329 @@ | |||
1 | #ifndef _EVAS_FONT_H | 1 | #ifndef _EVAS_FONT_H |
2 | #define _EVAS_FONT_H | 2 | #define _EVAS_FONT_H |
3 | |||
4 | typedef unsigned char DATA8; | ||
5 | typedef unsigned long long DATA64; | ||
6 | |||
7 | #include <ft2build.h> | ||
8 | #include FT_FREETYPE_H | ||
9 | #include FT_GLYPH_H | ||
10 | #include FT_SIZES_H | ||
11 | #include FT_MODULE_H | ||
12 | |||
13 | #ifndef FT_HAS_COLOR | ||
14 | # define FT_HAS_COLOR(face) 0 | ||
15 | #endif | ||
16 | |||
17 | #ifndef FT_LOAD_COLOR | ||
18 | # define FT_LOAD_COLOR FT_LOAD_DEFAULT | ||
19 | #endif | ||
20 | |||
21 | #ifdef EAPI | ||
22 | # undef EAPI | ||
23 | #endif | ||
24 | |||
25 | #ifdef _WIN32 | ||
26 | # ifdef EFL_EVAS_BUILD | ||
27 | # ifdef DLL_EXPORT | ||
28 | # define EAPI __declspec(dllexport) | ||
29 | # else | ||
30 | # define EAPI | ||
31 | # endif /* ! DLL_EXPORT */ | ||
32 | # else | ||
33 | # define EAPI __declspec(dllimport) | ||
34 | # endif /* ! EFL_EVAS_BUILD */ | ||
35 | #else | ||
36 | # ifdef __GNUC__ | ||
37 | # if __GNUC__ >= 4 | ||
38 | # define EAPI __attribute__ ((visibility("default"))) | ||
39 | # else | ||
40 | # define EAPI | ||
41 | # endif | ||
42 | # else | ||
43 | # define EAPI | ||
44 | # endif | ||
45 | #endif /* ! _WIN32 */ | ||
46 | |||
47 | #include <Eina.h> | ||
48 | |||
49 | #define LK(x) Eina_Lock x | ||
50 | #define LKU(x) eina_lock_release(&(x)) | ||
51 | #define LKL(x) eina_lock_take(&(x)) | ||
52 | #define LKD(x) eina_lock_free(&(x)) | ||
53 | |||
3 | #include "evas_text_utils.h" | 54 | #include "evas_text_utils.h" |
4 | 55 | ||
56 | |||
57 | enum _Evas_Font_Style | ||
58 | { | ||
59 | EVAS_FONT_STYLE_SLANT, | ||
60 | EVAS_FONT_STYLE_WEIGHT, | ||
61 | EVAS_FONT_STYLE_WIDTH | ||
62 | }; | ||
63 | |||
64 | enum _Evas_Font_Slant | ||
65 | { | ||
66 | EVAS_FONT_SLANT_NORMAL, | ||
67 | EVAS_FONT_SLANT_OBLIQUE, | ||
68 | EVAS_FONT_SLANT_ITALIC | ||
69 | }; | ||
70 | |||
71 | enum _Evas_Font_Weight | ||
72 | { | ||
73 | EVAS_FONT_WEIGHT_NORMAL, | ||
74 | EVAS_FONT_WEIGHT_THIN, | ||
75 | EVAS_FONT_WEIGHT_ULTRALIGHT, | ||
76 | EVAS_FONT_WEIGHT_EXTRALIGHT, | ||
77 | EVAS_FONT_WEIGHT_LIGHT, | ||
78 | EVAS_FONT_WEIGHT_BOOK, | ||
79 | EVAS_FONT_WEIGHT_MEDIUM, | ||
80 | EVAS_FONT_WEIGHT_SEMIBOLD, | ||
81 | EVAS_FONT_WEIGHT_BOLD, | ||
82 | EVAS_FONT_WEIGHT_ULTRABOLD, | ||
83 | EVAS_FONT_WEIGHT_EXTRABOLD, | ||
84 | EVAS_FONT_WEIGHT_BLACK, | ||
85 | EVAS_FONT_WEIGHT_EXTRABLACK | ||
86 | }; | ||
87 | |||
88 | enum _Evas_Font_Width | ||
89 | { | ||
90 | EVAS_FONT_WIDTH_NORMAL, | ||
91 | EVAS_FONT_WIDTH_ULTRACONDENSED, | ||
92 | EVAS_FONT_WIDTH_EXTRACONDENSED, | ||
93 | EVAS_FONT_WIDTH_CONDENSED, | ||
94 | EVAS_FONT_WIDTH_SEMICONDENSED, | ||
95 | EVAS_FONT_WIDTH_SEMIEXPANDED, | ||
96 | EVAS_FONT_WIDTH_EXPANDED, | ||
97 | EVAS_FONT_WIDTH_EXTRAEXPANDED, | ||
98 | EVAS_FONT_WIDTH_ULTRAEXPANDED | ||
99 | }; | ||
100 | |||
101 | enum _Evas_Font_Spacing | ||
102 | { | ||
103 | EVAS_FONT_SPACING_PROPORTIONAL, | ||
104 | EVAS_FONT_SPACING_DUAL, | ||
105 | EVAS_FONT_SPACING_MONO, | ||
106 | EVAS_FONT_SPACING_CHARCELL | ||
107 | }; | ||
108 | |||
109 | typedef enum _Evas_Font_Style Evas_Font_Style; | ||
110 | typedef enum _Evas_Font_Slant Evas_Font_Slant; | ||
111 | typedef enum _Evas_Font_Weight Evas_Font_Weight; | ||
112 | typedef enum _Evas_Font_Width Evas_Font_Width; | ||
113 | typedef enum _Evas_Font_Spacing Evas_Font_Spacing; | ||
114 | |||
115 | typedef struct _Evas_Font_Dir Evas_Font_Dir; | ||
116 | typedef struct _Evas_Font Evas_Font; | ||
117 | typedef struct _Evas_Font_Alias Evas_Font_Alias; | ||
118 | typedef struct _Evas_Font_Description Evas_Font_Description; | ||
119 | |||
120 | |||
121 | typedef struct _RGBA_Font RGBA_Font; | ||
122 | typedef struct _RGBA_Font_Int RGBA_Font_Int; | ||
123 | typedef struct _RGBA_Font_Source RGBA_Font_Source; | ||
124 | typedef struct _RGBA_Font_Glyph RGBA_Font_Glyph; | ||
125 | typedef struct _RGBA_Font_Glyph_Out RGBA_Font_Glyph_Out; | ||
126 | |||
127 | typedef struct _Fash_Item_Index_Map Fash_Item_Index_Map; | ||
128 | typedef struct _Fash_Int_Map Fash_Int_Map; | ||
129 | typedef struct _Fash_Int_Map2 Fash_Int_Map2; | ||
130 | typedef struct _Fash_Int Fash_Int; | ||
131 | |||
132 | |||
133 | struct _Fash_Item_Index_Map | ||
134 | { | ||
135 | RGBA_Font_Int *fint; | ||
136 | int index; | ||
137 | }; | ||
138 | struct _Fash_Int_Map | ||
139 | { | ||
140 | Fash_Item_Index_Map item[256]; | ||
141 | }; | ||
142 | struct _Fash_Int_Map2 | ||
143 | { | ||
144 | Fash_Int_Map *bucket[256]; | ||
145 | }; | ||
146 | struct _Fash_Int | ||
147 | { | ||
148 | Fash_Int_Map2 *bucket[256]; | ||
149 | void (*freeme) (Fash_Int *fash); | ||
150 | }; | ||
151 | |||
152 | typedef struct _Fash_Glyph_Map Fash_Glyph_Map; | ||
153 | typedef struct _Fash_Glyph_Map2 Fash_Glyph_Map2; | ||
154 | typedef struct _Fash_Glyph Fash_Glyph; | ||
155 | struct _Fash_Glyph_Map | ||
156 | { | ||
157 | RGBA_Font_Glyph *item[256]; | ||
158 | }; | ||
159 | struct _Fash_Glyph_Map2 | ||
160 | { | ||
161 | Fash_Glyph_Map *bucket[256]; | ||
162 | }; | ||
163 | struct _Fash_Glyph | ||
164 | { | ||
165 | Fash_Glyph_Map2 *bucket[256]; | ||
166 | void (*freeme) (Fash_Glyph *fash); | ||
167 | }; | ||
168 | |||
169 | |||
170 | typedef enum _Font_Hint_Flags | ||
171 | { | ||
172 | FONT_NO_HINT, | ||
173 | FONT_AUTO_HINT, | ||
174 | FONT_BYTECODE_HINT | ||
175 | } Font_Hint_Flags; | ||
176 | |||
177 | typedef enum _Font_Rend_Flags | ||
178 | { | ||
179 | FONT_REND_REGULAR = 0, | ||
180 | FONT_REND_SLANT = (1 << 0), | ||
181 | FONT_REND_WEIGHT = (1 << 1), | ||
182 | } Font_Rend_Flags; | ||
183 | |||
184 | struct _RGBA_Font | ||
185 | { | ||
186 | Eina_List *fonts; | ||
187 | Fash_Int *fash; | ||
188 | Font_Hint_Flags hinting; | ||
189 | int references; | ||
190 | LK(lock); | ||
191 | unsigned char sizeok : 1; | ||
192 | }; | ||
193 | |||
194 | |||
195 | struct _Evas_Font_Dir | ||
196 | { | ||
197 | Eina_Hash *lookup; | ||
198 | Eina_List *fonts; | ||
199 | Eina_List *aliases; | ||
200 | DATA64 dir_mod_time; | ||
201 | DATA64 fonts_dir_mod_time; | ||
202 | DATA64 fonts_alias_mod_time; | ||
203 | }; | ||
204 | |||
205 | struct _Evas_Font | ||
206 | { | ||
207 | struct { | ||
208 | const char *prop[14]; | ||
209 | } x; | ||
210 | struct { | ||
211 | const char *name; | ||
212 | } simple; | ||
213 | const char *path; | ||
214 | char type; | ||
215 | }; | ||
216 | |||
217 | struct _Evas_Font_Alias | ||
218 | { | ||
219 | const char *alias; | ||
220 | Evas_Font *fn; | ||
221 | }; | ||
222 | |||
223 | struct _Evas_Font_Description | ||
224 | { | ||
225 | int ref; | ||
226 | Eina_Stringshare *name; | ||
227 | Eina_Stringshare *fallbacks; | ||
228 | Eina_Stringshare *lang; | ||
229 | Eina_Stringshare *style; | ||
230 | |||
231 | Evas_Font_Slant slant; | ||
232 | Evas_Font_Weight weight; | ||
233 | Evas_Font_Width width; | ||
234 | Evas_Font_Spacing spacing; | ||
235 | |||
236 | Eina_Bool is_new : 1; | ||
237 | }; | ||
238 | |||
239 | struct _RGBA_Font_Int | ||
240 | { | ||
241 | EINA_INLIST; | ||
242 | RGBA_Font_Source *src; | ||
243 | Eina_Hash *kerning; | ||
244 | Fash_Glyph *fash; | ||
245 | unsigned int size; | ||
246 | float scale_factor; | ||
247 | int real_size; | ||
248 | int max_h; | ||
249 | int references; | ||
250 | int usage; | ||
251 | struct { | ||
252 | FT_Size size; | ||
253 | #ifdef USE_HARFBUZZ | ||
254 | void *hb_font; | ||
255 | #endif | ||
256 | } ft; | ||
257 | LK(ft_mutex); | ||
258 | Font_Hint_Flags hinting; | ||
259 | Font_Rend_Flags wanted_rend; /* The wanted rendering style */ | ||
260 | Font_Rend_Flags runtime_rend; /* The rendering we need to do on runtime | ||
261 | in order to comply with the wanted_rend. */ | ||
262 | |||
263 | Eina_List *task; | ||
264 | #ifdef EVAS_CSERVE2 | ||
265 | void *cs2_handler; | ||
266 | #endif | ||
267 | |||
268 | int generation; | ||
269 | |||
270 | Efl_Text_Font_Bitmap_Scalable bitmap_scalable; | ||
271 | |||
272 | unsigned char sizeok : 1; | ||
273 | unsigned char inuse : 1; | ||
274 | }; | ||
275 | |||
276 | struct _RGBA_Font_Source | ||
277 | { | ||
278 | const char *name; | ||
279 | const char *file; | ||
280 | void *data; | ||
281 | unsigned int current_size; | ||
282 | int data_size; | ||
283 | int references; | ||
284 | struct { | ||
285 | int orig_upem; | ||
286 | FT_Face face; | ||
287 | } ft; | ||
288 | }; | ||
289 | |||
290 | /* | ||
291 | * laziness wins for now. The parts used from the freetpye struct are | ||
292 | * kept intact to avoid changing the code using it until we know exactly | ||
293 | * what needs to be changed | ||
294 | */ | ||
295 | struct _RGBA_Font_Glyph_Out | ||
296 | { | ||
297 | unsigned char *rle; | ||
298 | struct { | ||
299 | unsigned char *buffer; | ||
300 | unsigned short rows; | ||
301 | unsigned short width; | ||
302 | unsigned short pitch; | ||
303 | unsigned short rle_alloc : 1; | ||
304 | unsigned short no_free_glout : 1; | ||
305 | } bitmap; | ||
306 | int rle_size; | ||
307 | }; | ||
308 | |||
309 | struct _RGBA_Font_Glyph | ||
310 | { | ||
311 | FT_UInt index; | ||
312 | Evas_Coord width; | ||
313 | Evas_Coord x_bear; | ||
314 | Evas_Coord y_bear; | ||
315 | FT_Glyph glyph; | ||
316 | RGBA_Font_Glyph_Out *glyph_out; | ||
317 | /* this is a problem - only 1 engine at a time can extend such a font... grrr */ | ||
318 | void *ext_dat; | ||
319 | void (*ext_dat_free) (void *ext_dat); | ||
320 | RGBA_Font_Int *fi; | ||
321 | }; | ||
322 | |||
323 | |||
5 | /* The tangent of the slant angle we do on runtime. */ | 324 | /* The tangent of the slant angle we do on runtime. */ |
6 | #define _EVAS_FONT_SLANT_TAN 0.221694663 | 325 | #define _EVAS_FONT_SLANT_TAN 0.221694663 |
326 | |||
7 | /* main */ | 327 | /* main */ |
8 | 328 | ||
9 | EAPI void evas_common_font_init (void); | 329 | EAPI void evas_common_font_init (void); |
@@ -23,20 +343,9 @@ EAPI int evas_common_font_instance_underline_thickness_get (R | |||
23 | EAPI int evas_common_font_get_line_advance (RGBA_Font *fn); | 343 | EAPI int evas_common_font_get_line_advance (RGBA_Font *fn); |
24 | void *evas_common_font_freetype_face_get(RGBA_Font *font); /* XXX: Not EAPI on purpose. Not ment to be used in modules. */ | 344 | void *evas_common_font_freetype_face_get(RGBA_Font *font); /* XXX: Not EAPI on purpose. Not ment to be used in modules. */ |
25 | 345 | ||
26 | /* draw */ | ||
27 | typedef Eina_Bool (*Evas_Common_Font_Draw_Cb)(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, Evas_Glyph_Array *glyphs, RGBA_Gfx_Func func, int ext_x, int ext_y, int ext_w, int ext_h, int im_w, int im_h); | ||
28 | |||
29 | EAPI Eina_Bool evas_common_font_draw_cb (RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, Evas_Glyph_Array *glyphs, Evas_Common_Font_Draw_Cb cb); | ||
30 | EAPI void evas_common_font_draw (RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, Evas_Glyph_Array *glyphs); | ||
31 | EAPI Eina_Bool evas_common_font_rgba_draw (RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, Evas_Glyph_Array *glyphs, RGBA_Gfx_Func func, int ext_x, int ext_y, int ext_w, int ext_h, int im_w, int im_h); | ||
32 | EAPI int evas_common_font_glyph_search (RGBA_Font *fn, RGBA_Font_Int **fi_ret, Eina_Unicode gl); | ||
33 | EAPI RGBA_Font_Glyph *evas_common_font_int_cache_glyph_get (RGBA_Font_Int *fi, FT_UInt index); | 346 | EAPI RGBA_Font_Glyph *evas_common_font_int_cache_glyph_get (RGBA_Font_Int *fi, FT_UInt index); |
34 | EAPI Eina_Bool evas_common_font_int_cache_glyph_render(RGBA_Font_Glyph *fg); | 347 | EAPI Eina_Bool evas_common_font_int_cache_glyph_render(RGBA_Font_Glyph *fg); |
35 | EAPI FT_UInt evas_common_get_char_index (RGBA_Font_Int* fi, Eina_Unicode gl); | 348 | EAPI FT_UInt evas_common_get_char_index (RGBA_Font_Int* fi, Eina_Unicode gl); |
36 | EAPI void evas_common_font_draw_init (void); | ||
37 | EAPI void evas_common_font_draw_prepare (Evas_Text_Props *text_props); | ||
38 | EAPI void evas_common_font_draw_do(const Cutout_Rects *reuse, const Eina_Rectangle *clip, RGBA_Gfx_Func func, RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, const Evas_Text_Props *text_props); | ||
39 | EAPI Eina_Bool evas_common_font_draw_prepare_cutout(Cutout_Rects **reuse, RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Gfx_Func *func); | ||
40 | 349 | ||
41 | /* load */ | 350 | /* load */ |
42 | EAPI void evas_common_font_dpi_set (int dpi_h, int dpi_v); | 351 | EAPI void evas_common_font_dpi_set (int dpi_h, int dpi_v); |
@@ -85,10 +394,31 @@ EAPI int evas_common_font_query_run_font_end_get(RGBA_Font *fn, RG | |||
85 | EAPI void evas_common_font_ascent_descent_get(RGBA_Font *fn, const Evas_Text_Props *text_props, int *ascent, int *descent); | 394 | EAPI void evas_common_font_ascent_descent_get(RGBA_Font *fn, const Evas_Text_Props *text_props, int *ascent, int *descent); |
86 | 395 | ||
87 | EAPI void *evas_common_font_glyph_compress(void *data, int num_grays, int pixel_mode, int pitch_data, int w, int h, int *size_ret); | 396 | EAPI void *evas_common_font_glyph_compress(void *data, int num_grays, int pixel_mode, int pitch_data, int w, int h, int *size_ret); |
88 | EAPI void evas_common_font_glyph_draw(RGBA_Font_Glyph *fg, RGBA_Draw_Context *dc, RGBA_Image *dst, int dst_pitch, int dx, int dy, int dw, int dh, int cx, int cy, int cw, int ch); | ||
89 | EAPI DATA8 *evas_common_font_glyph_uncompress(RGBA_Font_Glyph *fg, int *wret, int *hret); | 397 | EAPI DATA8 *evas_common_font_glyph_uncompress(RGBA_Font_Glyph *fg, int *wret, int *hret); |
398 | EAPI int evas_common_font_glyph_search (RGBA_Font *fn, RGBA_Font_Int **fi_ret, Eina_Unicode gl); | ||
90 | 399 | ||
91 | void evas_common_font_load_init(void); | 400 | void evas_common_font_load_init(void); |
92 | void evas_common_font_load_shutdown(void); | 401 | void evas_common_font_load_shutdown(void); |
93 | 402 | ||
403 | void evas_font_dir_cache_free(void); | ||
404 | const char *evas_font_dir_cache_find(char *dir, char *font); | ||
405 | Eina_List *evas_font_dir_available_list(const Eina_List *font_paths); | ||
406 | void evas_font_dir_available_list_free(Eina_List *available); | ||
407 | void evas_font_free(void *font); | ||
408 | void evas_fonts_zero_free(); | ||
409 | void evas_fonts_zero_pressure(); | ||
410 | void evas_font_name_parse(Evas_Font_Description *fdesc, const char *name); | ||
411 | int evas_font_style_find(const char *start, const char *end, Evas_Font_Style style); | ||
412 | Evas_Font_Description *evas_font_desc_new(void); | ||
413 | Evas_Font_Description *evas_font_desc_dup(const Evas_Font_Description *fdesc); | ||
414 | void evas_font_desc_unref(Evas_Font_Description *fdesc); | ||
415 | int evas_font_desc_cmp(const Evas_Font_Description *a, const Evas_Font_Description *b); | ||
416 | Evas_Font_Description *evas_font_desc_ref(Evas_Font_Description *fdesc); | ||
417 | const char *evas_font_lang_normalize(const char *lang); | ||
418 | void * evas_font_load(const Eina_List *font_paths, int hinting, Evas_Font_Description *fdesc, const char *source, Evas_Font_Size size, Efl_Text_Font_Bitmap_Scalable bitmap_scalable); | ||
419 | void evas_font_load_hinting_set(void *font, int hinting); | ||
420 | |||
421 | #undef EAPI | ||
422 | #define EAPI | ||
423 | |||
94 | #endif /* _EVAS_FONT_H */ | 424 | #endif /* _EVAS_FONT_H */ |
diff --git a/src/lib/evas/common/evas_font_compress.c b/src/lib/evas/common/evas_font_compress.c index 5e7658caf8..6843c97880 100644 --- a/src/lib/evas/common/evas_font_compress.c +++ b/src/lib/evas/common/evas_font_compress.c | |||
@@ -1,23 +1,9 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include "config.h" | ||
3 | #endif | ||
4 | |||
5 | #include <assert.h> | ||
6 | |||
7 | #include "evas_common_private.h" | ||
8 | #include "evas_private.h" | ||
9 | |||
10 | #include "evas_font_private.h" | 1 | #include "evas_font_private.h" |
11 | #include "evas_blend_private.h" | ||
12 | #include "draw.h" | ||
13 | 2 | ||
14 | #ifdef EVAS_CSERVE2 | 3 | #ifdef EVAS_CSERVE2 |
15 | # include "../cserve2/evas_cs2_private.h" | 4 | # include "../cserve2/evas_cs2_private.h" |
16 | #endif | 5 | #endif |
17 | 6 | ||
18 | #include FT_OUTLINE_H | ||
19 | #include FT_SYNTHESIS_H | ||
20 | |||
21 | // XXX: | 7 | // XXX: |
22 | // XXX: adapt cserve2 to this! | 8 | // XXX: adapt cserve2 to this! |
23 | // XXX: | 9 | // XXX: |
@@ -128,7 +114,7 @@ alpha8to4(int a8) | |||
128 | // [char] second byte of RLE data | 114 | // [char] second byte of RLE data |
129 | // ... | 115 | // ... |
130 | // [char] last byte of RLE data | 116 | // [char] last byte of RLE data |
131 | // | 117 | // |
132 | static DATA8 * | 118 | static DATA8 * |
133 | compress_rle4(DATA8 *src, int pitch, int w, int h, int *size_ret) | 119 | compress_rle4(DATA8 *src, int pitch, int w, int h, int *size_ret) |
134 | { | 120 | { |
@@ -247,7 +233,7 @@ static void | |||
247 | decompress_full_row(DATA8 *src, int start, int end, DATA8 *dst) | 233 | decompress_full_row(DATA8 *src, int start, int end, DATA8 *dst) |
248 | { | 234 | { |
249 | DATA8 *p = src + start, *e = src + end, *d = dst, len, val; | 235 | DATA8 *p = src + start, *e = src + end, *d = dst, len, val; |
250 | 236 | ||
251 | while (p < e) | 237 | while (p < e) |
252 | { | 238 | { |
253 | // length is upper 4 bits + 1 | 239 | // length is upper 4 bits + 1 |
@@ -377,7 +363,7 @@ decompress_bpp4(DATA8 *src, DATA8 *dst, int pitch, int w, int h) | |||
377 | { | 363 | { |
378 | int pitch2, x, y; | 364 | int pitch2, x, y; |
379 | DATA8 *d, *s, val; | 365 | DATA8 *d, *s, val; |
380 | 366 | ||
381 | // deal with source pixel to round up for odd length rows | 367 | // deal with source pixel to round up for odd length rows |
382 | pitch2 = (w + 1) / 2; | 368 | pitch2 = (w + 1) / 2; |
383 | // skip header int | 369 | // skip header int |
@@ -462,7 +448,7 @@ evas_common_font_glyph_uncompress(RGBA_Font_Glyph *fg, int *wret, int *hret) | |||
462 | RGBA_Font_Glyph_Out *fgo = fg->glyph_out; | 448 | RGBA_Font_Glyph_Out *fgo = fg->glyph_out; |
463 | DATA8 *buf = calloc(1, fgo->bitmap.width * fgo->bitmap.rows); | 449 | DATA8 *buf = calloc(1, fgo->bitmap.width * fgo->bitmap.rows); |
464 | int *iptr; | 450 | int *iptr; |
465 | 451 | ||
466 | if (!buf) return NULL; | 452 | if (!buf) return NULL; |
467 | if (wret) *wret = fgo->bitmap.width; | 453 | if (wret) *wret = fgo->bitmap.width; |
468 | if (hret) *hret = fgo->bitmap.rows; | 454 | if (hret) *hret = fgo->bitmap.rows; |
@@ -475,154 +461,3 @@ evas_common_font_glyph_uncompress(RGBA_Font_Glyph *fg, int *wret, int *hret) | |||
475 | fgo->bitmap.width, fgo->bitmap.rows); | 461 | fgo->bitmap.width, fgo->bitmap.rows); |
476 | return buf; | 462 | return buf; |
477 | } | 463 | } |
478 | |||
479 | // this draws a compressed font glyph and decompresses on the fly as it | ||
480 | // draws, saving memory bandwidth and providing speedups | ||
481 | EAPI void | ||
482 | evas_common_font_glyph_draw(RGBA_Font_Glyph *fg, | ||
483 | RGBA_Draw_Context *dc, | ||
484 | RGBA_Image *dst_image, int dst_pitch, | ||
485 | int dx, int dy, int dw, int dh, int cx, int cy, int cw, int ch) | ||
486 | { | ||
487 | RGBA_Font_Glyph_Out *fgo = fg->glyph_out; | ||
488 | int x, y, w, h, x1, x2, y1, y2, i, *iptr; | ||
489 | DATA32 *dst = dst_image->image.data; | ||
490 | DATA32 coltab[16], col; | ||
491 | DATA16 mtab[16], v; | ||
492 | |||
493 | // FIXME: Use dw, dh for scaling glyphs... | ||
494 | (void) dw; | ||
495 | (void) dh; | ||
496 | x = dx; | ||
497 | y = dy; | ||
498 | w = fgo->bitmap.width; h = fgo->bitmap.rows; | ||
499 | // skip if totally clipped out | ||
500 | if ((y >= (cy + ch)) || ((y + h) <= cy) || | ||
501 | (x >= (cx + cw)) || ((x + w) <= cx)) return; | ||
502 | // figure y1/y2 limit range | ||
503 | y1 = 0; y2 = h; | ||
504 | if ((y + y1) < cy) y1 = cy - y; | ||
505 | if ((y + y2) > (cy + ch)) y2 = cy + ch - y; | ||
506 | // figure x1/x2 limit range | ||
507 | x1 = 0; x2 = w; | ||
508 | if ((x + x1) < cx) x1 = cx - x; | ||
509 | if ((x + x2) > (cx + cw)) x2 = cx + cw - x; | ||
510 | col = dc->col.col; | ||
511 | if (dst_image->cache_entry.space == EVAS_COLORSPACE_GRY8) | ||
512 | { | ||
513 | // FIXME: Font draw not optimized for Alpha targets! SLOW! | ||
514 | // This is not pretty :) | ||
515 | |||
516 | DATA8 *src8, *dst8; | ||
517 | Draw_Func_Alpha func; | ||
518 | int row; | ||
519 | |||
520 | if (EINA_UNLIKELY(x < 0)) | ||
521 | { | ||
522 | x1 += (-x); | ||
523 | x = 0; | ||
524 | if ((x2 - x1) <= 0) return; | ||
525 | } | ||
526 | if (EINA_UNLIKELY(y < 0)) | ||
527 | { | ||
528 | y1 += (-y); | ||
529 | y = 0; | ||
530 | if ((y2 - y1) <= 0) return; | ||
531 | } | ||
532 | |||
533 | dst8 = dst_image->image.data8 + x + (y * dst_pitch); | ||
534 | func = efl_draw_alpha_func_get(dc->render_op, EINA_FALSE); | ||
535 | src8 = evas_common_font_glyph_uncompress(fg, NULL, NULL); | ||
536 | if (!src8) return; | ||
537 | |||
538 | for (row = y1; row < y2; row++) | ||
539 | { | ||
540 | DATA8 *d = dst8 + ((row - y1) * dst_pitch); | ||
541 | DATA8 *s = src8 + (row * w) + x1; | ||
542 | func(d, s, x2 - x1); | ||
543 | } | ||
544 | free(src8); | ||
545 | } | ||
546 | else if (dc->clip.mask) | ||
547 | { | ||
548 | RGBA_Gfx_Func func; | ||
549 | DATA8 *src8, *mask; | ||
550 | DATA32 *buf, *ptr, *buf_ptr; | ||
551 | RGBA_Image *im = dc->clip.mask; | ||
552 | int row; | ||
553 | |||
554 | buf = alloca(sizeof(DATA32) * w * h); | ||
555 | |||
556 | // Adjust clipping info | ||
557 | if (EINA_UNLIKELY((x + x1) < dc->clip.mask_x)) | ||
558 | x1 = dc->clip.mask_x - x; | ||
559 | if (EINA_UNLIKELY((y + y1) < dc->clip.mask_y)) | ||
560 | y1 = dc->clip.mask_y - y; | ||
561 | if (EINA_UNLIKELY((x + x2) > (int)(x + x1 + im->cache_entry.w))) | ||
562 | x2 = x1 + im->cache_entry.w; | ||
563 | if (EINA_UNLIKELY((y + y2) > (int)(y + y1 + im->cache_entry.h))) | ||
564 | y2 = y1 + im->cache_entry.h; | ||
565 | |||
566 | // Step 1: alpha glyph drawing | ||
567 | src8 = evas_common_font_glyph_uncompress(fg, NULL, NULL); | ||
568 | if (!src8) return; | ||
569 | |||
570 | // Step 2: color blending to buffer | ||
571 | func = evas_common_gfx_func_composite_mask_color_span_get(col, dst_image->cache_entry.flags.alpha, 1, EVAS_RENDER_COPY); | ||
572 | for (row = y1; row < y2; row++) | ||
573 | { | ||
574 | buf_ptr = buf + (row * w) + x1; | ||
575 | DATA8 *s = src8 + (row * w) + x1; | ||
576 | func(NULL, s, col, buf_ptr, x2 - x1); | ||
577 | } | ||
578 | free(src8); | ||
579 | |||
580 | // Step 3: masking to destination | ||
581 | func = evas_common_gfx_func_composite_pixel_mask_span_get(im->cache_entry.flags.alpha, im->cache_entry.flags.alpha_sparse, dst_image->cache_entry.flags.alpha, dst_pitch, dc->render_op); | ||
582 | for (row = y1; row < y2; row++) | ||
583 | { | ||
584 | mask = im->image.data8 | ||
585 | + (y + row - dc->clip.mask_y) * im->cache_entry.w | ||
586 | + (x + x1 - dc->clip.mask_x); | ||
587 | |||
588 | ptr = dst + (x + x1) + ((y + row) * dst_pitch); | ||
589 | buf_ptr = buf + (row * w) + x1; | ||
590 | func(buf_ptr, mask, 0, ptr, w); | ||
591 | } | ||
592 | } | ||
593 | else | ||
594 | { | ||
595 | // build fast multiply + mask color tables to avoid compute. this works | ||
596 | // because of our very limited 4bit range of alpha values | ||
597 | for (i = 0; i <= 0xf; i++) | ||
598 | { | ||
599 | v = (i << 4) | i; | ||
600 | coltab[i] = MUL_SYM(v, col); | ||
601 | mtab[i] = 256 - (coltab[i] >> 24); | ||
602 | } | ||
603 | #ifdef BUILD_MMX | ||
604 | if (evas_common_cpu_has_feature(CPU_FEATURE_MMX)) | ||
605 | { | ||
606 | #define MMX 1 | ||
607 | #include "evas_font_compress_draw.c" | ||
608 | #undef MMX | ||
609 | } | ||
610 | else | ||
611 | #endif | ||
612 | |||
613 | #ifdef BUILD_NEON | ||
614 | if (evas_common_cpu_has_feature(CPU_FEATURE_NEON)) | ||
615 | { | ||
616 | #define NEON 1 | ||
617 | #include "evas_font_compress_draw.c" | ||
618 | #undef NEON | ||
619 | } | ||
620 | else | ||
621 | #endif | ||
622 | |||
623 | // Plain C | ||
624 | { | ||
625 | #include "evas_font_compress_draw.c" | ||
626 | } | ||
627 | } | ||
628 | } | ||
diff --git a/src/lib/evas/common/evas_font_draw.c b/src/lib/evas/common/evas_font_draw.c index 4bdecddafe..f40e9b50c8 100644 --- a/src/lib/evas/common/evas_font_draw.c +++ b/src/lib/evas/common/evas_font_draw.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #include "evas_common_private.h" | 1 | #include "evas_font_draw.h" |
2 | #include "evas_private.h" | 2 | #include "evas_private.h" |
3 | #include "evas_blend_private.h" | 3 | #include "evas_blend_private.h" |
4 | 4 | ||
@@ -6,6 +6,7 @@ | |||
6 | #include "evas_font_private.h" /* for Frame-Queuing support */ | 6 | #include "evas_font_private.h" /* for Frame-Queuing support */ |
7 | 7 | ||
8 | #include "evas_font_ot.h" | 8 | #include "evas_font_ot.h" |
9 | #include "draw.h" | ||
9 | 10 | ||
10 | #ifdef EVAS_CSERVE2 | 11 | #ifdef EVAS_CSERVE2 |
11 | #include "../cserve2/evas_cs2_private.h" | 12 | #include "../cserve2/evas_cs2_private.h" |
@@ -507,3 +508,154 @@ evas_common_font_draw_prepare_cutout(Cutout_Rects **reuse, RGBA_Image *dst, RGBA | |||
507 | return EINA_TRUE; | 508 | return EINA_TRUE; |
508 | } | 509 | } |
509 | 510 | ||
511 | // this draws a compressed font glyph and decompresses on the fly as it | ||
512 | // draws, saving memory bandwidth and providing speedups | ||
513 | EAPI void | ||
514 | evas_common_font_glyph_draw(RGBA_Font_Glyph *fg, | ||
515 | RGBA_Draw_Context *dc, | ||
516 | RGBA_Image *dst_image, int dst_pitch, | ||
517 | int dx, int dy, int dw, int dh, int cx, int cy, int cw, int ch) | ||
518 | { | ||
519 | RGBA_Font_Glyph_Out *fgo = fg->glyph_out; | ||
520 | int x, y, w, h, x1, x2, y1, y2, i, *iptr; | ||
521 | DATA32 *dst = dst_image->image.data; | ||
522 | DATA32 coltab[16], col; | ||
523 | DATA16 mtab[16], v; | ||
524 | |||
525 | // FIXME: Use dw, dh for scaling glyphs... | ||
526 | (void) dw; | ||
527 | (void) dh; | ||
528 | x = dx; | ||
529 | y = dy; | ||
530 | w = fgo->bitmap.width; h = fgo->bitmap.rows; | ||
531 | // skip if totally clipped out | ||
532 | if ((y >= (cy + ch)) || ((y + h) <= cy) || | ||
533 | (x >= (cx + cw)) || ((x + w) <= cx)) return; | ||
534 | // figure y1/y2 limit range | ||
535 | y1 = 0; y2 = h; | ||
536 | if ((y + y1) < cy) y1 = cy - y; | ||
537 | if ((y + y2) > (cy + ch)) y2 = cy + ch - y; | ||
538 | // figure x1/x2 limit range | ||
539 | x1 = 0; x2 = w; | ||
540 | if ((x + x1) < cx) x1 = cx - x; | ||
541 | if ((x + x2) > (cx + cw)) x2 = cx + cw - x; | ||
542 | col = dc->col.col; | ||
543 | if (dst_image->cache_entry.space == EVAS_COLORSPACE_GRY8) | ||
544 | { | ||
545 | // FIXME: Font draw not optimized for Alpha targets! SLOW! | ||
546 | // This is not pretty :) | ||
547 | |||
548 | DATA8 *src8, *dst8; | ||
549 | Draw_Func_Alpha func; | ||
550 | int row; | ||
551 | |||
552 | if (EINA_UNLIKELY(x < 0)) | ||
553 | { | ||
554 | x1 += (-x); | ||
555 | x = 0; | ||
556 | if ((x2 - x1) <= 0) return; | ||
557 | } | ||
558 | if (EINA_UNLIKELY(y < 0)) | ||
559 | { | ||
560 | y1 += (-y); | ||
561 | y = 0; | ||
562 | if ((y2 - y1) <= 0) return; | ||
563 | } | ||
564 | |||
565 | dst8 = dst_image->image.data8 + x + (y * dst_pitch); | ||
566 | func = efl_draw_alpha_func_get(dc->render_op, EINA_FALSE); | ||
567 | src8 = evas_common_font_glyph_uncompress(fg, NULL, NULL); | ||
568 | if (!src8) return; | ||
569 | |||
570 | for (row = y1; row < y2; row++) | ||
571 | { | ||
572 | DATA8 *d = dst8 + ((row - y1) * dst_pitch); | ||
573 | DATA8 *s = src8 + (row * w) + x1; | ||
574 | func(d, s, x2 - x1); | ||
575 | } | ||
576 | free(src8); | ||
577 | } | ||
578 | else if (dc->clip.mask) | ||
579 | { | ||
580 | RGBA_Gfx_Func func; | ||
581 | DATA8 *src8, *mask; | ||
582 | DATA32 *buf, *ptr, *buf_ptr; | ||
583 | RGBA_Image *im = dc->clip.mask; | ||
584 | int row; | ||
585 | |||
586 | buf = alloca(sizeof(DATA32) * w * h); | ||
587 | |||
588 | // Adjust clipping info | ||
589 | if (EINA_UNLIKELY((x + x1) < dc->clip.mask_x)) | ||
590 | x1 = dc->clip.mask_x - x; | ||
591 | if (EINA_UNLIKELY((y + y1) < dc->clip.mask_y)) | ||
592 | y1 = dc->clip.mask_y - y; | ||
593 | if (EINA_UNLIKELY((x + x2) > (int)(x + x1 + im->cache_entry.w))) | ||
594 | x2 = x1 + im->cache_entry.w; | ||
595 | if (EINA_UNLIKELY((y + y2) > (int)(y + y1 + im->cache_entry.h))) | ||
596 | y2 = y1 + im->cache_entry.h; | ||
597 | |||
598 | // Step 1: alpha glyph drawing | ||
599 | src8 = evas_common_font_glyph_uncompress(fg, NULL, NULL); | ||
600 | if (!src8) return; | ||
601 | |||
602 | // Step 2: color blending to buffer | ||
603 | func = evas_common_gfx_func_composite_mask_color_span_get(col, dst_image->cache_entry.flags.alpha, 1, EVAS_RENDER_COPY); | ||
604 | for (row = y1; row < y2; row++) | ||
605 | { | ||
606 | buf_ptr = buf + (row * w) + x1; | ||
607 | DATA8 *s = src8 + (row * w) + x1; | ||
608 | func(NULL, s, col, buf_ptr, x2 - x1); | ||
609 | } | ||
610 | free(src8); | ||
611 | |||
612 | // Step 3: masking to destination | ||
613 | func = evas_common_gfx_func_composite_pixel_mask_span_get(im->cache_entry.flags.alpha, im->cache_entry.flags.alpha_sparse, dst_image->cache_entry.flags.alpha, dst_pitch, dc->render_op); | ||
614 | for (row = y1; row < y2; row++) | ||
615 | { | ||
616 | mask = im->image.data8 | ||
617 | + (y + row - dc->clip.mask_y) * im->cache_entry.w | ||
618 | + (x + x1 - dc->clip.mask_x); | ||
619 | |||
620 | ptr = dst + (x + x1) + ((y + row) * dst_pitch); | ||
621 | buf_ptr = buf + (row * w) + x1; | ||
622 | func(buf_ptr, mask, 0, ptr, w); | ||
623 | } | ||
624 | } | ||
625 | else | ||
626 | { | ||
627 | // build fast multiply + mask color tables to avoid compute. this works | ||
628 | // because of our very limited 4bit range of alpha values | ||
629 | for (i = 0; i <= 0xf; i++) | ||
630 | { | ||
631 | v = (i << 4) | i; | ||
632 | coltab[i] = MUL_SYM(v, col); | ||
633 | mtab[i] = 256 - (coltab[i] >> 24); | ||
634 | } | ||
635 | #ifdef BUILD_MMX | ||
636 | if (evas_common_cpu_has_feature(CPU_FEATURE_MMX)) | ||
637 | { | ||
638 | #define MMX 1 | ||
639 | #include "evas_font_compress_draw.c" | ||
640 | #undef MMX | ||
641 | } | ||
642 | else | ||
643 | #endif | ||
644 | |||
645 | #ifdef BUILD_NEON | ||
646 | if (evas_common_cpu_has_feature(CPU_FEATURE_NEON)) | ||
647 | { | ||
648 | #define NEON 1 | ||
649 | #include "evas_font_compress_draw.c" | ||
650 | #undef NEON | ||
651 | } | ||
652 | else | ||
653 | #endif | ||
654 | |||
655 | // Plain C | ||
656 | { | ||
657 | #include "evas_font_compress_draw.c" | ||
658 | } | ||
659 | } | ||
660 | } | ||
661 | |||
diff --git a/src/lib/evas/common/evas_font_draw.h b/src/lib/evas/common/evas_font_draw.h new file mode 100644 index 0000000000..c0b5e8edae --- /dev/null +++ b/src/lib/evas/common/evas_font_draw.h | |||
@@ -0,0 +1,18 @@ | |||
1 | #ifndef _EVAS_FONT_DRAW_H | ||
2 | #define _EVAS_FONT_DRAW_ | ||
3 | |||
4 | #include "evas_common_private.h" | ||
5 | |||
6 | /* draw */ | ||
7 | typedef Eina_Bool (*Evas_Common_Font_Draw_Cb)(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, Evas_Glyph_Array *glyphs, RGBA_Gfx_Func func, int ext_x, int ext_y, int ext_w, int ext_h, int im_w, int im_h); | ||
8 | |||
9 | EAPI Eina_Bool evas_common_font_draw_cb (RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, Evas_Glyph_Array *glyphs, Evas_Common_Font_Draw_Cb cb); | ||
10 | EAPI void evas_common_font_draw (RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, Evas_Glyph_Array *glyphs); | ||
11 | EAPI Eina_Bool evas_common_font_rgba_draw (RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, Evas_Glyph_Array *glyphs, RGBA_Gfx_Func func, int ext_x, int ext_y, int ext_w, int ext_h, int im_w, int im_h); | ||
12 | EAPI void evas_common_font_draw_init (void); | ||
13 | EAPI void evas_common_font_draw_prepare (Evas_Text_Props *text_props); | ||
14 | EAPI void evas_common_font_draw_do (const Cutout_Rects *reuse, const Eina_Rectangle *clip, RGBA_Gfx_Func func, RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, const Evas_Text_Props *text_props); | ||
15 | EAPI Eina_Bool evas_common_font_draw_prepare_cutout (Cutout_Rects **reuse, RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Gfx_Func *func); | ||
16 | EAPI void evas_common_font_glyph_draw (RGBA_Font_Glyph *fg, RGBA_Draw_Context *dc, RGBA_Image *dst, int dst_pitch, int dx, int dy, int dw, int dh, int cx, int cy, int cw, int ch); | ||
17 | |||
18 | #endif /* _EVAS_FONT_DRAW_H */ \ No newline at end of file | ||
diff --git a/src/lib/evas/common/evas_font_load.c b/src/lib/evas/common/evas_font_load.c index dfe94e9fb1..19baadc46f 100644 --- a/src/lib/evas/common/evas_font_load.c +++ b/src/lib/evas/common/evas_font_load.c | |||
@@ -3,9 +3,7 @@ | |||
3 | #endif | 3 | #endif |
4 | 4 | ||
5 | #include <assert.h> | 5 | #include <assert.h> |
6 | 6 | #include "evas_font_ot.h" | |
7 | #include "evas_common_private.h" | ||
8 | #include "evas_private.h" | ||
9 | 7 | ||
10 | #ifdef USE_HARFBUZZ | 8 | #ifdef USE_HARFBUZZ |
11 | # include <hb.h> | 9 | # include <hb.h> |
@@ -13,7 +11,7 @@ | |||
13 | 11 | ||
14 | #include "evas_font_private.h" /* for Frame-Queuing support */ | 12 | #include "evas_font_private.h" /* for Frame-Queuing support */ |
15 | 13 | ||
16 | #include <ft2build.h> | 14 | #include <ft2build.h> |
17 | #include FT_TRUETYPE_TABLES_H /* Freetype2 OS/2 font table. */ | 15 | #include FT_TRUETYPE_TABLES_H /* Freetype2 OS/2 font table. */ |
18 | 16 | ||
19 | #ifdef EVAS_CSERVE2 | 17 | #ifdef EVAS_CSERVE2 |
@@ -142,7 +140,7 @@ evas_common_font_dpi_set(int dpi_h, int dpi_v) | |||
142 | EAPI RGBA_Font_Source * | 140 | EAPI RGBA_Font_Source * |
143 | evas_common_font_source_memory_load(const char *name, const void *data, int data_size) | 141 | evas_common_font_source_memory_load(const char *name, const void *data, int data_size) |
144 | { | 142 | { |
145 | int error; | 143 | int error; |
146 | RGBA_Font_Source *fs; | 144 | RGBA_Font_Source *fs; |
147 | 145 | ||
148 | assert(name != NULL); | 146 | assert(name != NULL); |
@@ -218,7 +216,7 @@ evas_common_font_source_reload(RGBA_Font_Source *fs) | |||
218 | if (fs->data) | 216 | if (fs->data) |
219 | { | 217 | { |
220 | int error; | 218 | int error; |
221 | 219 | ||
222 | FTLOCK(); | 220 | FTLOCK(); |
223 | error = FT_New_Memory_Face(evas_ft_lib, fs->data, fs->data_size, 0, &(fs->ft.face)); | 221 | error = FT_New_Memory_Face(evas_ft_lib, fs->data, fs->data_size, 0, &(fs->ft.face)); |
224 | FTUNLOCK(); | 222 | FTUNLOCK(); |
@@ -316,8 +314,8 @@ _evas_common_font_double_int_cmp(const int *key1, EINA_UNUSED int key1_length, | |||
316 | static int | 314 | static int |
317 | _evas_common_font_double_int_hash(const unsigned int key[2], int key_length) | 315 | _evas_common_font_double_int_hash(const unsigned int key[2], int key_length) |
318 | { | 316 | { |
319 | return | 317 | return |
320 | eina_hash_int32(&key[0], key_length) ^ | 318 | eina_hash_int32(&key[0], key_length) ^ |
321 | eina_hash_int32(&key[1], key_length); | 319 | eina_hash_int32(&key[1], key_length); |
322 | } | 320 | } |
323 | 321 | ||
@@ -336,19 +334,17 @@ EAPI RGBA_Font_Int * | |||
336 | evas_common_font_int_memory_load(const char *source, const char *name, int size, const void *data, int data_size, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable) | 334 | evas_common_font_int_memory_load(const char *source, const char *name, int size, const void *data, int data_size, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable) |
337 | { | 335 | { |
338 | RGBA_Font_Int *fi; | 336 | RGBA_Font_Int *fi; |
339 | char *fake_name; | 337 | char fake_name[PATH_MAX]; |
340 | 338 | ||
341 | fake_name = evas_file_path_join(source, name); | 339 | eina_file_path_join(fake_name, sizeof(fake_name), source, name); |
342 | fi = evas_common_font_int_find(fake_name, size, wanted_rend, bitmap_scalable); | 340 | fi = evas_common_font_int_find(fake_name, size, wanted_rend, bitmap_scalable); |
343 | if (fi) | 341 | if (fi) |
344 | { | 342 | { |
345 | free(fake_name); | ||
346 | return fi; | 343 | return fi; |
347 | } | 344 | } |
348 | fi = calloc(1, sizeof(RGBA_Font_Int)); | 345 | fi = calloc(1, sizeof(RGBA_Font_Int)); |
349 | if (!fi) | 346 | if (!fi) |
350 | { | 347 | { |
351 | free(fake_name); | ||
352 | return NULL; | 348 | return NULL; |
353 | } | 349 | } |
354 | fi->src = evas_common_font_source_find(fake_name); | 350 | fi->src = evas_common_font_source_find(fake_name); |
@@ -356,9 +352,8 @@ evas_common_font_int_memory_load(const char *source, const char *name, int size, | |||
356 | fi->src = evas_common_font_source_memory_load(fake_name, data, data_size); | 352 | fi->src = evas_common_font_source_memory_load(fake_name, data, data_size); |
357 | if (!fi->src) | 353 | if (!fi->src) |
358 | { | 354 | { |
359 | free(fi); | 355 | free(fi); |
360 | free(fake_name); | 356 | return NULL; |
361 | return NULL; | ||
362 | } | 357 | } |
363 | fi->size = size; | 358 | fi->size = size; |
364 | fi->bitmap_scalable = bitmap_scalable; | 359 | fi->bitmap_scalable = bitmap_scalable; |
@@ -380,10 +375,19 @@ evas_common_font_int_memory_load(const char *source, const char *name, int size, | |||
380 | } | 375 | } |
381 | } | 376 | } |
382 | #endif | 377 | #endif |
383 | free(fake_name); | ||
384 | return fi; | 378 | return fi; |
385 | } | 379 | } |
386 | 380 | ||
381 | static int | ||
382 | _file_path_is_file_helper(const char *path) | ||
383 | { | ||
384 | struct stat st; | ||
385 | |||
386 | if (stat(path, &st) == -1) return 0; | ||
387 | if (S_ISREG(st.st_mode)) return 1; | ||
388 | return 0; | ||
389 | } | ||
390 | |||
387 | EAPI RGBA_Font_Int * | 391 | EAPI RGBA_Font_Int * |
388 | evas_common_font_int_load(const char *name, int size, | 392 | evas_common_font_int_load(const char *name, int size, |
389 | Font_Rend_Flags wanted_rend, | 393 | Font_Rend_Flags wanted_rend, |
@@ -396,7 +400,7 @@ evas_common_font_int_load(const char *name, int size, | |||
396 | fi = calloc(1, sizeof(RGBA_Font_Int)); | 400 | fi = calloc(1, sizeof(RGBA_Font_Int)); |
397 | if (!fi) return NULL; | 401 | if (!fi) return NULL; |
398 | fi->src = evas_common_font_source_find(name); | 402 | fi->src = evas_common_font_source_find(name); |
399 | if (!fi->src && evas_file_path_is_file(name)) | 403 | if (!fi->src && _file_path_is_file_helper(name)) |
400 | fi->src = evas_common_font_source_load(name); | 404 | fi->src = evas_common_font_source_load(name); |
401 | 405 | ||
402 | if (!fi->src) | 406 | if (!fi->src) |
@@ -466,7 +470,7 @@ evas_common_font_int_load_complete(RGBA_Font_Int *fi) | |||
466 | for (i = 0; i < fi->src->ft.face->num_fixed_sizes; i++) | 470 | for (i = 0; i < fi->src->ft.face->num_fixed_sizes; i++) |
467 | { | 471 | { |
468 | int s, cd; | 472 | int s, cd; |
469 | 473 | ||
470 | s = fi->src->ft.face->available_sizes[i].size; | 474 | s = fi->src->ft.face->available_sizes[i].size; |
471 | cd = chosen_size - fi->real_size; | 475 | cd = chosen_size - fi->real_size; |
472 | if (cd < 0) cd = -cd; | 476 | if (cd < 0) cd = -cd; |
@@ -853,7 +857,7 @@ void | |||
853 | evas_common_font_int_promote(RGBA_Font_Int *fi EINA_UNUSED) | 857 | evas_common_font_int_promote(RGBA_Font_Int *fi EINA_UNUSED) |
854 | { | 858 | { |
855 | return; | 859 | return; |
856 | /* unused - keep for reference | 860 | /* unused - keep for reference |
857 | if (fonts_use_lru == (Eina_Inlist *)fi) return; | 861 | if (fonts_use_lru == (Eina_Inlist *)fi) return; |
858 | if (!fi->inuse) return; | 862 | if (!fi->inuse) return; |
859 | fonts_use_lru = eina_inlist_remove(fonts_use_lru, EINA_INLIST_GET(fi)); | 863 | fonts_use_lru = eina_inlist_remove(fonts_use_lru, EINA_INLIST_GET(fi)); |
@@ -871,7 +875,7 @@ void | |||
871 | evas_common_font_int_use_trim(void) | 875 | evas_common_font_int_use_trim(void) |
872 | { | 876 | { |
873 | return; | 877 | return; |
874 | /* unused - keep for reference | 878 | /* unused - keep for reference |
875 | Eina_Inlist *l; | 879 | Eina_Inlist *l; |
876 | 880 | ||
877 | if (fonts_use_usage <= (font_cache << 1)) return; | 881 | if (fonts_use_usage <= (font_cache << 1)) return; |
@@ -894,7 +898,7 @@ void | |||
894 | evas_common_font_int_unload(RGBA_Font_Int *fi EINA_UNUSED) | 898 | evas_common_font_int_unload(RGBA_Font_Int *fi EINA_UNUSED) |
895 | { | 899 | { |
896 | return; | 900 | return; |
897 | /* unused - keep for reference | 901 | /* unused - keep for reference |
898 | if (!fi->src->ft.face) return; | 902 | if (!fi->src->ft.face) return; |
899 | _evas_common_font_int_clear(fi); | 903 | _evas_common_font_int_clear(fi); |
900 | FT_Done_Size(fi->ft.size); | 904 | FT_Done_Size(fi->ft.size); |
@@ -909,7 +913,7 @@ evas_common_font_int_reload(RGBA_Font_Int *fi) | |||
909 | if (fi->src->ft.face) return; | 913 | if (fi->src->ft.face) return; |
910 | evas_common_font_source_load_complete(fi->src); | 914 | evas_common_font_source_load_complete(fi->src); |
911 | return; | 915 | return; |
912 | /* unused - keep for reference | 916 | /* unused - keep for reference |
913 | evas_common_font_source_reload(fi->src); | 917 | evas_common_font_source_reload(fi->src); |
914 | evas_common_font_int_load_complete(fi); | 918 | evas_common_font_int_load_complete(fi); |
915 | */ | 919 | */ |
@@ -947,7 +951,7 @@ evas_common_font_flush(void) | |||
947 | while (font_cache_usage > font_cache) | 951 | while (font_cache_usage > font_cache) |
948 | { | 952 | { |
949 | int pfont_cache_usage; | 953 | int pfont_cache_usage; |
950 | 954 | ||
951 | pfont_cache_usage = font_cache_usage; | 955 | pfont_cache_usage = font_cache_usage; |
952 | evas_common_font_flush_last(); | 956 | evas_common_font_flush_last(); |
953 | if (pfont_cache_usage == font_cache_usage) break; | 957 | if (pfont_cache_usage == font_cache_usage) break; |
diff --git a/src/lib/evas/common/evas_font_main.c b/src/lib/evas/common/evas_font_main.c index c156bd7477..ef2c588668 100644 --- a/src/lib/evas/common/evas_font_main.c +++ b/src/lib/evas/common/evas_font_main.c | |||
@@ -1,12 +1,3 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include "config.h" | ||
3 | #endif | ||
4 | |||
5 | #include <assert.h> | ||
6 | |||
7 | #include "evas_common_private.h" | ||
8 | #include "evas_private.h" | ||
9 | |||
10 | #include "evas_font_private.h" | 1 | #include "evas_font_private.h" |
11 | 2 | ||
12 | #ifdef EVAS_CSERVE2 | 3 | #ifdef EVAS_CSERVE2 |
@@ -25,6 +16,8 @@ LK(lock_font_draw); // for freetype2 API calls | |||
25 | LK(lock_bidi); // for evas bidi internal usage. | 16 | LK(lock_bidi); // for evas bidi internal usage. |
26 | LK(lock_ot); // for evas bidi internal usage. | 17 | LK(lock_ot); // for evas bidi internal usage. |
27 | 18 | ||
19 | int _evas_font_log_dom_global = -1; | ||
20 | |||
28 | EAPI void | 21 | EAPI void |
29 | evas_common_font_init(void) | 22 | evas_common_font_init(void) |
30 | { | 23 | { |
@@ -36,6 +29,12 @@ evas_common_font_init(void) | |||
36 | #else | 29 | #else |
37 | 35; | 30 | 35; |
38 | #endif | 31 | #endif |
32 | _evas_font_log_dom_global = eina_log_domain_register | ||
33 | ("evas_font_main", EVAS_FONT_DEFAULT_LOG_COLOR); | ||
34 | if (_evas_font_log_dom_global < 0) | ||
35 | { | ||
36 | EINA_LOG_ERR("Can not create a module log domain."); | ||
37 | } | ||
39 | 38 | ||
40 | initialised++; | 39 | initialised++; |
41 | if (initialised != 1) return; | 40 | if (initialised != 1) return; |
@@ -77,6 +76,7 @@ evas_common_font_shutdown(void) | |||
77 | LKD(lock_font_draw); | 76 | LKD(lock_font_draw); |
78 | LKD(lock_bidi); | 77 | LKD(lock_bidi); |
79 | LKD(lock_ot); | 78 | LKD(lock_ot); |
79 | eina_log_domain_unregister(_evas_font_log_dom_global); | ||
80 | } | 80 | } |
81 | 81 | ||
82 | EAPI void | 82 | EAPI void |
@@ -681,7 +681,7 @@ evas_common_font_int_cache_glyph_render(RGBA_Font_Glyph *fg) | |||
681 | fg->glyph_out->bitmap.pitch = fbg->bitmap.pitch; | 681 | fg->glyph_out->bitmap.pitch = fbg->bitmap.pitch; |
682 | fg->glyph_out->bitmap.buffer = fbg->bitmap.buffer; | 682 | fg->glyph_out->bitmap.buffer = fbg->bitmap.buffer; |
683 | fg->glyph_out->bitmap.rle_alloc = EINA_TRUE; | 683 | fg->glyph_out->bitmap.rle_alloc = EINA_TRUE; |
684 | 684 | ||
685 | /* This '+ 100' is just an estimation of how much memory freetype will use | 685 | /* This '+ 100' is just an estimation of how much memory freetype will use |
686 | * on it's size. This value is not really used anywhere in code - it's | 686 | * on it's size. This value is not really used anywhere in code - it's |
687 | * only for statistics. */ | 687 | * only for statistics. */ |
@@ -709,7 +709,7 @@ evas_common_font_int_cache_glyph_render(RGBA_Font_Glyph *fg) | |||
709 | fg->glyph_out->rle = NULL; | 709 | fg->glyph_out->rle = NULL; |
710 | fg->glyph_out->bitmap.rle_alloc = EINA_FALSE; | 710 | fg->glyph_out->bitmap.rle_alloc = EINA_FALSE; |
711 | } | 711 | } |
712 | 712 | ||
713 | return EINA_TRUE; | 713 | return EINA_TRUE; |
714 | } | 714 | } |
715 | 715 | ||
@@ -805,11 +805,11 @@ evas_common_get_char_index(RGBA_Font_Int* fi, Eina_Unicode gl) | |||
805 | // codepoints with a guess that bitmap font is playing the old | 805 | // codepoints with a guess that bitmap font is playing the old |
806 | // game of putting line drawing chars in specific ranges | 806 | // game of putting line drawing chars in specific ranges |
807 | max = sizeof(mapfix) / (sizeof(mapfix[0]) * 2); | 807 | max = sizeof(mapfix) / (sizeof(mapfix[0]) * 2); |
808 | i = (min + max) / 2; | 808 | i = (min + max) / 2; |
809 | for (;;) | 809 | for (;;) |
810 | { | 810 | { |
811 | unsigned short v; | 811 | unsigned short v; |
812 | 812 | ||
813 | v = mapfix[i << 1]; | 813 | v = mapfix[i << 1]; |
814 | if (gl == v) | 814 | if (gl == v) |
815 | { | 815 | { |
@@ -867,7 +867,7 @@ evas_common_font_glyph_search(RGBA_Font *fn, RGBA_Font_Int **fi_ret, Eina_Unicod | |||
867 | fi = l->data; | 867 | fi = l->data; |
868 | 868 | ||
869 | #if 0 /* FIXME: charmap user is disabled and use a deprecated data type. */ | 869 | #if 0 /* FIXME: charmap user is disabled and use a deprecated data type. */ |
870 | /* | 870 | /* |
871 | if (fi->src->charmap) // Charmap loaded, FI/FS blank | 871 | if (fi->src->charmap) // Charmap loaded, FI/FS blank |
872 | { | 872 | { |
873 | idx = evas_array_hash_search(fi->src->charmap, gl); | 873 | idx = evas_array_hash_search(fi->src->charmap, gl); |
diff --git a/src/lib/evas/common/evas_font_ot.c b/src/lib/evas/common/evas_font_ot.c index 230abd68eb..47c624c99a 100644 --- a/src/lib/evas/common/evas_font_ot.c +++ b/src/lib/evas/common/evas_font_ot.c | |||
@@ -1,12 +1,10 @@ | |||
1 | #include "evas_common_private.h" | 1 | #include "evas_font_private.h" |
2 | 2 | ||
3 | #ifdef USE_HARFBUZZ | 3 | #ifdef USE_HARFBUZZ |
4 | # include <hb.h> | 4 | # include <hb.h> |
5 | # include <hb-ft.h> | 5 | # include <hb-ft.h> |
6 | #endif | 6 | #endif |
7 | 7 | ||
8 | #include "evas_font_private.h" | ||
9 | |||
10 | #ifdef USE_HARFBUZZ | 8 | #ifdef USE_HARFBUZZ |
11 | static const hb_script_t | 9 | static const hb_script_t |
12 | _evas_script_to_harfbuzz[] = | 10 | _evas_script_to_harfbuzz[] = |
diff --git a/src/lib/evas/common/evas_font_ot.h b/src/lib/evas/common/evas_font_ot.h index fe263db759..e38e758b00 100644 --- a/src/lib/evas/common/evas_font_ot.h +++ b/src/lib/evas/common/evas_font_ot.h | |||
@@ -1,6 +1,10 @@ | |||
1 | #ifndef _EVAS_FONT_OT_H | 1 | #ifndef _EVAS_FONT_OT_H |
2 | # define _EVAS_FONT_OT_H | 2 | # define _EVAS_FONT_OT_H |
3 | 3 | ||
4 | #ifdef HAVE_CONFIG_H | ||
5 | # include "config.h" | ||
6 | #endif | ||
7 | |||
4 | # ifdef HAVE_HARFBUZZ | 8 | # ifdef HAVE_HARFBUZZ |
5 | # define OT_SUPPORT | 9 | # define OT_SUPPORT |
6 | # define USE_HARFBUZZ | 10 | # define USE_HARFBUZZ |
@@ -17,8 +21,8 @@ typedef void *Evas_Font_OT_Info; | |||
17 | struct _Evas_Font_OT_Info | 21 | struct _Evas_Font_OT_Info |
18 | { | 22 | { |
19 | size_t source_cluster; | 23 | size_t source_cluster; |
20 | Evas_Coord x_offset; | 24 | int x_offset; |
21 | Evas_Coord y_offset; | 25 | int y_offset; |
22 | }; | 26 | }; |
23 | # endif | 27 | # endif |
24 | 28 | ||
@@ -28,7 +32,8 @@ struct _Evas_Font_OT_Info | |||
28 | # define EVAS_FONT_OT_POS_GET(a) ((a).source_cluster) | 32 | # define EVAS_FONT_OT_POS_GET(a) ((a).source_cluster) |
29 | # endif | 33 | # endif |
30 | 34 | ||
31 | # include "evas_text_utils.h" | 35 | #include "evas_font.h" |
36 | |||
32 | EAPI int | 37 | EAPI int |
33 | evas_common_font_ot_cluster_size_get(const Evas_Text_Props *props, size_t char_index); | 38 | evas_common_font_ot_cluster_size_get(const Evas_Text_Props *props, size_t char_index); |
34 | 39 | ||
diff --git a/src/lib/evas/common/evas_font_private.h b/src/lib/evas/common/evas_font_private.h index 904a01e4bf..213ef7f96f 100644 --- a/src/lib/evas/common/evas_font_private.h +++ b/src/lib/evas/common/evas_font_private.h | |||
@@ -1,10 +1,50 @@ | |||
1 | #ifndef _EVAS_FONT_PRIVATE_H | 1 | #ifndef _EVAS_FONT_PRIVATE_H |
2 | # define _EVAS_FONT_PRIVATE_H | 2 | #define _EVAS_FONT_PRIVATE_H |
3 | #include "evas_font_ot.h" | 3 | |
4 | #include "evas_font.h" | ||
5 | |||
6 | /* macros needed to log message through eina_log */ | ||
7 | extern EAPI int _evas_font_log_dom_global; | ||
8 | #ifdef _EVAS_FONT_DEFAULT_LOG_DOM | ||
9 | # undef _EVAS_FONT_DEFAULT_LOG_DOM | ||
10 | #endif | ||
11 | #define _EVAS_FONT_DEFAULT_LOG_DOM _evas_font_log_dom_global | ||
12 | |||
13 | #ifdef EVAS_FONT_DEFAULT_LOG_COLOR | ||
14 | # undef EVAS_FONT_DEFAULT_LOG_COLOR | ||
15 | #endif | ||
16 | #define EVAS_FONT_DEFAULT_LOG_COLOR EINA_COLOR_BLUE | ||
17 | |||
18 | #ifdef ERR | ||
19 | # undef ERR | ||
20 | #endif | ||
21 | #define ERR(...) EINA_LOG_DOM_ERR(_EVAS_FONT_DEFAULT_LOG_DOM, __VA_ARGS__) | ||
22 | |||
23 | #ifdef DBG | ||
24 | # undef DBG | ||
25 | #endif | ||
26 | #define DBG(...) EINA_LOG_DOM_DBG(_EVAS_FONT_DEFAULT_LOG_DOM, __VA_ARGS__) | ||
27 | |||
28 | #ifdef INF | ||
29 | # undef INF | ||
30 | #endif | ||
31 | #define INF(...) EINA_LOG_DOM_INFO(_EVAS_FONT_DEFAULT_LOG_DOM, __VA_ARGS__) | ||
32 | |||
33 | #ifdef WRN | ||
34 | # undef WRN | ||
35 | #endif | ||
36 | #define WRN(...) EINA_LOG_DOM_WARN(_EVAS_FONT_DEFAULT_LOG_DOM, __VA_ARGS__) | ||
37 | |||
38 | #ifdef CRI | ||
39 | # undef CRI | ||
40 | #endif | ||
41 | #define CRI(...) EINA_LOG_DOM_CRIT(_EVAS_FONT_DEFAULT_LOG_DOM, __VA_ARGS__) | ||
42 | |||
4 | 43 | ||
5 | extern LK(lock_font_draw); // for freetype2 API calls | 44 | extern LK(lock_font_draw); // for freetype2 API calls |
6 | extern LK(lock_bidi); // for fribidi API calls | 45 | extern LK(lock_bidi); // for fribidi API calls |
7 | extern LK(lock_ot); // for harfbuzz calls | 46 | extern LK(lock_ot); // for harfbuzz calls |
47 | |||
8 | # define FTLOCK() LKL(lock_font_draw) | 48 | # define FTLOCK() LKL(lock_font_draw) |
9 | # define FTUNLOCK() LKU(lock_font_draw) | 49 | # define FTUNLOCK() LKU(lock_font_draw) |
10 | 50 | ||
diff --git a/src/lib/evas/common/evas_font_query.c b/src/lib/evas/common/evas_font_query.c index 0fd5bc1360..1ff0447963 100644 --- a/src/lib/evas/common/evas_font_query.c +++ b/src/lib/evas/common/evas_font_query.c | |||
@@ -1,7 +1,4 @@ | |||
1 | #include "evas_common_private.h" | ||
2 | #include "language/evas_bidi_utils.h" /*defines BIDI_SUPPORT if possible */ | ||
3 | #include "evas_font_private.h" /* for Frame-Queuing support */ | 1 | #include "evas_font_private.h" /* for Frame-Queuing support */ |
4 | #include "evas_font_ot.h" | ||
5 | 2 | ||
6 | 3 | ||
7 | /* FIXME: Check coverage according to the font and not by actually loading */ | 4 | /* FIXME: Check coverage according to the font and not by actually loading */ |
diff --git a/src/lib/evas/common/evas_text_utils.c b/src/lib/evas/common/evas_text_utils.c index 5c00c7fb54..93e5694609 100644 --- a/src/lib/evas/common/evas_text_utils.c +++ b/src/lib/evas/common/evas_text_utils.c | |||
@@ -1,8 +1,4 @@ | |||
1 | #include "evas_common_private.h" | ||
2 | #include "evas_font_private.h" | 1 | #include "evas_font_private.h" |
3 | #include "evas_text_utils.h" | ||
4 | #include "language/evas_bidi_utils.h" | ||
5 | #include "language/evas_language_utils.h" | ||
6 | 2 | ||
7 | #define PROPS_CHANGE(Props) Props->changed = EINA_TRUE; | 3 | #define PROPS_CHANGE(Props) Props->changed = EINA_TRUE; |
8 | 4 | ||
@@ -47,7 +43,7 @@ evas_common_text_props_content_ref(Evas_Text_Props *props) | |||
47 | return; | 43 | return; |
48 | 44 | ||
49 | props->info->refcount++; | 45 | props->info->refcount++; |
50 | if (props->font_instance) | 46 | if (props->font_instance) |
51 | ((RGBA_Font_Int *)props->font_instance)->references++; | 47 | ((RGBA_Font_Int *)props->font_instance)->references++; |
52 | } | 48 | } |
53 | 49 | ||
@@ -541,7 +537,7 @@ evas_common_text_props_content_create(void *_fi, const Eina_Unicode *text, | |||
541 | text_props->font_instance = fi; | 537 | text_props->font_instance = fi; |
542 | fi->references++; | 538 | fi->references++; |
543 | } | 539 | } |
544 | 540 | ||
545 | evas_common_font_int_reload(fi); | 541 | evas_common_font_int_reload(fi); |
546 | if (fi->src->current_size != fi->size) | 542 | if (fi->src->current_size != fi->size) |
547 | { | 543 | { |
diff --git a/src/lib/evas/common/evas_text_utils.h b/src/lib/evas/common/evas_text_utils.h index 2c49dcb73a..36039568fa 100644 --- a/src/lib/evas/common/evas_text_utils.h +++ b/src/lib/evas/common/evas_text_utils.h | |||
@@ -17,7 +17,6 @@ typedef enum | |||
17 | } Evas_Text_Props_Mode; | 17 | } Evas_Text_Props_Mode; |
18 | 18 | ||
19 | # include "evas_font_ot.h" | 19 | # include "evas_font_ot.h" |
20 | # include "language/evas_bidi_utils.h" | ||
21 | # include "language/evas_language_utils.h" | 20 | # include "language/evas_language_utils.h" |
22 | 21 | ||
23 | /* Used for showing "malformed" or missing chars */ | 22 | /* Used for showing "malformed" or missing chars */ |
@@ -126,7 +125,7 @@ struct _Evas_Font_Glyph_Info | |||
126 | // relative layout info... worry then. | 125 | // relative layout info... worry then. |
127 | Evas_Coord pen_after; // 4 | 126 | Evas_Coord pen_after; // 4 |
128 | short x_bear, y_bear, width; // 6 | 127 | short x_bear, y_bear, width; // 6 |
129 | #else | 128 | #else |
130 | Evas_Coord x_bear; // 4 | 129 | Evas_Coord x_bear; // 4 |
131 | /* This one is rarely used, only in draw, in which we already get the glyph | 130 | /* This one is rarely used, only in draw, in which we already get the glyph |
132 | * so it doesn't really save time. Leaving it here just so no one will | 131 | * so it doesn't really save time. Leaving it here just so no one will |
@@ -134,7 +133,7 @@ struct _Evas_Font_Glyph_Info | |||
134 | Evas_Coord y_bear; // 4 | 133 | Evas_Coord y_bear; // 4 |
135 | Evas_Coord width; // 4 | 134 | Evas_Coord width; // 4 |
136 | Evas_Coord pen_after; // 4 | 135 | Evas_Coord pen_after; // 4 |
137 | #endif | 136 | #endif |
138 | }; | 137 | }; |
139 | 138 | ||
140 | void | 139 | void |
diff --git a/src/lib/evas/include/evas_common_private.h b/src/lib/evas/include/evas_common_private.h index 12cda89d02..4f731d4e79 100644 --- a/src/lib/evas/include/evas_common_private.h +++ b/src/lib/evas/include/evas_common_private.h | |||
@@ -63,6 +63,8 @@ | |||
63 | 63 | ||
64 | #include "Evas_Internal.h" | 64 | #include "Evas_Internal.h" |
65 | 65 | ||
66 | #include "../common/evas_font.h" | ||
67 | |||
66 | #ifdef EAPI | 68 | #ifdef EAPI |
67 | # undef EAPI | 69 | # undef EAPI |
68 | #endif | 70 | #endif |
@@ -224,20 +226,6 @@ extern EAPI int _evas_log_dom_global; | |||
224 | # define THI(x) int x | 226 | # define THI(x) int x |
225 | # define TH_MAX 8 | 227 | # define TH_MAX 8 |
226 | 228 | ||
227 | #include <ft2build.h> | ||
228 | #include FT_FREETYPE_H | ||
229 | #include FT_GLYPH_H | ||
230 | #include FT_SIZES_H | ||
231 | #include FT_MODULE_H | ||
232 | |||
233 | #ifndef FT_HAS_COLOR | ||
234 | # define FT_HAS_COLOR(face) 0 | ||
235 | #endif | ||
236 | |||
237 | #ifndef FT_LOAD_COLOR | ||
238 | # define FT_LOAD_COLOR FT_LOAD_DEFAULT | ||
239 | #endif | ||
240 | |||
241 | #ifdef __GNUC__ | 229 | #ifdef __GNUC__ |
242 | # if __GNUC__ >= 4 | 230 | # if __GNUC__ >= 4 |
243 | // BROKEN in gcc 4 on amd64 | 231 | // BROKEN in gcc 4 on amd64 |
@@ -430,11 +418,6 @@ typedef struct _RGBA_Draw_Context RGBA_Draw_Context; | |||
430 | typedef struct _RGBA_Polygon_Point RGBA_Polygon_Point; | 418 | typedef struct _RGBA_Polygon_Point RGBA_Polygon_Point; |
431 | typedef struct _RGBA_Map_Point RGBA_Map_Point; | 419 | typedef struct _RGBA_Map_Point RGBA_Map_Point; |
432 | typedef struct _RGBA_Map RGBA_Map; | 420 | typedef struct _RGBA_Map RGBA_Map; |
433 | typedef struct _RGBA_Font RGBA_Font; | ||
434 | typedef struct _RGBA_Font_Int RGBA_Font_Int; | ||
435 | typedef struct _RGBA_Font_Source RGBA_Font_Source; | ||
436 | typedef struct _RGBA_Font_Glyph RGBA_Font_Glyph; | ||
437 | typedef struct _RGBA_Font_Glyph_Out RGBA_Font_Glyph_Out; | ||
438 | typedef struct _RGBA_Gfx_Compositor RGBA_Gfx_Compositor; | 421 | typedef struct _RGBA_Gfx_Compositor RGBA_Gfx_Compositor; |
439 | typedef struct _RGBA_Image_Data_Map RGBA_Image_Data_Map; | 422 | typedef struct _RGBA_Image_Data_Map RGBA_Image_Data_Map; |
440 | 423 | ||
@@ -478,6 +461,8 @@ typedef void (*Evas_Engine_Thread_Task_Cb)(void *engine_data, Image_Entry *ie, v | |||
478 | #include "../cache2/evas_cache2.h" | 461 | #include "../cache2/evas_cache2.h" |
479 | #endif | 462 | #endif |
480 | 463 | ||
464 | #include "../common/evas_font_draw.h" | ||
465 | |||
481 | /*****************************************************************************/ | 466 | /*****************************************************************************/ |
482 | 467 | ||
483 | typedef void (*Evas_Thread_Command_Cb)(void *data); | 468 | typedef void (*Evas_Thread_Command_Cb)(void *data); |
@@ -536,20 +521,6 @@ typedef enum _CPU_Features | |||
536 | CPU_FEATURE_SSE3 = (1 << 7) | 521 | CPU_FEATURE_SSE3 = (1 << 7) |
537 | } CPU_Features; | 522 | } CPU_Features; |
538 | 523 | ||
539 | typedef enum _Font_Hint_Flags | ||
540 | { | ||
541 | FONT_NO_HINT, | ||
542 | FONT_AUTO_HINT, | ||
543 | FONT_BYTECODE_HINT | ||
544 | } Font_Hint_Flags; | ||
545 | |||
546 | typedef enum _Font_Rend_Flags | ||
547 | { | ||
548 | FONT_REND_REGULAR = 0, | ||
549 | FONT_REND_SLANT = (1 << 0), | ||
550 | FONT_REND_WEIGHT = (1 << 1), | ||
551 | } Font_Rend_Flags; | ||
552 | |||
553 | /*****************************************************************************/ | 524 | /*****************************************************************************/ |
554 | 525 | ||
555 | struct _Image_Entry_Flags | 526 | struct _Image_Entry_Flags |
@@ -792,7 +763,6 @@ struct _RGBA_Draw_Context | |||
792 | 763 | ||
793 | #ifdef BUILD_PIPE_RENDER | 764 | #ifdef BUILD_PIPE_RENDER |
794 | #include "../common/evas_map_image.h" | 765 | #include "../common/evas_map_image.h" |
795 | #include "../common/evas_text_utils.h" | ||
796 | 766 | ||
797 | struct _RGBA_Pipe_Op | 767 | struct _RGBA_Pipe_Op |
798 | { | 768 | { |
@@ -947,146 +917,6 @@ struct _RGBA_Map | |||
947 | RGBA_Map_Point pts[1]; | 917 | RGBA_Map_Point pts[1]; |
948 | }; | 918 | }; |
949 | 919 | ||
950 | // for fonts... | ||
951 | ///// | ||
952 | typedef struct _Fash_Item_Index_Map Fash_Item_Index_Map; | ||
953 | typedef struct _Fash_Int_Map Fash_Int_Map; | ||
954 | typedef struct _Fash_Int_Map2 Fash_Int_Map2; | ||
955 | typedef struct _Fash_Int Fash_Int; | ||
956 | struct _Fash_Item_Index_Map | ||
957 | { | ||
958 | RGBA_Font_Int *fint; | ||
959 | int index; | ||
960 | }; | ||
961 | struct _Fash_Int_Map | ||
962 | { | ||
963 | Fash_Item_Index_Map item[256]; | ||
964 | }; | ||
965 | struct _Fash_Int_Map2 | ||
966 | { | ||
967 | Fash_Int_Map *bucket[256]; | ||
968 | }; | ||
969 | struct _Fash_Int | ||
970 | { | ||
971 | Fash_Int_Map2 *bucket[256]; | ||
972 | void (*freeme) (Fash_Int *fash); | ||
973 | }; | ||
974 | |||
975 | ///// | ||
976 | typedef struct _Fash_Glyph_Map Fash_Glyph_Map; | ||
977 | typedef struct _Fash_Glyph_Map2 Fash_Glyph_Map2; | ||
978 | typedef struct _Fash_Glyph Fash_Glyph; | ||
979 | struct _Fash_Glyph_Map | ||
980 | { | ||
981 | RGBA_Font_Glyph *item[256]; | ||
982 | }; | ||
983 | struct _Fash_Glyph_Map2 | ||
984 | { | ||
985 | Fash_Glyph_Map *bucket[256]; | ||
986 | }; | ||
987 | struct _Fash_Glyph | ||
988 | { | ||
989 | Fash_Glyph_Map2 *bucket[256]; | ||
990 | void (*freeme) (Fash_Glyph *fash); | ||
991 | }; | ||
992 | ///// | ||
993 | |||
994 | struct _RGBA_Font | ||
995 | { | ||
996 | Eina_List *fonts; | ||
997 | Fash_Int *fash; | ||
998 | Font_Hint_Flags hinting; | ||
999 | int references; | ||
1000 | LK(lock); | ||
1001 | unsigned char sizeok : 1; | ||
1002 | }; | ||
1003 | |||
1004 | #include "../common/evas_font_ot.h" | ||
1005 | |||
1006 | struct _RGBA_Font_Int | ||
1007 | { | ||
1008 | EINA_INLIST; | ||
1009 | RGBA_Font_Source *src; | ||
1010 | Eina_Hash *kerning; | ||
1011 | Fash_Glyph *fash; | ||
1012 | unsigned int size; | ||
1013 | float scale_factor; | ||
1014 | int real_size; | ||
1015 | int max_h; | ||
1016 | int references; | ||
1017 | int usage; | ||
1018 | struct { | ||
1019 | FT_Size size; | ||
1020 | #ifdef USE_HARFBUZZ | ||
1021 | void *hb_font; | ||
1022 | #endif | ||
1023 | } ft; | ||
1024 | LK(ft_mutex); | ||
1025 | Font_Hint_Flags hinting; | ||
1026 | Font_Rend_Flags wanted_rend; /* The wanted rendering style */ | ||
1027 | Font_Rend_Flags runtime_rend; /* The rendering we need to do on runtime | ||
1028 | in order to comply with the wanted_rend. */ | ||
1029 | |||
1030 | Eina_List *task; | ||
1031 | #ifdef EVAS_CSERVE2 | ||
1032 | void *cs2_handler; | ||
1033 | #endif | ||
1034 | |||
1035 | int generation; | ||
1036 | |||
1037 | Efl_Text_Font_Bitmap_Scalable bitmap_scalable; | ||
1038 | |||
1039 | unsigned char sizeok : 1; | ||
1040 | unsigned char inuse : 1; | ||
1041 | }; | ||
1042 | |||
1043 | struct _RGBA_Font_Source | ||
1044 | { | ||
1045 | const char *name; | ||
1046 | const char *file; | ||
1047 | void *data; | ||
1048 | unsigned int current_size; | ||
1049 | int data_size; | ||
1050 | int references; | ||
1051 | struct { | ||
1052 | int orig_upem; | ||
1053 | FT_Face face; | ||
1054 | } ft; | ||
1055 | }; | ||
1056 | |||
1057 | /* | ||
1058 | * laziness wins for now. The parts used from the freetpye struct are | ||
1059 | * kept intact to avoid changing the code using it until we know exactly | ||
1060 | * what needs to be changed | ||
1061 | */ | ||
1062 | struct _RGBA_Font_Glyph_Out | ||
1063 | { | ||
1064 | unsigned char *rle; | ||
1065 | struct { | ||
1066 | unsigned char *buffer; | ||
1067 | unsigned short rows; | ||
1068 | unsigned short width; | ||
1069 | unsigned short pitch; | ||
1070 | unsigned short rle_alloc : 1; | ||
1071 | unsigned short no_free_glout : 1; | ||
1072 | } bitmap; | ||
1073 | int rle_size; | ||
1074 | }; | ||
1075 | |||
1076 | struct _RGBA_Font_Glyph | ||
1077 | { | ||
1078 | FT_UInt index; | ||
1079 | Evas_Coord width; | ||
1080 | Evas_Coord x_bear; | ||
1081 | Evas_Coord y_bear; | ||
1082 | FT_Glyph glyph; | ||
1083 | RGBA_Font_Glyph_Out *glyph_out; | ||
1084 | /* this is a problem - only 1 engine at a time can extend such a font... grrr */ | ||
1085 | void *ext_dat; | ||
1086 | void (*ext_dat_free) (void *ext_dat); | ||
1087 | RGBA_Font_Int *fi; | ||
1088 | }; | ||
1089 | |||
1090 | struct _RGBA_Gfx_Compositor | 920 | struct _RGBA_Gfx_Compositor |
1091 | { | 921 | { |
1092 | const char *name; | 922 | const char *name; |
@@ -1287,7 +1117,6 @@ EAPI void evas_common_blit_init (void); | |||
1287 | EAPI void evas_common_blit_rectangle (const RGBA_Image *src, RGBA_Image *dst, int src_x, int src_y, int w, int h, int dst_x, int dst_y); | 1117 | EAPI void evas_common_blit_rectangle (const RGBA_Image *src, RGBA_Image *dst, int src_x, int src_y, int w, int h, int dst_x, int dst_y); |
1288 | 1118 | ||
1289 | /****/ | 1119 | /****/ |
1290 | #include "../common/evas_font.h" | ||
1291 | 1120 | ||
1292 | /****/ | 1121 | /****/ |
1293 | EAPI void evas_common_tilebuf_init (void); | 1122 | EAPI void evas_common_tilebuf_init (void); |
@@ -1321,8 +1150,6 @@ Tilebuf_Rect *evas_common_regionbuf_rects_get (Regionbuf *rb); | |||
1321 | /****/ | 1150 | /****/ |
1322 | #include "../common/evas_pipe.h" | 1151 | #include "../common/evas_pipe.h" |
1323 | 1152 | ||
1324 | void evas_font_dir_cache_free(void); | ||
1325 | |||
1326 | EAPI void evas_thread_queue_wait(void); | 1153 | EAPI void evas_thread_queue_wait(void); |
1327 | 1154 | ||
1328 | EAPI int evas_async_events_process_blocking(void); | 1155 | EAPI int evas_async_events_process_blocking(void); |
diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h index ebc14a44c9..7ec4095692 100644 --- a/src/lib/evas/include/evas_private.h +++ b/src/lib/evas/include/evas_private.h | |||
@@ -14,12 +14,10 @@ | |||
14 | 14 | ||
15 | #include "../file/evas_module.h" | 15 | #include "../file/evas_module.h" |
16 | #include "../file/evas_path.h" | 16 | #include "../file/evas_path.h" |
17 | #include "../common/evas_text_utils.h" | ||
18 | #include "../common/language/evas_bidi_utils.h" | ||
19 | #include "../common/language/evas_language_utils.h" | ||
20 | 17 | ||
21 | #include "evas_3d_utils.h" | 18 | #include "evas_3d_utils.h" |
22 | 19 | ||
20 | |||
23 | #ifdef EAPI | 21 | #ifdef EAPI |
24 | # undef EAPI | 22 | # undef EAPI |
25 | #endif | 23 | #endif |
@@ -66,10 +64,6 @@ typedef struct _Evas_Aspect Evas_Aspect; | |||
66 | typedef struct _Evas_Border Evas_Border; | 64 | typedef struct _Evas_Border Evas_Border; |
67 | typedef struct _Evas_Double_Pair Evas_Double_Pair; | 65 | typedef struct _Evas_Double_Pair Evas_Double_Pair; |
68 | typedef struct _Evas_Size_Hints Evas_Size_Hints; | 66 | typedef struct _Evas_Size_Hints Evas_Size_Hints; |
69 | typedef struct _Evas_Font_Dir Evas_Font_Dir; | ||
70 | typedef struct _Evas_Font Evas_Font; | ||
71 | typedef struct _Evas_Font_Alias Evas_Font_Alias; | ||
72 | typedef struct _Evas_Font_Description Evas_Font_Description; | ||
73 | typedef struct _Evas_Data_Node Evas_Data_Node; | 67 | typedef struct _Evas_Data_Node Evas_Data_Node; |
74 | typedef struct _Evas_Func Evas_Func; | 68 | typedef struct _Evas_Func Evas_Func; |