summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsubhransu mohanty <sub.mohanty@samsung.com>2017-11-07 11:22:09 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-11-07 11:34:53 +0900
commitb038d7df25f9cecaa4f0d8c1c7355e4852e5348a (patch)
tree595da7d0114056e147d4a40fedc72d5b71b3927a
parenta75b3dcdfbe0760972c8b4d55a90dc6250bd1e45 (diff)
downloadefl-b038d7df25f9cecaa4f0d8c1c7355e4852e5348a.tar.gz
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
-rw-r--r--src/Makefile_Evas.am5
-rw-r--r--src/lib/evas/canvas/evas_font_dir.c1105
-rw-r--r--src/lib/evas/canvas/evas_main.c135
-rw-r--r--src/lib/evas/canvas/evas_object_text.c14
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c43
-rw-r--r--src/lib/evas/canvas/evas_object_textgrid.c54
-rw-r--r--src/lib/evas/canvas/evas_render.c4
-rw-r--r--src/lib/evas/canvas/render2/evas_render2_old.c2
-rw-r--r--src/lib/evas/common/evas_font.h354
-rw-r--r--src/lib/evas/common/evas_font_compress.c173
-rw-r--r--src/lib/evas/common/evas_font_draw.c154
-rw-r--r--src/lib/evas/common/evas_font_draw.h18
-rw-r--r--src/lib/evas/common/evas_font_load.c50
-rw-r--r--src/lib/evas/common/evas_font_main.c28
-rw-r--r--src/lib/evas/common/evas_font_ot.c4
-rw-r--r--src/lib/evas/common/evas_font_ot.h11
-rw-r--r--src/lib/evas/common/evas_font_private.h44
-rw-r--r--src/lib/evas/common/evas_font_query.c3
-rw-r--r--src/lib/evas/common/evas_text_utils.c8
-rw-r--r--src/lib/evas/common/evas_text_utils.h5
-rw-r--r--src/lib/evas/include/evas_common_private.h181
-rw-r--r--src/lib/evas/include/evas_private.h129
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 \
lib/evas/common/language/evas_language_utils.h \
lib/evas/common/language/evas_script_table.h \
lib/evas/common/evas_text_utils.h \
-lib/evas/common/evas_font_ot.h
+lib/evas/common/evas_font_ot.h \
+lib/evas/common/evas_font_draw.h
lib_evas_libevas_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
-I$(top_srcdir)/src/lib/evas/canvas \
@@ -1608,7 +1609,7 @@ if BUILD_VG_LOADER_SVG
if EVAS_STATIC_BUILD_VG_SVG
lib_evas_libevas_la_SOURCES += modules/evas/vg_loaders/svg/evas_vg_load_svg.c \
static_libs/vg_common/vg_common.c \
-static_libs/vg_common/vg_common.h
+static_libs/vg_common/vg_common.h
lib_evas_libevas_la_CPPFLAGS += -I$(top_srcdir)/src/static_libs/vg_common \
@evas_vg_loader_svg_cflags@
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 @@
#include <fontconfig/fcfreetype.h>
#endif
-#include "evas_common_private.h"
-#include "evas_private.h"
+#include "evas_font.h"
+
+/* General types - used for script type chceking */
+#define OPAQUE_TYPE(type) struct __##type { int a; }; \
+ typedef struct __##type type
+
+OPAQUE_TYPE(Evas_Font_Set); /* General type for RGBA_Font */
+OPAQUE_TYPE(Evas_Font_Instance); /* General type for RGBA_Font_Int */
/* font dir cache */
static Eina_Hash *font_dirs = NULL;
@@ -57,6 +63,70 @@ static int evas_object_text_font_string_parse(char *buffer, char dest[14][256]);
static FcConfig *fc_config = NULL;
#endif
+/* FIXME move these helper function to eina_file or eina_path */
+/* get the casefold feature! */
+#include <fnmatch.h>
+#ifndef _MSC_VER
+# include <unistd.h>
+# include <sys/param.h>
+#endif
+int
+_file_path_is_full_path(const char *path)
+{
+ if (!path) return 0;
+#ifdef _WIN32
+ if (evil_path_is_absolute(path)) return 1;
+#else
+ if (path[0] == '/') return 1;
+#endif
+ return 0;
+}
+
+static DATA64
+_file_modified_time(const char *file)
+{
+ struct stat st;
+
+ if (stat(file, &st) < 0) return 0;
+ if (st.st_ctime > st.st_mtime) return (DATA64)st.st_ctime;
+ else return (DATA64)st.st_mtime;
+ return 0;
+}
+
+Eina_List *
+_file_path_list(char *path, const char *match, int match_case)
+{
+ Eina_File_Direct_Info *info;
+ Eina_Iterator *it;
+ Eina_List *files = NULL;
+ int flags;
+
+ flags = FNM_PATHNAME;
+#ifdef FNM_CASEFOLD
+ if (!match_case)
+ flags |= FNM_CASEFOLD;
+#elif defined FNM_IGNORECASE
+ if (!match_case)
+ flags |= FNM_IGNORECASE;
+#else
+/*#warning "Your libc does not provide case-insensitive matching!"*/
+#endif
+
+ it = eina_file_direct_ls(path);
+ EINA_ITERATOR_FOREACH(it, info)
+ {
+ if (match)
+ {
+ if (fnmatch(match, info->path + info->name_start, flags) == 0)
+ files = eina_list_append(files, strdup(info->path + info->name_start));
+ }
+ else
+ files = eina_list_append(files, strdup(info->path + info->name_start));
+ }
+ if (it) eina_iterator_free(it);
+ return files;
+}
+
static void
evas_font_init(void)
{
@@ -102,13 +172,13 @@ evas_font_dir_cache_find(char *dir, char *font)
fd = object_text_font_cache_dir_update(dir, fd);
if (fd)
{
- Evas_Font *fn;
+ Evas_Font *fn;
- fn = object_text_font_cache_font_find(fd, font);
- if (fn)
- {
- return fn->path;
- }
+ fn = object_text_font_cache_font_find(fd, font);
+ if (fn)
+ {
+ return fn->path;
+ }
}
return NULL;
}
@@ -122,123 +192,117 @@ evas_font_set_get(const char *name)
p = strchr(name, ',');
if (!p)
{
- fonts = eina_list_append(fonts, eina_stringshare_add(name));
+ fonts = eina_list_append(fonts, eina_stringshare_add(name));
}
else
{
- const char *pp;
- char *nm;
-
- pp = name;
- while (p)
- {
- nm = alloca(p - pp + 1);
- strncpy(nm, pp, p - pp);
- nm[p - pp] = 0;
- fonts = eina_list_append(fonts, eina_stringshare_add(nm));
- pp = p + 1;
- p = strchr(pp, ',');
- if (!p) fonts = eina_list_append(fonts, eina_stringshare_add(pp));
- }
+ const char *pp;
+ char *nm;
+
+ pp = name;
+ while (p)
+ {
+ nm = alloca(p - pp + 1);
+ strncpy(nm, pp, p - pp);
+ nm[p - pp] = 0;
+ fonts = eina_list_append(fonts, eina_stringshare_add(nm));
+ pp = p + 1;
+ p = strchr(pp, ',');
+ if (!p) fonts = eina_list_append(fonts, eina_stringshare_add(pp));
+ }
}
return fonts;
}
void
-evas_fonts_zero_free(Evas *eo_evas)
+evas_fonts_zero_free()
{
Fndat *fd;
- Evas_Public_Data *evas = efl_data_scope_get(eo_evas, EVAS_CANVAS_CLASS);
EINA_LIST_FREE(fonts_zero, fd)
{
if (fd->fdesc) evas_font_desc_unref(fd->fdesc);
- if (fd->source) eina_stringshare_del(fd->source);
- if ((evas->engine.func) && (evas->engine.func->font_free))
- evas->engine.func->font_free(_evas_engine_context(evas), fd->font);
+ if (fd->source) eina_stringshare_del(fd->source);
+ evas_common_font_free((RGBA_Font *)fd->font);
#ifdef HAVE_FONTCONFIG
- if (fd->set) FcFontSetDestroy(fd->set);
- if (fd->p_nm) FcPatternDestroy(fd->p_nm);
+ if (fd->set) FcFontSetDestroy(fd->set);
+ if (fd->p_nm) FcPatternDestroy(fd->p_nm);
#endif
- free(fd);
+ free(fd);
}
}
void
-evas_fonts_zero_pressure(Evas *eo_evas)
+evas_fonts_zero_pressure()
{
Fndat *fd;
- Evas_Public_Data *evas = efl_data_scope_get(eo_evas, EVAS_CANVAS_CLASS);
while (fonts_zero
- && eina_list_count(fonts_zero) > 4) /* 4 is arbitrary */
+ && eina_list_count(fonts_zero) > 4) /* 4 is arbitrary */
{
- fd = eina_list_data_get(fonts_zero);
+ fd = eina_list_data_get(fonts_zero);
- if (fd->ref != 0) break;
- fonts_zero = eina_list_remove_list(fonts_zero, fonts_zero);
+ if (fd->ref != 0) break;
+ fonts_zero = eina_list_remove_list(fonts_zero, fonts_zero);
if (fd->fdesc) evas_font_desc_unref(fd->fdesc);
- if (fd->source) eina_stringshare_del(fd->source);
- if ((evas->engine.func) && (evas->engine.func->font_free))
- evas->engine.func->font_free(_evas_engine_context(evas), fd->font);
-#ifdef HAVE_FONTCONFIG
- if (fd->set) FcFontSetDestroy(fd->set);
- if (fd->p_nm) FcPatternDestroy(fd->p_nm);
-#endif
- free(fd);
-
- if (eina_list_count(fonts_zero) < 5) break;
+ if (fd->source) eina_stringshare_del(fd->source);
+ evas_common_font_free((RGBA_Font *)fd->font);
+ #ifdef HAVE_FONTCONFIG
+ if (fd->set) FcFontSetDestroy(fd->set);
+ if (fd->p_nm) FcPatternDestroy(fd->p_nm);
+ #endif
+ free(fd);
+
+ if (eina_list_count(fonts_zero) < 5) break;
}
}
void
-evas_font_free(Evas *eo_evas, void *font)
+evas_font_free(void *font)
{
Eina_List *l;
Fndat *fd;
- Evas_Public_Data *evas = efl_data_scope_get(eo_evas, EVAS_CANVAS_CLASS);
EINA_LIST_FOREACH(fonts_cache, l, fd)
{
- if (fd->font == font)
- {
- fd->ref--;
- if (fd->ref == 0)
- {
- fonts_cache = eina_list_remove_list(fonts_cache, l);
- fonts_zero = eina_list_append(fonts_zero, fd);
- }
- break;
- }
+ if (fd->font == font)
+ {
+ fd->ref--;
+ if (fd->ref == 0)
+ {
+ fonts_cache = eina_list_remove_list(fonts_cache, l);
+ fonts_zero = eina_list_append(fonts_zero, fd);
+ }
+ break;
+ }
}
while (fonts_zero
- && eina_list_count(fonts_zero) > 42) /* 42 is arbitrary */
+ && eina_list_count(fonts_zero) > 42) /* 42 is arbitrary */
{
- fd = eina_list_data_get(fonts_zero);
+ fd = eina_list_data_get(fonts_zero);
- if (fd->ref != 0) break;
- fonts_zero = eina_list_remove_list(fonts_zero, fonts_zero);
+ if (fd->ref != 0) break;
+ fonts_zero = eina_list_remove_list(fonts_zero, fonts_zero);
if (fd->fdesc) evas_font_desc_unref(fd->fdesc);
- if (fd->source) eina_stringshare_del(fd->source);
- evas->engine.func->font_free(_evas_engine_context(evas), fd->font);
-#ifdef HAVE_FONTCONFIG
- if (fd->set) FcFontSetDestroy(fd->set);
- if (fd->p_nm) FcPatternDestroy(fd->p_nm);
-#endif
- free(fd);
-
- if (eina_list_count(fonts_zero) < 43) break;
+ if (fd->source) eina_stringshare_del(fd->source);
+ evas_common_font_free((RGBA_Font *)fd->font);
+ #ifdef HAVE_FONTCONFIG
+ if (fd->set) FcFontSetDestroy(fd->set);
+ if (fd->p_nm) FcPatternDestroy(fd->p_nm);
+ #endif
+ free(fd);
+
+ if (eina_list_count(fonts_zero) < 43) break;
}
}
#ifdef HAVE_FONTCONFIG
static Evas_Font_Set *
-_evas_load_fontconfig(Evas_Font_Set *font, Evas *eo_evas, FcFontSet *set, int size,
+_evas_load_fontconfig(Evas_Font_Set *font, FcFontSet *set, int size,
Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable)
{
- Evas_Public_Data *evas = efl_data_scope_get(eo_evas, EVAS_CANVAS_CLASS);
int i;
/* Do loading for all in family */
@@ -249,9 +313,9 @@ _evas_load_fontconfig(Evas_Font_Set *font, Evas *eo_evas, FcFontSet *set, int si
if (FcPatternGet(set->fonts[i], FC_FILE, 0, &filename) == FcResultMatch)
{
if (font)
- evas->engine.func->font_add(_evas_engine_context(evas), font, (char *)filename.u.s, size, wanted_rend, bitmap_scalable);
+ evas_common_font_add((RGBA_Font *)font, (char *)filename.u.s, size, wanted_rend, bitmap_scalable);
else
- font = evas->engine.func->font_load(_evas_engine_context(evas), (char *)filename.u.s, size, wanted_rend, bitmap_scalable);
+ font = (Evas_Font_Set *)evas_common_font_load((char *)filename.u.s, size, wanted_rend, bitmap_scalable);
}
}
@@ -385,7 +449,7 @@ _evas_font_style_find_internal(const char *style, const char *style_end,
const char *cur = _map[i].name;
len = strlen(cur);
if (!strncasecmp(style, cur, len) &&
- (!cur[len] || (cur[len] == ' ')))
+ (!cur[len] || (cur[len] == ' ')))
{
return _map[i].type;
}
@@ -474,8 +538,8 @@ evas_font_desc_cmp(const Evas_Font_Description *a,
{
/* FIXME: Do actual comparison, i.e less than and bigger than. */
return !((a->name == b->name) && (a->weight == b->weight) &&
- (a->slant == b->slant) && (a->width == b->width) &&
- (a->spacing == b->spacing) && (a->lang == b->lang));
+ (a->slant == b->slant) && (a->width == b->width) &&
+ (a->spacing == b->spacing) && (a->lang == b->lang));
}
const char *
@@ -552,9 +616,8 @@ evas_font_name_parse(Evas_Font_Description *fdesc, const char *name)
}
void *
-evas_font_load(Evas *eo_evas, Evas_Font_Description *fdesc, const char *source, Evas_Font_Size size, Efl_Text_Font_Bitmap_Scalable bitmap_scalable)
+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)
{
- Evas_Public_Data *evas = efl_data_scope_get(eo_evas, EVAS_CANVAS_CLASS);
#ifdef HAVE_FONTCONFIG
FcPattern *p_nm = NULL;
FcFontSet *set = NULL;
@@ -583,32 +646,32 @@ evas_font_load(Evas *eo_evas, Evas_Font_Description *fdesc, const char *source,
EINA_LIST_FOREACH(fonts_cache, l, fd)
{
if (!evas_font_desc_cmp(fdesc, fd->fdesc))
- {
- if (((!source) && (!fd->source)) ||
- ((source) && (fd->source) && (!strcmp(source, fd->source))))
- {
- if ((size == fd->size) &&
- (wanted_rend == fd->wanted_rend) &&
- (bitmap_scalable == fd->bitmap_scalable))
- {
- fonts_cache = eina_list_promote_list(fonts_cache, l);
- fd->ref++;
- return fd->font;
- }
-#ifdef HAVE_FONTCONFIG
- else if (fd->set && fd->p_nm && !fd->file_font)
- {
- found_fd = fd;
- }
-#endif
- }
- }
+ {
+ if (((!source) && (!fd->source)) ||
+ ((source) && (fd->source) && (!strcmp(source, fd->source))))
+ {
+ if ((size == fd->size) &&
+ (wanted_rend == fd->wanted_rend) &&
+ (bitmap_scalable == fd->bitmap_scalable))
+ {
+ fonts_cache = eina_list_promote_list(fonts_cache, l);
+ fd->ref++;
+ return fd->font;
+ }
+ #ifdef HAVE_FONTCONFIG
+ else if (fd->set && fd->p_nm && !fd->file_font)
+ {
+ found_fd = fd;
+ }
+ #endif
+ }
+ }
}
#ifdef HAVE_FONTCONFIG
if (found_fd)
{
- font = _evas_load_fontconfig(font, evas->evas, found_fd->set, size, wanted_rend, bitmap_scalable);
+ font = _evas_load_fontconfig(font, found_fd->set, size, wanted_rend, bitmap_scalable);
goto on_find;
}
#endif
@@ -616,32 +679,32 @@ evas_font_load(Evas *eo_evas, Evas_Font_Description *fdesc, const char *source,
EINA_LIST_FOREACH_SAFE(fonts_zero, l, l_next, fd)
{
if (!evas_font_desc_cmp(fdesc, fd->fdesc))
- {
- if (((!source) && (!fd->source)) ||
- ((source) && (fd->source) && (!strcmp(source, fd->source))))
- {
- if ((size == fd->size) &&
- (wanted_rend == fd->wanted_rend))
- {
- fonts_zero = eina_list_remove_list(fonts_zero, l);
- fonts_cache = eina_list_prepend(fonts_cache, fd);
- fd->ref++;
- return fd->font;
- }
-#ifdef HAVE_FONTCONFIG
- else if (fd->set && fd->p_nm && !fd->file_font)
- {
- found_fd = fd;
- }
-#endif
- }
- }
+ {
+ if (((!source) && (!fd->source)) ||
+ ((source) && (fd->source) && (!strcmp(source, fd->source))))
+ {
+ if ((size == fd->size) &&
+ (wanted_rend == fd->wanted_rend))
+ {
+ fonts_zero = eina_list_remove_list(fonts_zero, l);
+ fonts_cache = eina_list_prepend(fonts_cache, fd);
+ fd->ref++;
+ return fd->font;
+ }
+ #ifdef HAVE_FONTCONFIG
+ else if (fd->set && fd->p_nm && !fd->file_font)
+ {
+ found_fd = fd;
+ }
+ #endif
+ }
+ }
}
#ifdef HAVE_FONTCONFIG
if (found_fd)
{
- font = _evas_load_fontconfig(font, evas->evas, found_fd->set, size, wanted_rend, bitmap_scalable);
+ font = _evas_load_fontconfig(font, found_fd->set, size, wanted_rend, bitmap_scalable);
goto on_find;
}
#endif
@@ -649,57 +712,53 @@ evas_font_load(Evas *eo_evas, Evas_Font_Description *fdesc, const char *source,
fonts = evas_font_set_get(fdesc->name);
EINA_LIST_FOREACH(fonts, l, nm) /* Load each font in append */
{
- if (l == fonts || !font) /* First iteration OR no font */
- {
- if (source) /* Load Font from "eet" source */
- {
- Eet_File *ef;
- char *fake_name;
-
- fake_name = evas_file_path_join(source, nm);
- if (fake_name)
- {
- font = evas->engine.func->font_load(_evas_engine_context(evas), fake_name, size, wanted_rend, bitmap_scalable);
- if (!font) /* Load from fake name failed, probably not cached */
- {
- /* read original!!! */
- ef = eet_open(source, EET_FILE_MODE_READ);
- if (ef)
- {
- void *fdata;
- int fsize = 0;
-
- fdata = eet_read(ef, nm, &fsize);
- if (fdata)
- {
- font = evas->engine.func->font_memory_load(_evas_engine_context(evas), source, nm, size, fdata, fsize, wanted_rend, bitmap_scalable);
- free(fdata);
- }
- eet_close(ef);
- }
- }
- free(fake_name);
- }
- }
- if (!font) /* Source load failed */
- {
- if (evas_file_path_is_full_path((char *)nm)) /* Try filename */
- font = evas->engine.func->font_load(_evas_engine_context(evas), (char *)nm, size, wanted_rend, bitmap_scalable);
- else /* search font path */
- {
- Eina_List *ll;
- char *dir;
-
- EINA_LIST_FOREACH(evas->font_path, ll, dir)
- {
- const char *f_file;
-
- f_file = evas_font_dir_cache_find(dir, (char *)nm);
- if (f_file)
- {
- font = evas->engine.func->font_load(_evas_engine_context(evas), f_file, size, wanted_rend, bitmap_scalable);
- if (font) break;
- }
+ if (l == fonts || !font) /* First iteration OR no font */
+ {
+ if (source) /* Load Font from "eet" source */
+ {
+ Eet_File *ef;
+ char fake_name[PATH_MAX];
+
+ eina_file_path_join(fake_name, PATH_MAX, source, nm);
+ font = (Evas_Font_Set *)evas_common_font_load(fake_name, size, wanted_rend, bitmap_scalable);
+ if (!font) /* Load from fake name failed, probably not cached */
+ {
+ /* read original!!! */
+ ef = eet_open(source, EET_FILE_MODE_READ);
+ if (ef)
+ {
+ void *fdata;
+ int fsize = 0;
+
+ fdata = eet_read(ef, nm, &fsize);
+ if (fdata)
+ {
+ font = (Evas_Font_Set *)evas_common_font_memory_load(source, nm, size, fdata, fsize, wanted_rend, bitmap_scalable);
+ free(fdata);
+ }
+ eet_close(ef);
+ }
+ }
+ }
+ if (!font) /* Source load failed */
+ {
+ if (_file_path_is_full_path((char *)nm)) /* Try filename */
+ font = (Evas_Font_Set *)evas_common_font_load((char *)nm, size, wanted_rend, bitmap_scalable);
+ else /* search font path */
+ {
+ const Eina_List *ll;
+ char *dir;
+
+ EINA_LIST_FOREACH(font_paths, ll, dir)
+ {
+ const char *f_file;
+
+ f_file = evas_font_dir_cache_find(dir, (char *)nm);
+ if (f_file)
+ {
+ font = (Evas_Font_Set *)evas_common_font_load(f_file, size, wanted_rend, bitmap_scalable);
+ if (font) break;
+ }
}
if (!font)
@@ -711,71 +770,66 @@ evas_font_load(Evas *eo_evas, Evas_Font_Description *fdesc, const char *source,
f_file = evas_font_dir_cache_find(dir, (char *)nm);
if (f_file)
{
- font = evas->engine.func->font_load(_evas_engine_context(evas), f_file, size, wanted_rend, bitmap_scalable);
+ font = (Evas_Font_Set *)evas_common_font_load(f_file, size, wanted_rend, bitmap_scalable);
if (font) break;
}
}
}
}
- }
- }
- else /* Base font loaded, append others */
- {
- void *ok = NULL;
-
- if (source)
- {
- Eet_File *ef;
- char *fake_name;
-
- fake_name = evas_file_path_join(source, nm);
- if (fake_name)
- {
- /* FIXME: make an engine func */
- if (!evas->engine.func->font_add(_evas_engine_context(evas), font, fake_name, size, wanted_rend, bitmap_scalable))
- {
- /* read original!!! */
- ef = eet_open(source, EET_FILE_MODE_READ);
- if (ef)
- {
- void *fdata;
- int fsize = 0;
-
- fdata = eet_read(ef, nm, &fsize);
- if ((fdata) && (fsize > 0))
- {
- ok = evas->engine.func->font_memory_add(_evas_engine_context(evas), font, source, nm, size, fdata, fsize, wanted_rend, bitmap_scalable);
- }
- eet_close(ef);
- free(fdata);
- }
- }
- else
- ok = (void *)1;
- free(fake_name);
- }
- }
- if (!ok)
- {
- if (evas_file_path_is_full_path((char *)nm))
- evas->engine.func->font_add(_evas_engine_context(evas), font, (char *)nm, size, wanted_rend, bitmap_scalable);
- else
- {
- Eina_List *ll;
- char *dir;
- RGBA_Font *fn = NULL;
-
- EINA_LIST_FOREACH(evas->font_path, ll, dir)
- {
- const char *f_file;
-
- f_file = evas_font_dir_cache_find(dir, (char *)nm);
- if (f_file)
- {
- fn = (RGBA_Font *)evas->engine.func->font_add(_evas_engine_context(evas), font, f_file, size, wanted_rend, bitmap_scalable);
- if (fn)
- break;
- }
+ }
+ }
+ else /* Base font loaded, append others */
+ {
+ void *ok = NULL;
+
+ if (source)
+ {
+ Eet_File *ef;
+ char fake_name[PATH_MAX];
+
+ eina_file_path_join(fake_name, PATH_MAX, source, nm);
+ if (!evas_common_font_add((RGBA_Font *)font, fake_name, size, wanted_rend, bitmap_scalable))
+ {
+ /* read original!!! */
+ ef = eet_open(source, EET_FILE_MODE_READ);
+ if (ef)
+ {
+ void *fdata;
+ int fsize = 0;
+
+ fdata = eet_read(ef, nm, &fsize);
+ if ((fdata) && (fsize > 0))
+ {
+ ok = evas_common_font_memory_add((RGBA_Font *)font, source, nm, size, fdata, fsize, wanted_rend, bitmap_scalable);
+ }
+ eet_close(ef);
+ free(fdata);
+ }
+ }
+ else
+ ok = (void *)1;
+ }
+ if (!ok)
+ {
+ if (_file_path_is_full_path((char *)nm))
+ evas_common_font_add((RGBA_Font *)font, (char *)nm, size, wanted_rend, bitmap_scalable);
+ else
+ {
+ const Eina_List *ll;
+ char *dir;
+ RGBA_Font *fn = NULL;
+
+ EINA_LIST_FOREACH(font_paths, ll, dir)
+ {
+ const char *f_file;
+
+ f_file = evas_font_dir_cache_find(dir, (char *)nm);
+ if (f_file)
+ {
+ fn = evas_common_font_add((RGBA_Font *)font, f_file, size, wanted_rend, bitmap_scalable);
+ if (fn)
+ break;
+ }
}
if (!fn)
@@ -787,23 +841,23 @@ evas_font_load(Evas *eo_evas, Evas_Font_Description *fdesc, const char *source,
f_file = evas_font_dir_cache_find(dir, (char *)nm);
if (f_file)
{
- fn = (RGBA_Font *)evas->engine.func->font_add(_evas_engine_context(evas), font, f_file, size, wanted_rend, bitmap_scalable);
+ fn = evas_common_font_add((RGBA_Font *)font, f_file, size, wanted_rend, bitmap_scalable);
if (fn)
break;
}
}
}
}
- }
- }
- eina_stringshare_del(nm);
+ }
+ }
+ eina_stringshare_del(nm);
}
eina_list_free(fonts);
#ifdef HAVE_FONTCONFIG
if (!font) /* Search using fontconfig */
{
- FcResult res;
+ FcResult res;
p_nm = FcPatternBuild (NULL,
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,
if (fdesc->lang)
FcPatternAddString (p_nm, FC_LANG, (FcChar8 *) fdesc->lang);
- FcConfigSubstitute(fc_config, p_nm, FcMatchPattern);
- FcDefaultSubstitute(p_nm);
-
- /* do matching */
- set = FcFontSort(fc_config, p_nm, FcTrue, NULL, &res);
- if (!set)
- {
- ERR("No fontconfig font matches '%s'. It was the last resource, no font found!", fdesc->name);
- FcPatternDestroy(p_nm);
- p_nm = NULL;
- }
- else
+ FcConfigSubstitute(fc_config, p_nm, FcMatchPattern);
+ FcDefaultSubstitute(p_nm);
+
+ /* do matching */
+ set = FcFontSort(fc_config, p_nm, FcTrue, NULL, &res);
+ if (!set)
+ {
+ //FIXME add ERR log capability
+ //ERR("No fontconfig font matches '%s'. It was the last resource, no font found!", fdesc->name);
+ FcPatternDestroy(p_nm);
+ p_nm = NULL;
+ }
+ else
{
- font = _evas_load_fontconfig(font, evas->evas, set, size, wanted_rend, bitmap_scalable);
+ font = _evas_load_fontconfig(font, set, size, wanted_rend, bitmap_scalable);
}
}
else /* Add a fallback list from fontconfig according to the found font. */
{
#if FC_MAJOR >= 2 && FC_MINOR >= 11
- FcResult res;
+ FcResult res;
FT_Face face = evas_common_font_freetype_face_get((RGBA_Font *) font);
@@ -884,7 +939,7 @@ evas_font_load(Evas *eo_evas, Evas_Font_Description *fdesc, const char *source,
}
else
{
- font = _evas_load_fontconfig(font, evas->evas, set, size, wanted_rend, bitmap_scalable);
+ font = _evas_load_fontconfig(font, set, size, wanted_rend, bitmap_scalable);
}
}
#endif
@@ -913,24 +968,20 @@ evas_font_load(Evas *eo_evas, Evas_Font_Description *fdesc, const char *source,
}
if (font)
- evas->engine.func->font_hinting_set(_evas_engine_context(evas), font,
- evas->hinting);
+ evas_common_font_hinting_set((RGBA_Font *)font, hinting);
return font;
}
void
-evas_font_load_hinting_set(Evas *eo_evas, void *font, int hinting)
+evas_font_load_hinting_set(void *font, int hinting)
{
- Evas_Public_Data *evas = efl_data_scope_get(eo_evas, EVAS_CANVAS_CLASS);
- evas->engine.func->font_hinting_set(_evas_engine_context(evas), font,
- hinting);
+ evas_common_font_hinting_set((RGBA_Font *) font, hinting);
}
Eina_List *
-evas_font_dir_available_list(const Evas *eo_evas)
+evas_font_dir_available_list(const Eina_List *font_paths)
{
- const Evas_Public_Data *evas = efl_data_scope_get(eo_evas, EVAS_CANVAS_CLASS);
- Eina_List *l;
+ const Eina_List *l;
Eina_List *ll;
Eina_List *available = NULL;
char *dir;
@@ -954,25 +1005,25 @@ evas_font_dir_available_list(const Evas *eo_evas)
if (set)
{
- for (i = 0; i < set->nfont; i++)
- {
- char *font;
+ for (i = 0; i < set->nfont; i++)
+ {
+ char *font;
- font = (char *)FcNameUnparse(set->fonts[i]);
- available = eina_list_append(available, eina_stringshare_add(font));
- free(font);
- }
+ font = (char *)FcNameUnparse(set->fonts[i]);
+ available = eina_list_append(available, eina_stringshare_add(font));
+ free(font);
+ }
- FcFontSetDestroy(set);
+ FcFontSetDestroy(set);
}
#endif
- /* Add fonts in evas font_path*/
- if (evas->font_path)
+ /* Add fonts in font_paths*/
+ if (font_paths)
{
if (!font_dirs) font_dirs = eina_hash_string_superfast_new(NULL);
- EINA_LIST_FOREACH(evas->font_path, l, dir)
+ EINA_LIST_FOREACH(font_paths, l, dir)
{
Evas_Font_Dir *fd;
@@ -1016,8 +1067,8 @@ evas_font_dir_available_list_free(Eina_List *available)
{
while (available)
{
- eina_stringshare_del(available->data);
- available = eina_list_remove(available, available->data);
+ eina_stringshare_del(available->data);
+ available = eina_list_remove(available, available->data);
}
}
@@ -1032,47 +1083,39 @@ font_cache_dir_free(const Eina_Hash *hash EINA_UNUSED, const void *key, void *da
static Evas_Font_Dir *
object_text_font_cache_dir_update(char *dir, Evas_Font_Dir *fd)
{
+ char file_path[PATH_MAX];
DATA64 mt;
- char *tmp;
if (fd)
{
- mt = evas_file_modified_time(dir);
- if (mt != fd->dir_mod_time)
- {
- eina_hash_del(font_dirs, dir, fd);
- object_text_font_cache_dir_del(dir, fd);
- }
- else
- {
- tmp = evas_file_path_join(dir, "fonts.dir");
- if (tmp)
- {
- mt = evas_file_modified_time(tmp);
- free(tmp);
- if (mt != fd->fonts_dir_mod_time)
- {
- eina_hash_del(font_dirs, dir, fd);
- object_text_font_cache_dir_del(dir, fd);
- }
- else
- {
- tmp = evas_file_path_join(dir, "fonts.alias");
- if (tmp)
- {
- mt = evas_file_modified_time(tmp);
- free(tmp);
- }
- if (mt != fd->fonts_alias_mod_time)
- {
- eina_hash_del(font_dirs, dir, fd);
- object_text_font_cache_dir_del(dir, fd);
- }
- else
- return fd;
- }
- }
- }
+ mt = _file_modified_time(dir);
+ if (mt != fd->dir_mod_time)
+ {
+ eina_hash_del(font_dirs, dir, fd);
+ object_text_font_cache_dir_del(dir, fd);
+ }
+ else
+ {
+ eina_file_path_join(file_path, PATH_MAX, dir, "fonts.dir");
+ mt = _file_modified_time(file_path);
+ if (mt != fd->fonts_dir_mod_time)
+ {
+ eina_hash_del(font_dirs, dir, fd);
+ object_text_font_cache_dir_del(dir, fd);
+ }
+ else
+ {
+ eina_file_path_join(file_path, PATH_MAX, dir, "fonts.alias");
+ mt = _file_modified_time(file_path);
+ if (mt != fd->fonts_alias_mod_time)
+ {
+ eina_hash_del(font_dirs, dir, fd);
+ object_text_font_cache_dir_del(dir, fd);
+ }
+ else
+ return fd;
+ }
+ }
}
return object_text_font_cache_dir_add(dir);
}
@@ -1089,23 +1132,23 @@ object_text_font_cache_font_find_x(Evas_Font_Dir *fd, char *font)
if (num != 14) return NULL;
EINA_LIST_FOREACH(fd->fonts, l, fn)
{
- if (fn->type == 1)
- {
- int i;
- int match = 0;
-
- for (i = 0; i < 14; i++)
- {
- if ((font_prop[i][0] == '*') && (font_prop[i][1] == 0))
- match++;
- else
- {
- if (!strcasecmp(font_prop[i], fn->x.prop[i])) match++;
- else break;
- }
- }
- if (match == 14) return fn;
- }
+ if (fn->type == 1)
+ {
+ int i;
+ int match = 0;
+
+ for (i = 0; i < 14; i++)
+ {
+ if ((font_prop[i][0] == '*') && (font_prop[i][1] == 0))
+ match++;
+ else
+ {
+ if (!strcasecmp(font_prop[i], fn->x.prop[i])) match++;
+ else break;
+ }
+ }
+ if (match == 14) return fn;
+ }
}
return NULL;
}
@@ -1118,10 +1161,10 @@ object_text_font_cache_font_find_file(Evas_Font_Dir *fd, char *font)
EINA_LIST_FOREACH(fd->fonts, l, fn)
{
- if (fn->type == 0)
- {
- if (!strcasecmp(font, fn->simple.name)) return fn;
- }
+ if (fn->type == 0)
+ {
+ if (!strcasecmp(font, fn->simple.name)) return fn;
+ }
}
return NULL;
}
@@ -1155,10 +1198,13 @@ object_text_font_cache_font_find(Evas_Font_Dir *fd, char *font)
static Evas_Font_Dir *
object_text_font_cache_dir_add(char *dir)
{
+ char file_path[PATH_MAX];
Evas_Font_Dir *fd;
- char *tmp, *tmp2, *file;
+ char *file;
+ char tmp2[PATH_MAX];
Eina_List *fdir;
Evas_Font *fn;
+ FILE *f;
fd = calloc(1, sizeof(Evas_Font_Dir));
if (!fd) return NULL;
@@ -1169,134 +1215,105 @@ object_text_font_cache_dir_add(char *dir)
/* READ fonts.alias, fonts.dir and directory listing */
/* fonts.dir */
- tmp = evas_file_path_join(dir, "fonts.dir");
- if (tmp)
+ eina_file_path_join(file_path, PATH_MAX, dir, "fonts.dir");
+
+ f = fopen(file_path, "rb");
+ if (f)
{
- FILE *f;
-
- f = fopen(tmp, "rb");
- if (f)
- {
- int num;
- char fname[4096], fdef[4096];
-
- if (fscanf(f, "%i\n", &num) != 1) goto cant_read;
- /* read font lines */
- while (fscanf(f, "%4090s %[^\n]\n", fname, fdef) == 2)
- {
- char font_prop[14][256];
- int i;
-
- /* skip comments */
- if ((fdef[0] == '!') || (fdef[0] == '#')) continue;
- /* parse font def */
- num = evas_object_text_font_string_parse((char *)fdef, font_prop);
- if (num == 14)
- {
- fn = calloc(1, sizeof(Evas_Font));
- if (fn)
- {
- fn->type = 1;
- for (i = 0; i < 14; i++)
- fn->x.prop[i] = eina_stringshare_add(font_prop[i]);
- tmp2 = evas_file_path_join(dir, fname);
- if (tmp2)
- {
- fn->path = eina_stringshare_add(tmp2);
- free(tmp2);
- }
- fd->fonts = eina_list_append(fd->fonts, fn);
- }
- }
- }
- cant_read: ;
- fclose(f);
- }
- free(tmp);
+ int num;
+ char fname[4096], fdef[4096];
+
+ if (fscanf(f, "%i\n", &num) != 1) goto cant_read;
+ /* read font lines */
+ while (fscanf(f, "%4090s %[^\n]\n", fname, fdef) == 2)
+ {
+ char font_prop[14][256];
+ int i;
+
+ /* skip comments */
+ if ((fdef[0] == '!') || (fdef[0] == '#')) continue;
+ /* parse font def */
+ num = evas_object_text_font_string_parse((char *)fdef, font_prop);
+ if (num == 14)
+ {
+ fn = calloc(1, sizeof(Evas_Font));
+ if (fn)
+ {
+ fn->type = 1;
+ for (i = 0; i < 14; i++)
+ fn->x.prop[i] = eina_stringshare_add(font_prop[i]);
+ eina_file_path_join(tmp2, PATH_MAX, dir, fname);
+ fn->path = eina_stringshare_add(tmp2);
+ fd->fonts = eina_list_append(fd->fonts, fn);
+ }
+ }
+ }
+ cant_read: ;
+ fclose(f);
}
/* directoy listing */
- fdir = evas_file_path_list(dir, "*.ttf", 0);
+ fdir = _file_path_list(dir, "*.ttf", 0);
EINA_LIST_FREE(fdir, file)
{
- tmp = evas_file_path_join(dir, file);
- if (tmp)
- {
- fn = calloc(1, sizeof(Evas_Font));
- if (fn)
- {
- char *p;
-
- fn->type = 0;
- tmp2 = alloca(strlen(file) + 1);
- strcpy(tmp2, file);
- p = strrchr(tmp2, '.');
- if (p) *p = 0;
- fn->simple.name = eina_stringshare_add(tmp2);
- tmp2 = evas_file_path_join(dir, file);
- if (tmp2)
- {
- fn->path = eina_stringshare_add(tmp2);
- free(tmp2);
- }
- fd->fonts = eina_list_append(fd->fonts, fn);
- }
- free(tmp);
- }
- free(file);
+ eina_file_path_join(file_path, PATH_MAX, dir, file);
+ fn = calloc(1, sizeof(Evas_Font));
+ if (fn)
+ {
+ char *p;
+
+ fn->type = 0;
+ strcpy(tmp2, file);
+ p = strrchr(tmp2, '.');
+ if (p) *p = 0;
+ fn->simple.name = eina_stringshare_add(tmp2);
+ eina_file_path_join(tmp2, PATH_MAX, dir, file);
+ fn->path = eina_stringshare_add(tmp2);
+ fd->fonts = eina_list_append(fd->fonts, fn);
+ }
+ free(file);
}
/* fonts.alias */
- tmp = evas_file_path_join(dir, "fonts.alias");
- if (tmp)
- {
- FILE *f;
-
- f = fopen(tmp, "rb");
- if (f)
- {
- char fname[4096], fdef[4096];
-
- /* read font alias lines */
- while (fscanf(f, "%4090s %4090[^\n]\n", fname, fdef) == 2)
- {
- Evas_Font_Alias *fa;
-
- /* skip comments */
- if ((fname[0] == '!') || (fname[0] == '#')) continue;
- fa = calloc(1, sizeof(Evas_Font_Alias));
- if (fa)
- {
- fa->alias = eina_stringshare_add(fname);
- fa->fn = object_text_font_cache_font_find_x(fd, fdef);
- if ((!fa->alias) || (!fa->fn))
- {
- if (fa->alias) eina_stringshare_del(fa->alias);
- free(fa);
- }
- else
- fd->aliases = eina_list_append(fd->aliases, fa);
- }
- }
- fclose(f);
- }
- free(tmp);
- }
+ eina_file_path_join(file_path, PATH_MAX, dir, "fonts.alias");
- fd->dir_mod_time = evas_file_modified_time(dir);
- tmp = evas_file_path_join(dir, "fonts.dir");
- if (tmp)
+ f = fopen(file_path, "rb");
+ if (f)
{
- fd->fonts_dir_mod_time = evas_file_modified_time(tmp);
- free(tmp);
- }
- tmp = evas_file_path_join(dir, "fonts.alias");
- if (tmp)
- {
- fd->fonts_alias_mod_time = evas_file_modified_time(tmp);
- free(tmp);
+ char fname[4096], fdef[4096];
+
+ /* read font alias lines */
+ while (fscanf(f, "%4090s %4090[^\n]\n", fname, fdef) == 2)
+ {
+ Evas_Font_Alias *fa;
+
+ /* skip comments */
+ if ((fname[0] == '!') || (fname[0] == '#')) continue;
+ fa = calloc(1, sizeof(Evas_Font_Alias));
+ if (fa)
+ {
+ fa->alias = eina_stringshare_add(fname);
+ fa->fn = object_text_font_cache_font_find_x(fd, fdef);
+ if ((!fa->alias) || (!fa->fn))
+ {
+ if (fa->alias) eina_stringshare_del(fa->alias);
+ free(fa);
+ }
+ else
+ fd->aliases = eina_list_append(fd->aliases, fa);
+ }
+ }
+ fclose(f);
}
+ fd->dir_mod_time = _file_modified_time(dir);
+
+ eina_file_path_join(file_path, PATH_MAX, dir, "fonts.dir");
+ fd->fonts_dir_mod_time = _file_modified_time(file_path);
+
+ eina_file_path_join(file_path, PATH_MAX, dir, "fonts.alias");
+ fd->fonts_alias_mod_time = _file_modified_time(file_path);
+
return fd;
}
@@ -1306,27 +1323,27 @@ object_text_font_cache_dir_del(char *dir EINA_UNUSED, Evas_Font_Dir *fd)
if (fd->lookup) eina_hash_free(fd->lookup);
while (fd->fonts)
{
- Evas_Font *fn;
- int i;
-
- fn = fd->fonts->data;
- fd->fonts = eina_list_remove(fd->fonts, fn);
- for (i = 0; i < 14; i++)
- {
- if (fn->x.prop[i]) eina_stringshare_del(fn->x.prop[i]);
- }
- if (fn->simple.name) eina_stringshare_del(fn->simple.name);
- if (fn->path) eina_stringshare_del(fn->path);
- free(fn);
+ Evas_Font *fn;
+ int i;
+
+ fn = fd->fonts->data;
+ fd->fonts = eina_list_remove(fd->fonts, fn);
+ for (i = 0; i < 14; i++)
+ {
+ if (fn->x.prop[i]) eina_stringshare_del(fn->x.prop[i]);
+ }
+ if (fn->simple.name) eina_stringshare_del(fn->simple.name);
+ if (fn->path) eina_stringshare_del(fn->path);
+ free(fn);
}
while (fd->aliases)
{
- Evas_Font_Alias *fa;
+ Evas_Font_Alias *fa;
- fa = fd->aliases->data;
- fd->aliases = eina_list_remove(fd->aliases, fa);
- if (fa->alias) eina_stringshare_del(fa->alias);
- free(fa);
+ fa = fd->aliases->data;
+ fd->aliases = eina_list_remove(fd->aliases, fa);
+ if (fa->alias) eina_stringshare_del(fa->alias);
+ free(fa);
}
free(fd);
}
@@ -1344,59 +1361,22 @@ evas_object_text_font_string_parse(char *buffer, char dest[14][256])
i = 1;
while (p[i])
{
- dest[n][m] = p[i];
- if ((p[i] == '-') || (m == 255))
- {
- dest[n][m] = 0;
- n++;
- m = -1;
- }
- i++;
- m++;
- if (n == 14) return n;
+ dest[n][m] = p[i];
+ if ((p[i] == '-') || (m == 255))
+ {
+ dest[n][m] = 0;
+ n++;
+ m = -1;
+ }
+ i++;
+ m++;
+ if (n == 14) return n;
}
dest[n][m] = 0;
n++;
return n;
}
-EOLIAN void
-_evas_canvas_font_path_clear(Eo *eo_e EINA_UNUSED, Evas_Public_Data *evas)
-{
- evas_canvas_async_block(evas);
- while (evas->font_path)
- {
- eina_stringshare_del(evas->font_path->data);
- evas->font_path = eina_list_remove(evas->font_path, evas->font_path->data);
- }
-}
-
-EOLIAN void
-_evas_canvas_font_path_append(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e, const char *path)
-{
- if (!path) return;
- evas_canvas_async_block(e);
- e->font_path = eina_list_append(e->font_path, eina_stringshare_add(path));
-
- evas_font_init();
-}
-
-EOLIAN void
-_evas_canvas_font_path_prepend(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e, const char *path)
-{
- if (!path) return;
- evas_canvas_async_block(e);
- e->font_path = eina_list_prepend(e->font_path, eina_stringshare_add(path));
-
- evas_font_init();
-}
-
-EOLIAN const Eina_List*
-_evas_canvas_font_path_list(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e)
-{
- return e->font_path;
-}
-
EAPI void
evas_font_path_global_append(const char *path)
{
@@ -1439,103 +1419,6 @@ evas_font_path_global_list(void)
return global_font_path;
}
-void
-evas_font_object_rehint(Evas_Object *eo_obj)
-{
- Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
- if (obj->is_smart)
- {
- EINA_INLIST_FOREACH(evas_object_smart_members_get_direct(eo_obj), obj)
- evas_font_object_rehint(obj->object);
- }
- else
- {
- if (!strcmp(obj->type, "text"))
- _evas_object_text_rehint(eo_obj);
- if (!strcmp(obj->type, "textblock"))
- _evas_object_textblock_rehint(eo_obj);
- }
-}
-
-EAPI void
-evas_font_hinting_set(Eo *eo_e, Evas_Font_Hinting_Flags hinting)
-{
- Evas_Layer *lay;
-
- EVAS_LEGACY_API(eo_e, e);
- evas_canvas_async_block(e);
- if (e->hinting == hinting) return;
- e->hinting = hinting;
-
- EINA_INLIST_FOREACH(e->layers, lay)
- {
- Evas_Object_Protected_Data *obj;
-
- EINA_INLIST_FOREACH(lay->objects, obj)
- evas_font_object_rehint(obj->object);
- }
-}
-
-EAPI Evas_Font_Hinting_Flags
-evas_font_hinting_get(const Evas *eo_e)
-{
- EVAS_LEGACY_API(eo_e, e, EVAS_FONT_HINTING_NONE);
- return e->hinting;
-}
-
-EAPI Eina_Bool
-evas_font_hinting_can_hint(const Evas *eo_e, Evas_Font_Hinting_Flags hinting)
-{
- EVAS_LEGACY_API(eo_e, e, EINA_FALSE);
- if (e->engine.func->font_hinting_can_hint && _evas_engine_context(e))
- return e->engine.func->font_hinting_can_hint(_evas_engine_context(e),
- hinting);
- else return EINA_FALSE;
-}
-
-EOLIAN void
-_evas_canvas_font_cache_flush(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e)
-{
- evas_canvas_async_block(e);
- evas_render_rendering_wait(e);
- if (_evas_engine_context(e))
- e->engine.func->font_cache_flush(_evas_engine_context(e));
-}
-
-EOLIAN void
-_evas_canvas_font_cache_set(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e, int size)
-{
- if (size < 0) size = 0;
- evas_canvas_async_block(e);
- evas_render_rendering_wait(e);
- if (_evas_engine_context(e))
- e->engine.func->font_cache_set(_evas_engine_context(e), size);
-}
-
-EOLIAN int
-_evas_canvas_font_cache_get(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e)
-{
- if (_evas_engine_context(e))
- return e->engine.func->font_cache_get(_evas_engine_context(e));
- return -1;
-}
-
-EOLIAN Eina_List*
-_evas_canvas_font_available_list(Eo *eo_e, Evas_Public_Data *_pd EINA_UNUSED)
-{
- return evas_font_dir_available_list(eo_e);
-}
-
-EAPI void
-evas_font_available_list_free(Evas *eo_e, Eina_List *available)
-{
- MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS);
- return;
- MAGIC_CHECK_END();
-
- evas_font_dir_available_list_free(available);
-}
-
EAPI void
evas_font_reinit(void)
{
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:
EINA_LIST_FREE(e->obscures, r)
eina_rectangle_free(r);
- evas_fonts_zero_free(eo_e);
+ evas_fonts_zero_free();
evas_event_callback_all_del(eo_e);
evas_event_callback_cleanup(eo_e);
@@ -1289,6 +1289,139 @@ _evas_pointer_list_in_rect_get(Evas_Public_Data *edata, Evas_Object *obj,
return list;
}
+/* font related api */
+
+EOLIAN static void
+_evas_canvas_font_path_clear(Eo *eo_e EINA_UNUSED, Evas_Public_Data *evas)
+{
+ evas_canvas_async_block(evas);
+ while (evas->font_path)
+ {
+ eina_stringshare_del(evas->font_path->data);
+ evas->font_path = eina_list_remove(evas->font_path, evas->font_path->data);
+ }
+}
+
+EOLIAN static void
+_evas_canvas_font_path_append(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e, const char *path)
+{
+ if (!path) return;
+ evas_canvas_async_block(e);
+ e->font_path = eina_list_append(e->font_path, eina_stringshare_add(path));
+}
+
+EOLIAN static void
+_evas_canvas_font_path_prepend(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e, const char *path)
+{
+ if (!path) return;
+ evas_canvas_async_block(e);
+ e->font_path = eina_list_prepend(e->font_path, eina_stringshare_add(path));
+}
+
+EOLIAN static const Eina_List*
+_evas_canvas_font_path_list(const Eo *eo_e EINA_UNUSED, Evas_Public_Data *e)
+{
+ return e->font_path;
+}
+
+EOLIAN static void
+_evas_canvas_font_cache_flush(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e)
+{
+ evas_canvas_async_block(e);
+ evas_render_rendering_wait(e);
+ if (_evas_engine_context(e))
+ e->engine.func->font_cache_flush(_evas_engine_context(e));
+}
+
+EOLIAN static void
+_evas_canvas_font_cache_set(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e, int size)
+{
+ if (size < 0) size = 0;
+ evas_canvas_async_block(e);
+ evas_render_rendering_wait(e);
+ if (_evas_engine_context(e))
+ e->engine.func->font_cache_set(_evas_engine_context(e), size);
+}
+
+EOLIAN static int
+_evas_canvas_font_cache_get(Eo *eo_e EINA_UNUSED, Evas_Public_Data *e)
+{
+ if (_evas_engine_context(e))
+ return e->engine.func->font_cache_get(_evas_engine_context(e));
+ return -1;
+}
+
+EOLIAN static Eina_List*
+_evas_canvas_font_available_list(const Eo *eo_e EINA_UNUSED, Evas_Public_Data *pd)
+{
+ return evas_font_dir_available_list(pd->font_path);
+}
+
+static void
+evas_font_object_rehint(Evas_Object *eo_obj)
+{
+ Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
+ if (obj->is_smart)
+ {
+ EINA_INLIST_FOREACH(evas_object_smart_members_get_direct(eo_obj), obj)
+ evas_font_object_rehint(obj->object);
+ }
+ else
+ {
+ if (!strcmp(obj->type, "text"))
+ _evas_object_text_rehint(eo_obj);
+ if (!strcmp(obj->type, "textblock"))
+ _evas_object_textblock_rehint(eo_obj);
+ }
+}
+
+EAPI void
+evas_font_hinting_set(Eo *eo_e, Evas_Font_Hinting_Flags hinting)
+{
+ Evas_Layer *lay;
+
+ EVAS_LEGACY_API(eo_e, e);
+ evas_canvas_async_block(e);
+ if (e->hinting == hinting) return;
+ e->hinting = hinting;
+
+ EINA_INLIST_FOREACH(e->layers, lay)
+ {
+ Evas_Object_Protected_Data *obj;
+
+ EINA_INLIST_FOREACH(lay->objects, obj)
+ evas_font_object_rehint(obj->object);
+ }
+}
+
+EAPI Evas_Font_Hinting_Flags
+evas_font_hinting_get(const Evas *eo_e)
+{
+ EVAS_LEGACY_API(eo_e, e, EVAS_FONT_HINTING_NONE);
+ return e->hinting;
+}
+
+EAPI Eina_Bool
+evas_font_hinting_can_hint(const Evas *eo_e, Evas_Font_Hinting_Flags hinting)
+{
+ EVAS_LEGACY_API(eo_e, e, EINA_FALSE);
+ if (e->engine.func->font_hinting_can_hint && _evas_engine_context(e))
+ return e->engine.func->font_hinting_can_hint(_evas_engine_context(e),
+ hinting);
+ else return EINA_FALSE;
+}
+
+EAPI void
+evas_font_available_list_free(Evas *eo_e, Eina_List *available)
+{
+ MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS);
+ return;
+ MAGIC_CHECK_END();
+
+ evas_font_dir_available_list_free(available);
+}
+
+
/* Legacy EAPI */
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)
/* DO IT */
if (o->font)
{
- evas_font_free(obj->layer->evas->evas, o->font);
+ evas_font_free(o->font);
o->font = NULL;
}
- o->font = evas_font_load(obj->layer->evas->evas, o->cur.fdesc, o->cur.source,
- (int)(((double) o->cur.size) * obj->cur->scale), o->cur.bitmap_scalable);
+ o->font = evas_font_load(obj->layer->evas->font_path,
+ obj->layer->evas->hinting,
+ o->cur.fdesc, o->cur.source,
+ (int)(((double) o->cur.size) * obj->cur->scale),
+ o->cur.bitmap_scalable);
{
o->ascent = 0;
o->descent = 0;
@@ -1657,7 +1660,7 @@ evas_object_text_free(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
if (o->bidi_delimiters) eina_stringshare_del(o->bidi_delimiters);
if (o->cur.text) free(o->cur.text);
if (o->font && obj->layer && obj->layer->evas)
- evas_font_free(obj->layer->evas->evas, o->font);
+ evas_font_free(o->font);
o->font = NULL;
o->cur.utf8_text = NULL;
o->cur.font = NULL;
@@ -2241,8 +2244,7 @@ _evas_object_text_rehint(Evas_Object *eo_obj)
Eina_List *was = NULL;
if (!o->font) return;
- evas_font_load_hinting_set(obj->layer->evas->evas, o->font,
- obj->layer->evas->hinting);
+ evas_font_load_hinting_set(o->font, obj->layer->evas->hinting);
was = _evas_pointer_list_in_rect_get(obj->layer->evas, eo_obj, obj, 1, 1);
/* DO II */
_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
fmt->gfx_filter = NULL;
}
if ((obj->layer) && (obj->layer->evas))
- evas_font_free(obj->layer->evas->evas, fmt->font.font);
+ evas_font_free(fmt->font.font);
free(fmt);
}
@@ -2835,8 +2835,12 @@ _format_dup(Evas_Object *eo_obj, const Evas_Object_Textblock_Format *fmt)
if (fmt->font.source) fmt2->font.source = eina_stringshare_add(fmt->font.source);
/* FIXME: just ref the font here... */
- fmt2->font.font = evas_font_load(obj->layer->evas->evas, fmt2->font.fdesc,
- fmt2->font.source, (int)(((double) fmt2->font.size) * obj->cur->scale), fmt2->font.bitmap_scalable);
+ fmt2->font.font = evas_font_load(obj->layer->evas->font_path,
+ obj->layer->evas->hinting,
+ fmt2->font.fdesc,
+ fmt2->font.source,
+ (int)(((double) fmt2->font.size) * obj->cur->scale),
+ fmt2->font.bitmap_scalable);
if (fmt->gfx_filter)
{
@@ -3392,8 +3396,12 @@ _layout_format_push(Ctxt *c, Evas_Object_Textblock_Format *fmt,
fmt->font.fdesc->slant = _FMT_INFO(font_slant);
fmt->font.fdesc->width = _FMT_INFO(font_width);
fmt->font.fdesc->lang = _FMT_INFO(font_lang);
- fmt->font.font = evas_font_load(evas_obj->layer->evas->evas, fmt->font.fdesc,
- fmt->font.source, (int)(((double) _FMT_INFO(size)) * evas_obj->cur->scale), fmt->font.bitmap_scalable);
+ fmt->font.font = evas_font_load(evas_obj->layer->evas->font_path,
+ evas_obj->layer->evas->hinting,
+ fmt->font.fdesc,
+ fmt->font.source,
+ (int)(((double) _FMT_INFO(size)) * evas_obj->cur->scale),
+ fmt->font.bitmap_scalable);
}
if (_FMT_INFO(gfx_filter_name))
{
@@ -4276,7 +4284,7 @@ _text_item_update_sizes(Ctxt *c, Evas_Object_Textblock_Text_Item *ti)
if (shx1 < minx) minx = shx1;
if (shx2 > maxx) maxx = shx2;
ti->x_adjustment = maxx - minx;
-
+
ti->parent.w = tw + ti->x_adjustment;
ti->parent.h = th;
ti->parent.adv = advw;
@@ -4538,9 +4546,13 @@ _format_finalize(Evas_Object *eo_obj, Evas_Object_Textblock_Format *fmt)
of = fmt->font.font;
- fmt->font.font = evas_font_load(obj->layer->evas->evas, fmt->font.fdesc,
- fmt->font.source, (int)(((double) fmt->font.size) * obj->cur->scale), fmt->font.bitmap_scalable);
- if (of) evas_font_free(obj->layer->evas->evas, of);
+ fmt->font.font = evas_font_load(obj->layer->evas->font_path,
+ obj->layer->evas->hinting,
+ fmt->font.fdesc,
+ fmt->font.source,
+ (int)(((double) fmt->font.size) * obj->cur->scale),
+ fmt->font.bitmap_scalable);
+ if (of) evas_font_free(of);
}
static Efl_Canvas_Text_Filter_Program *
@@ -4666,11 +4678,11 @@ _layout_do_format(const Evas_Object *obj, Ctxt *c,
// item size=20x10 href=name
// item relsize=20x10 href=name
// item abssize=20x10 href=name
- //
+ //
// optional arguments:
// vsize=full
// vsize=ascent
- //
+ //
// size == item size (modifies line size) - can be multiplied by
// scale factor
// 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
* that don't intersect in whole) will be split, and the rest are set to be
* visually-deleted.
* Note that a special case for visible format items does not
- * split them, but instead just visually-deletes them (because there are no
+ * split them, but instead just visually-deletes them (because there are no
* characters to split).
*/
static inline void
@@ -7903,7 +7915,7 @@ _evas_object_textblock_text_markup_get(Eo *eo_obj, Efl_Canvas_Text_Data *o)
{
Eina_Unicode tmp_ch;
off += fnode->offset;
-
+
if (off > len) break;
/* No need to skip on the first run */
tmp_ch = text[off];
@@ -14597,9 +14609,8 @@ _evas_object_textblock_rehint(Evas_Object *eo_obj)
Evas_Object_Textblock_Text_Item *ti = _ITEM_TEXT(it);
if (ti->parent.format->font.font)
{
- evas_font_load_hinting_set(obj->layer->evas->evas,
- ti->parent.format->font.font,
- obj->layer->evas->hinting);
+ evas_font_load_hinting_set(ti->parent.format->font.font,
+ obj->layer->evas->hinting);
}
}
}
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)
}
static void
-evas_object_textgrid_free(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
+evas_object_textgrid_free(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj EINA_UNUSED)
{
Evas_Object_Textgrid_Color *c;
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)
if (o->cur.font_description_normal)
evas_font_desc_unref(o->cur.font_description_normal);
- if (o->font_normal) evas_font_free(obj->layer->evas->evas, o->font_normal);
- if (o->font_bold) evas_font_free(obj->layer->evas->evas, o->font_bold);
- if (o->font_italic) evas_font_free(obj->layer->evas->evas, o->font_italic);
- if (o->font_bolditalic) evas_font_free(obj->layer->evas->evas, o->font_bolditalic);
+ if (o->font_normal) evas_font_free(o->font_normal);
+ if (o->font_bold) evas_font_free(o->font_bold);
+ if (o->font_italic) evas_font_free(o->font_italic);
+ if (o->font_bolditalic) evas_font_free(o->font_bolditalic);
if (o->cur.cells) free(o->cur.cells);
while ((c = eina_array_pop(&o->cur.palette_standard)))
@@ -784,17 +784,17 @@ evas_object_textgrid_render_pre(Evas_Object *eo_obj,
if (r->ch1 >= 0)
{
Evas_Coord chx, chy, chw, chh;
-
+
chx = r->ch1 * o->cur.char_width;
chy = i * o->cur.char_height;
chw = (r->ch2 - r->ch1 + 1) * o->cur.char_width;
chh = o->cur.char_height;
-
+
chx -= o->cur.char_width;
chy -= o->cur.char_height;
chw += o->cur.char_width * 2;
chh += o->cur.char_height * 2;
-
+
chx += obj->cur->geometry.x;
chy += obj->cur->geometry.y;
RECTS_CLIP_TO_RECT(chx, chy, chw, chh,
@@ -808,7 +808,7 @@ evas_object_textgrid_render_pre(Evas_Object *eo_obj,
}
}
}
-
+
done:
o->core_change = 0;
o->row_change = 0;
@@ -1003,11 +1003,12 @@ _alternate_font_weight_slant(Evas_Object_Protected_Data *obj,
int ret = -1;
Evas_Font_Set *font;
- font = evas_font_load(obj->layer->evas->evas,
+ font = evas_font_load(obj->layer->evas->font_path,
+ obj->layer->evas->hinting,
fdesc,
o->cur.font_source,
(int)(((double) o->cur.font_size) *
- obj->cur->scale),
+ obj->cur->scale),
o->cur.bitmap_scalable);
if (font)
{
@@ -1040,7 +1041,7 @@ _alternate_font_weight_slant(Evas_Object_Protected_Data *obj,
(o->cur.char_height != vadvance) ||
(o->ascent != ascent))
{
- evas_font_free(obj->layer->evas->evas, font);
+ evas_font_free(font);
}
else
{
@@ -1080,16 +1081,17 @@ _evas_textgrid_font_reload(Eo *eo_obj, Evas_Textgrid_Data *o)
if (o->font_normal)
{
- evas_font_free(obj->layer->evas->evas, o->font_normal);
+ evas_font_free(o->font_normal);
o->font_normal = NULL;
}
- o->font_normal = evas_font_load(obj->layer->evas->evas,
- o->cur.font_description_normal,
- o->cur.font_source,
- (int)(((double) o->cur.font_size) *
- obj->cur->scale),
- o->cur.bitmap_scalable);
+ o->font_normal = evas_font_load(obj->layer->evas->font_path,
+ obj->layer->evas->hinting,
+ o->cur.font_description_normal,
+ o->cur.font_source,
+ (int)(((double) o->cur.font_size) *
+ obj->cur->scale),
+ o->cur.bitmap_scalable);
if (o->font_normal)
{
Eina_Unicode W[2] = { 'O', 0 };
@@ -1133,7 +1135,7 @@ _evas_textgrid_font_reload(Eo *eo_obj, Evas_Textgrid_Data *o)
/* Bold */
if (o->font_bold)
{
- evas_font_free(obj->layer->evas->evas, o->font_bold);
+ evas_font_free(o->font_bold);
o->font_bold = NULL;
}
if ((fdesc->weight == EVAS_FONT_WEIGHT_NORMAL) ||
@@ -1153,7 +1155,7 @@ _evas_textgrid_font_reload(Eo *eo_obj, Evas_Textgrid_Data *o)
/* Italic */
if (o->font_italic)
{
- evas_font_free(obj->layer->evas->evas, o->font_italic);
+ evas_font_free(o->font_italic);
o->font_italic = NULL;
}
if (fdesc->slant == EVAS_FONT_SLANT_NORMAL)
@@ -1180,7 +1182,7 @@ _evas_textgrid_font_reload(Eo *eo_obj, Evas_Textgrid_Data *o)
/* BoldItalic */
if (o->font_bolditalic)
{
- evas_font_free(obj->layer->evas->evas, o->font_bolditalic);
+ evas_font_free(o->font_bolditalic);
o->font_bolditalic = NULL;
}
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,
default:
return;
}
-
+
if (idx >= (int)eina_array_count(palette)) return;
color = eina_array_data_get(palette, idx);
if (!color) return;
@@ -1437,16 +1439,16 @@ _evas_textgrid_update_add(Eo *eo_obj, Evas_Textgrid_Data *o, int x, int y, int w
{
Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
int i, x2;
-
+
RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, o->cur.w, o->cur.h);
if ((w <= 0) || (h <= 0)) return;
-
+
evas_object_async_block(obj);
x2 = x + w - 1;
for (i = 0; i < h; i++)
{
Evas_Object_Textgrid_Row *r = &(o->cur.rows[y + i]);
-
+
if (r->ch1 < 0)
{
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)
evas_render_rendering_wait(evas);
- evas_fonts_zero_pressure(eo_e);
+ evas_fonts_zero_pressure();
if (ENFN && ENFN->output_idle_flush)
{
@@ -4125,7 +4125,7 @@ _evas_canvas_render_dump(Eo *eo_e, Evas_Public_Data *evas)
GC_ALL(evas_object_image_load_opts_cow);
GC_ALL(evas_object_image_state_cow);
- evas_fonts_zero_pressure(eo_e);
+ evas_fonts_zero_pressure();
if (ENFN && ENFN->output_idle_flush)
{
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)
// wait for rendering to finish so we don't mess up shared resources
_evas_render2_wait(eo_e);
// clean fonts
- evas_fonts_zero_pressure(eo_e);
+ evas_fonts_zero_pressure();
// call engine idle flush call
if ((e->engine.func) && (e->engine.func->output_idle_flush) &&
(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 @@
#ifndef _EVAS_FONT_H
#define _EVAS_FONT_H
+
+typedef unsigned char DATA8;
+typedef unsigned long long DATA64;
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_GLYPH_H
+#include FT_SIZES_H
+#include FT_MODULE_H
+
+#ifndef FT_HAS_COLOR
+# define FT_HAS_COLOR(face) 0
+#endif
+
+#ifndef FT_LOAD_COLOR
+# define FT_LOAD_COLOR FT_LOAD_DEFAULT
+#endif
+
+#ifdef EAPI
+# undef EAPI
+#endif
+
+#ifdef _WIN32
+# ifdef EFL_EVAS_BUILD
+# ifdef DLL_EXPORT
+# define EAPI __declspec(dllexport)
+# else
+# define EAPI
+# endif /* ! DLL_EXPORT */
+# else
+# define EAPI __declspec(dllimport)
+# endif /* ! EFL_EVAS_BUILD */
+#else
+# ifdef __GNUC__
+# if __GNUC__ >= 4
+# define EAPI __attribute__ ((visibility("default")))
+# else
+# define EAPI
+# endif
+# else
+# define EAPI
+# endif
+#endif /* ! _WIN32 */
+
+#include <Eina.h>
+
+#define LK(x) Eina_Lock x
+#define LKU(x) eina_lock_release(&(x))
+#define LKL(x) eina_lock_take(&(x))
+#define LKD(x) eina_lock_free(&(x))
+
#include "evas_text_utils.h"
+
+enum _Evas_Font_Style
+{
+ EVAS_FONT_STYLE_SLANT,
+ EVAS_FONT_STYLE_WEIGHT,
+ EVAS_FONT_STYLE_WIDTH
+};
+
+enum _Evas_Font_Slant
+{
+ EVAS_FONT_SLANT_NORMAL,
+ EVAS_FONT_SLANT_OBLIQUE,
+ EVAS_FONT_SLANT_ITALIC
+};
+
+enum _Evas_Font_Weight
+{
+ EVAS_FONT_WEIGHT_NORMAL,
+ EVAS_FONT_WEIGHT_THIN,
+ EVAS_FONT_WEIGHT_ULTRALIGHT,
+ EVAS_FONT_WEIGHT_EXTRALIGHT,
+ EVAS_FONT_WEIGHT_LIGHT,
+ EVAS_FONT_WEIGHT_BOOK,
+ EVAS_FONT_WEIGHT_MEDIUM,
+ EVAS_FONT_WEIGHT_SEMIBOLD,
+ EVAS_FONT_WEIGHT_BOLD,
+ EVAS_FONT_WEIGHT_ULTRABOLD,
+ EVAS_FONT_WEIGHT_EXTRABOLD,
+ EVAS_FONT_WEIGHT_BLACK,
+ EVAS_FONT_WEIGHT_EXTRABLACK
+};
+
+enum _Evas_Font_Width
+{
+ EVAS_FONT_WIDTH_NORMAL,
+ EVAS_FONT_WIDTH_ULTRACONDENSED,
+ EVAS_FONT_WIDTH_EXTRACONDENSED,
+ EVAS_FONT_WIDTH_CONDENSED,
+ EVAS_FONT_WIDTH_SEMICONDENSED,
+ EVAS_FONT_WIDTH_SEMIEXPANDED,
+ EVAS_FONT_WIDTH_EXPANDED,
+ EVAS_FONT_WIDTH_EXTRAEXPANDED,
+ EVAS_FONT_WIDTH_ULTRAEXPANDED
+};
+
+enum _Evas_Font_Spacing
+{
+ EVAS_FONT_SPACING_PROPORTIONAL,
+ EVAS_FONT_SPACING_DUAL,
+ EVAS_FONT_SPACING_MONO,
+ EVAS_FONT_SPACING_CHARCELL
+};
+
+typedef enum _Evas_Font_Style Evas_Font_Style;
+typedef enum _Evas_Font_Slant Evas_Font_Slant;
+typedef enum _Evas_Font_Weight Evas_Font_Weight;
+typedef enum _Evas_Font_Width Evas_Font_Width;
+typedef enum _Evas_Font_Spacing Evas_Font_Spacing;
+
+typedef struct _Evas_Font_Dir Evas_Font_Dir;
+typedef struct _Evas_Font Evas_Font;
+typedef struct _Evas_Font_Alias Evas_Font_Alias;
+typedef struct _Evas_Font_Description Evas_Font_Description;
+
+
+typedef struct _RGBA_Font RGBA_Font;
+typedef struct _RGBA_Font_Int RGBA_Font_Int;
+typedef struct _RGBA_Font_Source RGBA_Font_Source;
+typedef struct _RGBA_Font_Glyph RGBA_Font_Glyph;
+typedef struct _RGBA_Font_Glyph_Out RGBA_Font_Glyph_Out;
+
+typedef struct _Fash_Item_Index_Map Fash_Item_Index_Map;
+typedef struct _Fash_Int_Map Fash_Int_Map;
+typedef struct _Fash_Int_Map2 Fash_Int_Map2;
+typedef struct _Fash_Int Fash_Int;
+
+
+struct _Fash_Item_Index_Map
+{
+ RGBA_Font_Int *fint;
+ int index;
+};
+struct _Fash_Int_Map
+{
+ Fash_Item_Index_Map item[256];
+};
+struct _Fash_Int_Map2
+{
+ Fash_Int_Map *bucket[256];
+};
+struct _Fash_Int
+{
+ Fash_Int_Map2 *bucket[256];
+ void (*freeme) (Fash_Int *fash);
+};
+
+typedef struct _Fash_Glyph_Map Fash_Glyph_Map;
+typedef struct _Fash_Glyph_Map2 Fash_Glyph_Map2;
+typedef struct _Fash_Glyph Fash_Glyph;
+struct _Fash_Glyph_Map
+{
+ RGBA_Font_Glyph *item[256];
+};
+struct _Fash_Glyph_Map2
+{
+ Fash_Glyph_Map *bucket[256];
+};
+struct _Fash_Glyph
+{
+ Fash_Glyph_Map2 *bucket[256];
+ void (*freeme) (Fash_Glyph *fash);
+};
+
+
+typedef enum _Font_Hint_Flags
+{
+ FONT_NO_HINT,
+ FONT_AUTO_HINT,
+ FONT_BYTECODE_HINT
+} Font_Hint_Flags;
+
+typedef enum _Font_Rend_Flags
+{
+ FONT_REND_REGULAR = 0,
+ FONT_REND_SLANT = (1 << 0),
+ FONT_REND_WEIGHT = (1 << 1),
+} Font_Rend_Flags;
+
+struct _RGBA_Font
+{
+ Eina_List *fonts;
+ Fash_Int *fash;
+ Font_Hint_Flags hinting;
+ int references;
+ LK(lock);
+ unsigned char sizeok : 1;
+};
+
+
+struct _Evas_Font_Dir
+{
+ Eina_Hash *lookup;
+ Eina_List *fonts;
+ Eina_List *aliases;
+ DATA64 dir_mod_time;
+ DATA64 fonts_dir_mod_time;
+ DATA64 fonts_alias_mod_time;
+};
+
+struct _Evas_Font
+{
+ struct {
+ const char *prop[14];
+ } x;
+ struct {
+ const char *name;
+ } simple;
+ const char *path;
+ char type;
+};
+
+struct _Evas_Font_Alias
+{
+ const char *alias;
+ Evas_Font *fn;
+};
+
+struct _Evas_Font_Description
+{
+ int ref;
+ Eina_Stringshare *name;
+ Eina_Stringshare *fallbacks;
+ Eina_Stringshare *lang;
+ Eina_Stringshare *style;
+
+ Evas_Font_Slant slant;
+ Evas_Font_Weight weight;
+ Evas_Font_Width width;
+ Evas_Font_Spacing spacing;
+
+ Eina_Bool is_new : 1;
+};
+
+struct _RGBA_Font_Int
+{
+ EINA_INLIST;
+ RGBA_Font_Source *src;
+ Eina_Hash *kerning;
+ Fash_Glyph *fash;
+ unsigned int size;
+ float scale_factor;
+ int real_size;
+ int max_h;
+ int references;
+ int usage;
+ struct {
+ FT_Size size;
+#ifdef USE_HARFBUZZ
+ void *hb_font;
+#endif
+ } ft;
+ LK(ft_mutex);
+ Font_Hint_Flags hinting;
+ Font_Rend_Flags wanted_rend; /* The wanted rendering style */
+ Font_Rend_Flags runtime_rend; /* The rendering we need to do on runtime
+ in order to comply with the wanted_rend. */
+
+ Eina_List *task;
+#ifdef EVAS_CSERVE2
+ void *cs2_handler;
+#endif
+
+ int generation;
+
+ Efl_Text_Font_Bitmap_Scalable bitmap_scalable;
+
+ unsigned char sizeok : 1;
+ unsigned char inuse : 1;
+};
+
+struct _RGBA_Font_Source
+{
+ const char *name;
+ const char *file;
+ void *data;
+ unsigned int current_size;
+ int data_size;
+ int references;
+ struct {
+ int orig_upem;
+ FT_Face face;
+ } ft;
+};
+
+/*
+ * laziness wins for now. The parts used from the freetpye struct are
+ * kept intact to avoid changing the code using it until we know exactly
+ * what needs to be changed
+ */
+struct _RGBA_Font_Glyph_Out
+{
+ unsigned char *rle;
+ struct {
+ unsigned char *buffer;
+ unsigned short rows;
+ unsigned short width;
+ unsigned short pitch;
+ unsigned short rle_alloc : 1;
+ unsigned short no_free_glout : 1;
+ } bitmap;
+ int rle_size;
+};
+
+struct _RGBA_Font_Glyph
+{
+ FT_UInt index;
+ Evas_Coord width;
+ Evas_Coord x_bear;
+ Evas_Coord y_bear;
+ FT_Glyph glyph;
+ RGBA_Font_Glyph_Out *glyph_out;
+ /* this is a problem - only 1 engine at a time can extend such a font... grrr */
+ void *ext_dat;
+ void (*ext_dat_free) (void *ext_dat);
+ RGBA_Font_Int *fi;
+};
+
+
/* The tangent of the slant angle we do on runtime. */
#define _EVAS_FONT_SLANT_TAN 0.221694663
+
/* main */
EAPI void evas_common_font_init (void);
@@ -23,20 +343,9 @@ EAPI int evas_common_font_instance_underline_thickness_get (R
EAPI int evas_common_font_get_line_advance (RGBA_Font *fn);
void *evas_common_font_freetype_face_get(RGBA_Font *font); /* XXX: Not EAPI on purpose. Not ment to be used in modules. */
-/* draw */
-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);
-
-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);
-EAPI void evas_common_font_draw (RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, Evas_Glyph_Array *glyphs);
-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);
-EAPI int evas_common_font_glyph_search (RGBA_Font *fn, RGBA_Font_Int **fi_ret, Eina_Unicode gl);
EAPI RGBA_Font_Glyph *evas_common_font_int_cache_glyph_get (RGBA_Font_Int *fi, FT_UInt index);
EAPI Eina_Bool evas_common_font_int_cache_glyph_render(RGBA_Font_Glyph *fg);
EAPI FT_UInt evas_common_get_char_index (RGBA_Font_Int* fi, Eina_Unicode gl);
-EAPI void evas_common_font_draw_init (void);
-EAPI void evas_common_font_draw_prepare (Evas_Text_Props *text_props);
-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);
-EAPI Eina_Bool evas_common_font_draw_prepare_cutout(Cutout_Rects **reuse, RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Gfx_Func *func);
/* load */
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
EAPI void evas_common_font_ascent_descent_get(RGBA_Font *fn, const Evas_Text_Props *text_props, int *ascent, int *descent);
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);
-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);
EAPI DATA8 *evas_common_font_glyph_uncompress(RGBA_Font_Glyph *fg, int *wret, int *hret);
+EAPI int evas_common_font_glyph_search (RGBA_Font *fn, RGBA_Font_Int **fi_ret, Eina_Unicode gl);
void evas_common_font_load_init(void);
void evas_common_font_load_shutdown(void);
+void evas_font_dir_cache_free(void);
+const char *evas_font_dir_cache_find(char *dir, char *font);
+Eina_List *evas_font_dir_available_list(const Eina_List *font_paths);
+void evas_font_dir_available_list_free(Eina_List *available);
+void evas_font_free(void *font);
+void evas_fonts_zero_free();
+void evas_fonts_zero_pressure();
+void evas_font_name_parse(Evas_Font_Description *fdesc, const char *name);
+int evas_font_style_find(const char *start, const char *end, Evas_Font_Style style);
+Evas_Font_Description *evas_font_desc_new(void);
+Evas_Font_Description *evas_font_desc_dup(const Evas_Font_Description *fdesc);
+void evas_font_desc_unref(Evas_Font_Description *fdesc);
+int evas_font_desc_cmp(const Evas_Font_Description *a, const Evas_Font_Description *b);
+Evas_Font_Description *evas_font_desc_ref(Evas_Font_Description *fdesc);
+const char *evas_font_lang_normalize(const char *lang);
+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);
+void evas_font_load_hinting_set(void *font, int hinting);
+
+#undef EAPI
+#define EAPI
+
#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 @@
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <assert.h>
-
-#include "evas_common_private.h"
-#include "evas_private.h"
-
#include "evas_font_private.h"
-#include "evas_blend_private.h"
-#include "draw.h"
#ifdef EVAS_CSERVE2
# include "../cserve2/evas_cs2_private.h"
#endif
-#include FT_OUTLINE_H
-#include FT_SYNTHESIS_H
-
// XXX:
// XXX: adapt cserve2 to this!
// XXX:
@@ -128,7 +114,7 @@ alpha8to4(int a8)
// [char] second byte of RLE data
// ...
// [char] last byte of RLE data
-//
+//
static DATA8 *
compress_rle4(DATA8 *src, int pitch, int w, int h, int *size_ret)
{
@@ -247,7 +233,7 @@ static void
decompress_full_row(DATA8 *src, int start, int end, DATA8 *dst)
{
DATA8 *p = src + start, *e = src + end, *d = dst, len, val;
-
+
while (p < e)
{
// length is upper 4 bits + 1
@@ -377,7 +363,7 @@ decompress_bpp4(DATA8 *src, DATA8 *dst, int pitch, int w, int h)
{
int pitch2, x, y;
DATA8 *d, *s, val;
-
+
// deal with source pixel to round up for odd length rows
pitch2 = (w + 1) / 2;
// skip header int
@@ -462,7 +448,7 @@ evas_common_font_glyph_uncompress(RGBA_Font_Glyph *fg, int *wret, int *hret)
RGBA_Font_Glyph_Out *fgo = fg->glyph_out;
DATA8 *buf = calloc(1, fgo->bitmap.width * fgo->bitmap.rows);
int *iptr;
-
+
if (!buf) return NULL;
if (wret) *wret = fgo->bitmap.width;
if (hret) *hret = fgo->bitmap.rows;
@@ -475,154 +461,3 @@ evas_common_font_glyph_uncompress(RGBA_Font_Glyph *fg, int *wret, int *hret)
fgo->bitmap.width, fgo->bitmap.rows);
return buf;
}
-
-// this draws a compressed font glyph and decompresses on the fly as it
-// draws, saving memory bandwidth and providing speedups
-EAPI void
-evas_common_font_glyph_draw(RGBA_Font_Glyph *fg,
- RGBA_Draw_Context *dc,
- RGBA_Image *dst_image, int dst_pitch,
- int dx, int dy, int dw, int dh, int cx, int cy, int cw, int ch)
-{
- RGBA_Font_Glyph_Out *fgo = fg->glyph_out;
- int x, y, w, h, x1, x2, y1, y2, i, *iptr;
- DATA32 *dst = dst_image->image.data;
- DATA32 coltab[16], col;
- DATA16 mtab[16], v;
-
- // FIXME: Use dw, dh for scaling glyphs...
- (void) dw;
- (void) dh;
- x = dx;
- y = dy;
- w = fgo->bitmap.width; h = fgo->bitmap.rows;
- // skip if totally clipped out
- if ((y >= (cy + ch)) || ((y + h) <= cy) ||
- (x >= (cx + cw)) || ((x + w) <= cx)) return;
- // figure y1/y2 limit range
- y1 = 0; y2 = h;
- if ((y + y1) < cy) y1 = cy - y;
- if ((y + y2) > (cy + ch)) y2 = cy + ch - y;
- // figure x1/x2 limit range
- x1 = 0; x2 = w;
- if ((x + x1) < cx) x1 = cx - x;
- if ((x + x2) > (cx + cw)) x2 = cx + cw - x;
- col = dc->col.col;
- if (dst_image->cache_entry.space == EVAS_COLORSPACE_GRY8)
- {
- // FIXME: Font draw not optimized for Alpha targets! SLOW!
- // This is not pretty :)
-
- DATA8 *src8, *dst8;
- Draw_Func_Alpha func;
- int row;
-
- if (EINA_UNLIKELY(x < 0))
- {
- x1 += (-x);
- x = 0;
- if ((x2 - x1) <= 0) return;
- }
- if (EINA_UNLIKELY(y < 0))
- {
- y1 += (-y);
- y = 0;
- if ((y2 - y1) <= 0) return;
- }
-
- dst8 = dst_image->image.data8 + x + (y * dst_pitch);
- func = efl_draw_alpha_func_get(dc->render_op, EINA_FALSE);
- src8 = evas_common_font_glyph_uncompress(fg, NULL, NULL);
- if (!src8) return;
-
- for (row = y1; row < y2; row++)
- {
- DATA8 *d = dst8 + ((row - y1) * dst_pitch);
- DATA8 *s = src8 + (row * w) + x1;
- func(d, s, x2 - x1);
- }
- free(src8);
- }
- else if (dc->clip.mask)
- {
- RGBA_Gfx_Func func;
- DATA8 *src8, *mask;
- DATA32 *buf, *ptr, *buf_ptr;
- RGBA_Image *im = dc->clip.mask;
- int row;
-
- buf = alloca(sizeof(DATA32) * w * h);
-
- // Adjust clipping info
- if (EINA_UNLIKELY((x + x1) < dc->clip.mask_x))
- x1 = dc->clip.mask_x - x;
- if (EINA_UNLIKELY((y + y1) < dc->clip.mask_y))
- y1 = dc->clip.mask_y - y;
- if (EINA_UNLIKELY((x + x2) > (int)(x + x1 + im->cache_entry.w)))
- x2 = x1 + im->cache_entry.w;
- if (EINA_UNLIKELY((y + y2) > (int)(y + y1 + im->cache_entry.h)))
- y2 = y1 + im->cache_entry.h;
-
- // Step 1: alpha glyph drawing
- src8 = evas_common_font_glyph_uncompress(fg, NULL, NULL);
- if (!src8) return;
-
- // Step 2: color blending to buffer
- func = evas_common_gfx_func_composite_mask_color_span_get(col, dst_image->cache_entry.flags.alpha, 1, EVAS_RENDER_COPY);
- for (row = y1; row < y2; row++)
- {
- buf_ptr = buf + (row * w) + x1;
- DATA8 *s = src8 + (row * w) + x1;
- func(NULL, s, col, buf_ptr, x2 - x1);
- }
- free(src8);
-
- // Step 3: masking to destination
- 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);
- for (row = y1; row < y2; row++)
- {
- mask = im->image.data8
- + (y + row - dc->clip.mask_y) * im->cache_entry.w
- + (x + x1 - dc->clip.mask_x);
-
- ptr = dst + (x + x1) + ((y + row) * dst_pitch);
- buf_ptr = buf + (row * w) + x1;
- func(buf_ptr, mask, 0, ptr, w);
- }
- }
- else
- {
- // build fast multiply + mask color tables to avoid compute. this works
- // because of our very limited 4bit range of alpha values
- for (i = 0; i <= 0xf; i++)
- {
- v = (i << 4) | i;
- coltab[i] = MUL_SYM(v, col);
- mtab[i] = 256 - (coltab[i] >> 24);
- }
-#ifdef BUILD_MMX
- if (evas_common_cpu_has_feature(CPU_FEATURE_MMX))
- {
-#define MMX 1
-#include "evas_font_compress_draw.c"
-#undef MMX
- }
- else
-#endif
-
-#ifdef BUILD_NEON
- if (evas_common_cpu_has_feature(CPU_FEATURE_NEON))
- {
-#define NEON 1
-#include "evas_font_compress_draw.c"
-#undef NEON
- }
- else
-#endif
-
- // Plain C
- {
-#include "evas_font_compress_draw.c"
- }
- }
-}
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 @@
-#include "evas_common_private.h"
+#include "evas_font_draw.h"
#include "evas_private.h"
#include "evas_blend_private.h"
@@ -6,6 +6,7 @@
#include "evas_font_private.h" /* for Frame-Queuing support */
#include "evas_font_ot.h"
+#include "draw.h"
#ifdef EVAS_CSERVE2
#include "../cserve2/evas_cs2_private.h"
@@ -507,3 +508,154 @@ evas_common_font_draw_prepare_cutout(Cutout_Rects **reuse, RGBA_Image *dst, RGBA
return EINA_TRUE;
}
+// this draws a compressed font glyph and decompresses on the fly as it
+// draws, saving memory bandwidth and providing speedups
+EAPI void
+evas_common_font_glyph_draw(RGBA_Font_Glyph *fg,
+ RGBA_Draw_Context *dc,
+ RGBA_Image *dst_image, int dst_pitch,
+ int dx, int dy, int dw, int dh, int cx, int cy, int cw, int ch)
+{
+ RGBA_Font_Glyph_Out *fgo = fg->glyph_out;
+ int x, y, w, h, x1, x2, y1, y2, i, *iptr;
+ DATA32 *dst = dst_image->image.data;
+ DATA32 coltab[16], col;
+ DATA16 mtab[16], v;
+
+ // FIXME: Use dw, dh for scaling glyphs...
+ (void) dw;
+ (void) dh;
+ x = dx;
+ y = dy;
+ w = fgo->bitmap.width; h = fgo->bitmap.rows;
+ // skip if totally clipped out
+ if ((y >= (cy + ch)) || ((y + h) <= cy) ||
+ (x >= (cx + cw)) || ((x + w) <= cx)) return;
+ // figure y1/y2 limit range
+ y1 = 0; y2 = h;
+ if ((y + y1) < cy) y1 = cy - y;
+ if ((y + y2) > (cy + ch)) y2 = cy + ch - y;
+ // figure x1/x2 limit range
+ x1 = 0; x2 = w;
+ if ((x + x1) < cx) x1 = cx - x;
+ if ((x + x2) > (cx + cw)) x2 = cx + cw - x;
+ col = dc->col.col;
+ if (dst_image->cache_entry.space == EVAS_COLORSPACE_GRY8)
+ {
+ // FIXME: Font draw not optimized for Alpha targets! SLOW!
+ // This is not pretty :)
+
+ DATA8 *src8, *dst8;
+ Draw_Func_Alpha func;
+ int row;
+
+ if (EINA_UNLIKELY(x < 0))
+ {
+ x1 += (-x);
+ x = 0;
+ if ((x2 - x1) <= 0) return;
+ }
+ if (EINA_UNLIKELY(y < 0))
+ {
+ y1 += (-y);
+ y = 0;
+ if ((y2 - y1) <= 0) return;
+ }
+
+ dst8 = dst_image->image.data8 + x + (y * dst_pitch);
+ func = efl_draw_alpha_func_get(dc->render_op, EINA_FALSE);
+ src8 = evas_common_font_glyph_uncompress(fg, NULL, NULL);
+ if (!src8) return;
+
+ for (row = y1; row < y2; row++)
+ {
+ DATA8 *d = dst8 + ((row - y1) * dst_pitch);
+ DATA8 *s = src8 + (row * w) + x1;
+ func(d, s, x2 - x1);
+ }
+ free(src8);
+ }
+ else if (dc->clip.mask)
+ {
+ RGBA_Gfx_Func func;
+ DATA8 *src8, *mask;
+ DATA32 *buf, *ptr, *buf_ptr;
+ RGBA_Image *im = dc->clip.mask;
+ int row;
+
+ buf = alloca(sizeof(DATA32) * w * h);
+
+ // Adjust clipping info
+ if (EINA_UNLIKELY((x + x1) < dc->clip.mask_x))
+ x1 = dc->clip.mask_x - x;
+ if (EINA_UNLIKELY((y + y1) < dc->clip.mask_y))
+ y1 = dc->clip.mask_y - y;
+ if (EINA_UNLIKELY((x + x2) > (int)(x + x1 + im->cache_entry.w)))
+ x2 = x1 + im->cache_entry.w;
+ if (EINA_UNLIKELY((y + y2) > (int)(y + y1 + im->cache_entry.h)))
+ y2 = y1 + im->cache_entry.h;
+
+ // Step 1: alpha glyph drawing
+ src8 = evas_common_font_glyph_uncompress(fg, NULL, NULL);
+ if (!src8) return;
+
+ // Step 2: color blending to buffer
+ func = evas_common_gfx_func_composite_mask_color_span_get(col, dst_image->cache_entry.flags.alpha, 1, EVAS_RENDER_COPY);
+ for (row = y1; row < y2; row++)
+ {
+ buf_ptr = buf + (row * w) + x1;
+ DATA8 *s = src8 + (row * w) + x1;
+ func(NULL, s, col, buf_ptr, x2 - x1);
+ }
+ free(src8);
+
+ // Step 3: masking to destination
+ 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);
+ for (row = y1; row < y2; row++)
+ {
+ mask = im->image.data8
+ + (y + row - dc->clip.mask_y) * im->cache_entry.w
+ + (x + x1 - dc->clip.mask_x);
+
+ ptr = dst + (x + x1) + ((y + row) * dst_pitch);
+ buf_ptr = buf + (row * w) + x1;
+ func(buf_ptr, mask, 0, ptr, w);
+ }
+ }
+ else
+ {
+ // build fast multiply + mask color tables to avoid compute. this works
+ // because of our very limited 4bit range of alpha values
+ for (i = 0; i <= 0xf; i++)
+ {
+ v = (i << 4) | i;
+ coltab[i] = MUL_SYM(v, col);
+ mtab[i] = 256 - (coltab[i] >> 24);
+ }
+#ifdef BUILD_MMX
+ if (evas_common_cpu_has_feature(CPU_FEATURE_MMX))
+ {
+#define MMX 1
+#include "evas_font_compress_draw.c"
+#undef MMX
+ }
+ else
+#endif
+
+#ifdef BUILD_NEON
+ if (evas_common_cpu_has_feature(CPU_FEATURE_NEON))
+ {
+#define NEON 1
+#include "evas_font_compress_draw.c"
+#undef NEON
+ }
+ else
+#endif
+
+ // Plain C
+ {
+#include "evas_font_compress_draw.c"
+ }
+ }
+}
+
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 @@
+#ifndef _EVAS_FONT_DRAW_H
+#define _EVAS_FONT_DRAW_
+
+#include "evas_common_private.h"
+
+/* draw */
+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);
+
+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);
+EAPI void evas_common_font_draw (RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, Evas_Glyph_Array *glyphs);
+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);
+EAPI void evas_common_font_draw_init (void);
+EAPI void evas_common_font_draw_prepare (Evas_Text_Props *text_props);
+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);
+EAPI Eina_Bool evas_common_font_draw_prepare_cutout (Cutout_Rects **reuse, RGBA_Image *dst, RGBA_Draw_Context *dc, RGBA_Gfx_Func *func);
+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);
+
+#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 @@
#endif
#include <assert.h>
-
-#include "evas_common_private.h"
-#include "evas_private.h"
+#include "evas_font_ot.h"
#ifdef USE_HARFBUZZ
# include <hb.h>
@@ -13,7 +11,7 @@
#include "evas_font_private.h" /* for Frame-Queuing support */
-#include <ft2build.h>
+#include <ft2build.h>
#include FT_TRUETYPE_TABLES_H /* Freetype2 OS/2 font table. */
#ifdef EVAS_CSERVE2
@@ -142,7 +140,7 @@ evas_common_font_dpi_set(int dpi_h, int dpi_v)
EAPI RGBA_Font_Source *
evas_common_font_source_memory_load(const char *name, const void *data, int data_size)
{
- int error;
+ int error;
RGBA_Font_Source *fs;
assert(name != NULL);
@@ -218,7 +216,7 @@ evas_common_font_source_reload(RGBA_Font_Source *fs)
if (fs->data)
{
int error;
-
+
FTLOCK();
error = FT_New_Memory_Face(evas_ft_lib, fs->data, fs->data_size, 0, &(fs->ft.face));
FTUNLOCK();
@@ -316,8 +314,8 @@ _evas_common_font_double_int_cmp(const int *key1, EINA_UNUSED int key1_length,
static int
_evas_common_font_double_int_hash(const unsigned int key[2], int key_length)
{
- return
- eina_hash_int32(&key[0], key_length) ^
+ return
+ eina_hash_int32(&key[0], key_length) ^
eina_hash_int32(&key[1], key_length);
}
@@ -336,19 +334,17 @@ EAPI RGBA_Font_Int *
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)
{
RGBA_Font_Int *fi;
- char *fake_name;
+ char fake_name[PATH_MAX];
- fake_name = evas_file_path_join(source, name);
+ eina_file_path_join(fake_name, sizeof(fake_name), source, name);
fi = evas_common_font_int_find(fake_name, size, wanted_rend, bitmap_scalable);
if (fi)
{
- free(fake_name);
return fi;
}
fi = calloc(1, sizeof(RGBA_Font_Int));
if (!fi)
{
- free(fake_name);
return NULL;
}
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,
fi->src = evas_common_font_source_memory_load(fake_name, data, data_size);
if (!fi->src)
{
- free(fi);
- free(fake_name);
- return NULL;
+ free(fi);
+ return NULL;
}
fi->size = size;
fi->bitmap_scalable = bitmap_scalable;
@@ -380,10 +375,19 @@ evas_common_font_int_memory_load(const char *source, const char *name, int size,
}
}
#endif
- free(fake_name);
return fi;
}
+static int
+_file_path_is_file_helper(const char *path)
+{
+ struct stat st;
+
+ if (stat(path, &st) == -1) return 0;
+ if (S_ISREG(st.st_mode)) return 1;
+ return 0;
+}
+
EAPI RGBA_Font_Int *
evas_common_font_int_load(const char *name, int size,
Font_Rend_Flags wanted_rend,
@@ -396,7 +400,7 @@ evas_common_font_int_load(const char *name, int size,
fi = calloc(1, sizeof(RGBA_Font_Int));
if (!fi) return NULL;
fi->src = evas_common_font_source_find(name);
- if (!fi->src && evas_file_path_is_file(name))
+ if (!fi->src && _file_path_is_file_helper(name))
fi->src = evas_common_font_source_load(name);
if (!fi->src)
@@ -466,7 +470,7 @@ evas_common_font_int_load_complete(RGBA_Font_Int *fi)
for (i = 0; i < fi->src->ft.face->num_fixed_sizes; i++)
{
int s, cd;
-
+
s = fi->src->ft.face->available_sizes[i].size;
cd = chosen_size - fi->real_size;
if (cd < 0) cd = -cd;
@@ -853,7 +857,7 @@ void
evas_common_font_int_promote(RGBA_Font_Int *fi EINA_UNUSED)
{
return;
-/* unused - keep for reference
+/* unused - keep for reference
if (fonts_use_lru == (Eina_Inlist *)fi) return;
if (!fi->inuse) return;
fonts_use_lru = eina_inlist_remove(fonts_use_lru, EINA_INLIST_GET(fi));
@@ -871,7 +875,7 @@ void
evas_common_font_int_use_trim(void)
{
return;
-/* unused - keep for reference
+/* unused - keep for reference
Eina_Inlist *l;
if (fonts_use_usage <= (font_cache << 1)) return;
@@ -894,7 +898,7 @@ void
evas_common_font_int_unload(RGBA_Font_Int *fi EINA_UNUSED)
{
return;
-/* unused - keep for reference
+/* unused - keep for reference
if (!fi->src->ft.face) return;
_evas_common_font_int_clear(fi);
FT_Done_Size(fi->ft.size);
@@ -909,7 +913,7 @@ evas_common_font_int_reload(RGBA_Font_Int *fi)
if (fi->src->ft.face) return;
evas_common_font_source_load_complete(fi->src);
return;
-/* unused - keep for reference
+/* unused - keep for reference
evas_common_font_source_reload(fi->src);
evas_common_font_int_load_complete(fi);
*/
@@ -947,7 +951,7 @@ evas_common_font_flush(void)
while (font_cache_usage > font_cache)
{
int pfont_cache_usage;
-
+
pfont_cache_usage = font_cache_usage;
evas_common_font_flush_last();
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 @@
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <assert.h>
-
-#include "evas_common_private.h"
-#include "evas_private.h"
-
#include "evas_font_private.h"
#ifdef EVAS_CSERVE2
@@ -25,6 +16,8 @@ LK(lock_font_draw); // for freetype2 API calls
LK(lock_bidi); // for evas bidi internal usage.
LK(lock_ot); // for evas bidi internal usage.
+int _evas_font_log_dom_global = -1;
+
EAPI void
evas_common_font_init(void)
{
@@ -36,6 +29,12 @@ evas_common_font_init(void)
#else
35;
#endif
+ _evas_font_log_dom_global = eina_log_domain_register
+ ("evas_font_main", EVAS_FONT_DEFAULT_LOG_COLOR);
+ if (_evas_font_log_dom_global < 0)
+ {
+ EINA_LOG_ERR("Can not create a module log domain.");
+ }
initialised++;
if (initialised != 1) return;
@@ -77,6 +76,7 @@ evas_common_font_shutdown(void)
LKD(lock_font_draw);
LKD(lock_bidi);
LKD(lock_ot);
+ eina_log_domain_unregister(_evas_font_log_dom_global);
}
EAPI void
@@ -681,7 +681,7 @@ evas_common_font_int_cache_glyph_render(RGBA_Font_Glyph *fg)
fg->glyph_out->bitmap.pitch = fbg->bitmap.pitch;
fg->glyph_out->bitmap.buffer = fbg->bitmap.buffer;
fg->glyph_out->bitmap.rle_alloc = EINA_TRUE;
-
+
/* This '+ 100' is just an estimation of how much memory freetype will use
* on it's size. This value is not really used anywhere in code - it's
* only for statistics. */
@@ -709,7 +709,7 @@ evas_common_font_int_cache_glyph_render(RGBA_Font_Glyph *fg)
fg->glyph_out->rle = NULL;
fg->glyph_out->bitmap.rle_alloc = EINA_FALSE;
}
-
+
return EINA_TRUE;
}
@@ -805,11 +805,11 @@ evas_common_get_char_index(RGBA_Font_Int* fi, Eina_Unicode gl)
// codepoints with a guess that bitmap font is playing the old
// game of putting line drawing chars in specific ranges
max = sizeof(mapfix) / (sizeof(mapfix[0]) * 2);
- i = (min + max) / 2;
+ i = (min + max) / 2;
for (;;)
{
unsigned short v;
-
+
v = mapfix[i << 1];
if (gl == v)
{
@@ -867,7 +867,7 @@ evas_common_font_glyph_search(RGBA_Font *fn, RGBA_Font_Int **fi_ret, Eina_Unicod
fi = l->data;
#if 0 /* FIXME: charmap user is disabled and use a deprecated data type. */
-/*
+/*
if (fi->src->charmap) // Charmap loaded, FI/FS blank
{
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 @@
-#include "evas_common_private.h"
+#include "evas_font_private.h"
#ifdef USE_HARFBUZZ
# include <hb.h>
# include <hb-ft.h>
#endif
-#include "evas_font_private.h"
-
#ifdef USE_HARFBUZZ
static const hb_script_t
_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 @@
#ifndef _EVAS_FONT_OT_H
# define _EVAS_FONT_OT_H
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
# ifdef HAVE_HARFBUZZ
# define OT_SUPPORT
# define USE_HARFBUZZ
@@ -17,8 +21,8 @@ typedef void *Evas_Font_OT_Info;
struct _Evas_Font_OT_Info
{
size_t source_cluster;
- Evas_Coord x_offset;
- Evas_Coord y_offset;
+ int x_offset;
+ int y_offset;
};
# endif
@@ -28,7 +32,8 @@ struct _Evas_Font_OT_Info
# define EVAS_FONT_OT_POS_GET(a) ((a).source_cluster)
# endif
-# include "evas_text_utils.h"
+#include "evas_font.h"
+
EAPI int
evas_common_font_ot_cluster_size_get(const Evas_Text_Props *props, size_t char_index);
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 @@
#ifndef _EVAS_FONT_PRIVATE_H
-# define _EVAS_FONT_PRIVATE_H
-#include "evas_font_ot.h"
+#define _EVAS_FONT_PRIVATE_H
+
+#include "evas_font.h"
+
+/* macros needed to log message through eina_log */
+extern EAPI int _evas_font_log_dom_global;
+#ifdef _EVAS_FONT_DEFAULT_LOG_DOM
+# undef _EVAS_FONT_DEFAULT_LOG_DOM
+#endif
+#define _EVAS_FONT_DEFAULT_LOG_DOM _evas_font_log_dom_global
+
+#ifdef EVAS_FONT_DEFAULT_LOG_COLOR
+# undef EVAS_FONT_DEFAULT_LOG_COLOR
+#endif
+#define EVAS_FONT_DEFAULT_LOG_COLOR EINA_COLOR_BLUE
+
+#ifdef ERR
+# undef ERR
+#endif
+#define ERR(...) EINA_LOG_DOM_ERR(_EVAS_FONT_DEFAULT_LOG_DOM, __VA_ARGS__)
+
+#ifdef DBG
+# undef DBG
+#endif
+#define DBG(...) EINA_LOG_DOM_DBG(_EVAS_FONT_DEFAULT_LOG_DOM, __VA_ARGS__)
+
+#ifdef INF
+# undef INF
+#endif
+#define INF(...) EINA_LOG_DOM_INFO(_EVAS_FONT_DEFAULT_LOG_DOM, __VA_ARGS__)
+
+#ifdef WRN
+# undef WRN
+#endif
+#define WRN(...) EINA_LOG_DOM_WARN(_EVAS_FONT_DEFAULT_LOG_DOM, __VA_ARGS__)
+
+#ifdef CRI
+# undef CRI
+#endif
+#define CRI(...) EINA_LOG_DOM_CRIT(_EVAS_FONT_DEFAULT_LOG_DOM, __VA_ARGS__)
+
extern LK(lock_font_draw); // for freetype2 API calls
extern LK(lock_bidi); // for fribidi API calls
extern LK(lock_ot); // for harfbuzz calls
+
# define FTLOCK() LKL(lock_font_draw)
# define FTUNLOCK() LKU(lock_font_draw)
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 @@
-#include "evas_common_private.h"
-#include "language/evas_bidi_utils.h" /*defines BIDI_SUPPORT if possible */
#include "evas_font_private.h" /* for Frame-Queuing support */
-#include "evas_font_ot.h"
/* 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 @@
-#include "evas_common_private.h"
#include "evas_font_private.h"
-#include "evas_text_utils.h"
-#include "language/evas_bidi_utils.h"
-#include "language/evas_language_utils.h"
#define PROPS_CHANGE(Props) Props->changed = EINA_TRUE;
@@ -47,7 +43,7 @@ evas_common_text_props_content_ref(Evas_Text_Props *props)
return;
props->info->refcount++;
- if (props->font_instance)
+ if (props->font_instance)
((RGBA_Font_Int *)props->font_instance)->references++;
}
@@ -541,7 +537,7 @@ evas_common_text_props_content_create(void *_fi, const Eina_Unicode *text,
text_props->font_instance = fi;
fi->references++;
}
-
+
evas_common_font_int_reload(fi);
if (fi->src->current_size != fi->size)
{
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
} Evas_Text_Props_Mode;
# include "evas_font_ot.h"
-# include "language/evas_bidi_utils.h"
# include "language/evas_language_utils.h"
/* Used for showing "malformed" or missing chars */
@@ -126,7 +125,7 @@ struct _Evas_Font_Glyph_Info
// relative layout info... worry then.
Evas_Coord pen_after; // 4
short x_bear, y_bear, width; // 6
-#else
+#else
Evas_Coord x_bear; // 4
/* This one is rarely used, only in draw, in which we already get the glyph
* so it doesn't really save time. Leaving it here just so no one will
@@ -134,7 +133,7 @@ struct _Evas_Font_Glyph_Info
Evas_Coord y_bear; // 4
Evas_Coord width; // 4
Evas_Coord pen_after; // 4
-#endif
+#endif
};
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 @@
#include "Evas_Internal.h"
+#include "../common/evas_font.h"
+
#ifdef EAPI
# undef EAPI
#endif
@@ -224,20 +226,6 @@ extern EAPI int _evas_log_dom_global;
# define THI(x) int x
# define TH_MAX 8
-#include <ft2build.h>
-#include FT_FREETYPE_H
-#include FT_GLYPH_H
-#include FT_SIZES_H
-#include FT_MODULE_H
-
-#ifndef FT_HAS_COLOR
-# define FT_HAS_COLOR(face) 0
-#endif
-
-#ifndef FT_LOAD_COLOR
-# define FT_LOAD_COLOR FT_LOAD_DEFAULT
-#endif
-
#ifdef __GNUC__
# if __GNUC__ >= 4
// BROKEN in gcc 4 on amd64
@@ -430,11 +418,6 @@ typedef struct _RGBA_Draw_Context RGBA_Draw_Context;
typedef struct _RGBA_Polygon_Point RGBA_Polygon_Point;
typedef struct _RGBA_Map_Point RGBA_Map_Point;
typedef struct _RGBA_Map RGBA_Map;
-typedef struct _RGBA_Font RGBA_Font;
-typedef struct _RGBA_Font_Int RGBA_Font_Int;
-typedef struct _RGBA_Font_Source RGBA_Font_Source;
-typedef struct _RGBA_Font_Glyph RGBA_Font_Glyph;
-typedef struct _RGBA_Font_Glyph_Out RGBA_Font_Glyph_Out;
typedef struct _RGBA_Gfx_Compositor RGBA_Gfx_Compositor;
typedef struct _RGBA_Image_Data_Map RGBA_Image_Data_Map;
@@ -478,6 +461,8 @@ typedef void (*Evas_Engine_Thread_Task_Cb)(void *engine_data, Image_Entry *ie, v
#include "../cache2/evas_cache2.h"
#endif
+#include "../common/evas_font_draw.h"
+
/*****************************************************************************/
typedef void (*Evas_Thread_Command_Cb)(void *data);
@@ -536,20 +521,6 @@ typedef enum _CPU_Features
CPU_FEATURE_SSE3 = (1 << 7)
} CPU_Features;
-typedef enum _Font_Hint_Flags
-{
- FONT_NO_HINT,
- FONT_AUTO_HINT,
- FONT_BYTECODE_HINT
-} Font_Hint_Flags;
-
-typedef enum _Font_Rend_Flags
-{
- FONT_REND_REGULAR = 0,
- FONT_REND_SLANT = (1 << 0),
- FONT_REND_WEIGHT = (1 << 1),
-} Font_Rend_Flags;
-
/*****************************************************************************/
struct _Image_Entry_Flags
@@ -792,7 +763,6 @@ struct _RGBA_Draw_Context
#ifdef BUILD_PIPE_RENDER
#include "../common/evas_map_image.h"
-#include "../common/evas_text_utils.h"
struct _RGBA_Pipe_Op
{
@@ -947,146 +917,6 @@ struct _RGBA_Map
RGBA_Map_Point pts[1];
};
-// for fonts...
-/////
-typedef struct _Fash_Item_Index_Map Fash_Item_Index_Map;
-typedef struct _Fash_Int_Map Fash_Int_Map;
-typedef struct _Fash_Int_Map2 Fash_Int_Map2;
-typedef struct _Fash_Int Fash_Int;
-struct _Fash_Item_Index_Map
-{
- RGBA_Font_Int *fint;
- int index;
-};
-struct _Fash_Int_Map
-{
- Fash_Item_Index_Map item[256];
-};
-struct _Fash_Int_Map2
-{
- Fash_Int_Map *bucket[256];
-};
-struct _Fash_Int
-{
- Fash_Int_Map2 *bucket[256];
- void (*freeme) (Fash_Int *fash);
-};
-
-/////
-typedef struct _Fash_Glyph_Map Fash_Glyph_Map;
-typedef struct _Fash_Glyph_Map2 Fash_Glyph_Map2;
-typedef struct _Fash_Glyph Fash_Glyph;
-struct _Fash_Glyph_Map
-{
- RGBA_Font_Glyph *item[256];
-};
-struct _Fash_Glyph_Map2
-{
- Fash_Glyph_Map *bucket[256];
-};
-struct _Fash_Glyph
-{
- Fash_Glyph_Map2 *bucket[256];
- void (*freeme) (Fash_Glyph *fash);
-};
-/////
-
-struct _RGBA_Font
-{
- Eina_List *fonts;
- Fash_Int *fash;
- Font_Hint_Flags hinting;
- int references;
- LK(lock);
- unsigned char sizeok : 1;
-};
-
-#include "../common/evas_font_ot.h"
-
-struct _RGBA_Font_Int
-{
- EINA_INLIST;
- RGBA_Font_Source *src;
- Eina_Hash *kerning;
- Fash_Glyph *fash;
- unsigned int size;
- float scale_factor;
- int real_size;
- int max_h;
- int references;
- int usage;
- struct {
- FT_Size size;
-#ifdef USE_HARFBUZZ
- void *hb_font;
-#endif
- } ft;
- LK(ft_mutex);
- Font_Hint_Flags hinting;
- Font_Rend_Flags wanted_rend; /* The wanted rendering style */
- Font_Rend_Flags runtime_rend; /* The rendering we need to do on runtime
- in order to comply with the wanted_rend. */
-
- Eina_List *task;
-#ifdef EVAS_CSERVE2
- void *cs2_handler;
-#endif
-
- int generation;
-
- Efl_Text_Font_Bitmap_Scalable bitmap_scalable;
-
- unsigned char sizeok : 1;
- unsigned char inuse : 1;
-};
-
-struct _RGBA_Font_Source
-{
- const char *name;
- const char *file;
- void *data;
- unsigned int current_size;
- int data_size;
- int references;
- struct {
- int orig_upem;
- FT_Face face;
- } ft;
-};
-
-/*
- * laziness wins for now. The parts used from the freetpye struct are
- * kept intact to avoid changing the code using it until we know exactly
- * what needs to be changed
- */
-struct _RGBA_Font_Glyph_Out
-{
- unsigned char *rle;
- struct {
- unsigned char *buffer;
- unsigned short rows;
- unsigned short width;
- unsigned short pitch;
- unsigned short rle_alloc : 1;
- unsigned short no_free_glout : 1;
- } bitmap;
- int rle_size;
-};
-
-struct _RGBA_Font_Glyph
-{
- FT_UInt index;
- Evas_Coord width;
- Evas_Coord x_bear;
- Evas_Coord y_bear;
- FT_Glyph glyph;
- RGBA_Font_Glyph_Out *glyph_out;
- /* this is a problem - only 1 engine at a time can extend such a font... grrr */
- void *ext_dat;
- void (*ext_dat_free) (void *ext_dat);
- RGBA_Font_Int *fi;
-};
-
struct _RGBA_Gfx_Compositor
{
const char *name;
@@ -1287,7 +1117,6 @@ EAPI void evas_common_blit_init (void);
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);
/****/
-#include "../common/evas_font.h"
/****/
EAPI void evas_common_tilebuf_init (void);
@@ -1321,8 +1150,6 @@ Tilebuf_Rect *evas_common_regionbuf_rects_get (Regionbuf *rb);
/****/
#include "../common/evas_pipe.h"
-void evas_font_dir_cache_free(void);
-
EAPI void evas_thread_queue_wait(void);
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 @@
#include "../file/evas_module.h"
#include "../file/evas_path.h"
-#include "../common/evas_text_utils.h"
-#include "../common/language/evas_bidi_utils.h"
-#include "../common/language/evas_language_utils.h"
#include "evas_3d_utils.h"
+
#ifdef EAPI
# undef EAPI
#endif
@@ -66,10 +64,6 @@ typedef struct _Evas_Aspect Evas_Aspect;
typedef struct _Evas_Border Evas_Border;
typedef struct _Evas_Double_Pair Evas_Double_Pair;
typedef struct _Evas_Size_Hints Evas_Size_Hints;
-typedef struct _Evas_Font_Dir Evas_Font_Dir;
-typedef struct _Evas_Font Evas_Font;
-typedef struct _Evas_Font_Alias Evas_Font_Alias;
-typedef struct _Evas_Font_Description Evas_Font_Description;
typedef struct _Evas_Data_Node Evas_Data_Node;
typedef struct _Evas_Func Evas_Func;
typedef struct _Evas_Image_Save_Func Evas_Image_Save_Func;
@@ -505,64 +499,6 @@ struct _Evas_Canvas3D_Pick_Data
Evas_Real s, t;
};
-enum _Evas_Font_Style
-{
- EVAS_FONT_STYLE_SLANT,
- EVAS_FONT_STYLE_WEIGHT,
- EVAS_FONT_STYLE_WIDTH
-};
-
-enum _Evas_Font_Slant
-{
- EVAS_FONT_SLANT_NORMAL,
- EVAS_FONT_SLANT_OBLIQUE,
- EVAS_FONT_SLANT_ITALIC
-};
-
-enum _Evas_Font_Weight
-{
- EVAS_FONT_WEIGHT_NORMAL,
- EVAS_FONT_WEIGHT_THIN,
- EVAS_FONT_WEIGHT_ULTRALIGHT,
- EVAS_FONT_WEIGHT_EXTRALIGHT,
- EVAS_FONT_WEIGHT_LIGHT,
- EVAS_FONT_WEIGHT_BOOK,
- EVAS_FONT_WEIGHT_MEDIUM,
- EVAS_FONT_WEIGHT_SEMIBOLD,
- EVAS_FONT_WEIGHT_BOLD,
- EVAS_FONT_WEIGHT_ULTRABOLD,
- EVAS_FONT_WEIGHT_EXTRABOLD,
- EVAS_FONT_WEIGHT_BLACK,
- EVAS_FONT_WEIGHT_EXTRABLACK
-};
-
-enum _Evas_Font_Width
-{
- EVAS_FONT_WIDTH_NORMAL,
- EVAS_FONT_WIDTH_ULTRACONDENSED,
- EVAS_FONT_WIDTH_EXTRACONDENSED,
- EVAS_FONT_WIDTH_CONDENSED,
- EVAS_FONT_WIDTH_SEMICONDENSED,
- EVAS_FONT_WIDTH_SEMIEXPANDED,
- EVAS_FONT_WIDTH_EXPANDED,
- EVAS_FONT_WIDTH_EXTRAEXPANDED,
- EVAS_FONT_WIDTH_ULTRAEXPANDED
-};
-
-enum _Evas_Font_Spacing
-{
- EVAS_FONT_SPACING_PROPORTIONAL,
- EVAS_FONT_SPACING_DUAL,
- EVAS_FONT_SPACING_MONO,
- EVAS_FONT_SPACING_CHARCELL
-};
-
-typedef enum _Evas_Font_Style Evas_Font_Style;
-typedef enum _Evas_Font_Slant Evas_Font_Slant;
-typedef enum _Evas_Font_Weight Evas_Font_Weight;
-typedef enum _Evas_Font_Width Evas_Font_Width;
-typedef enum _Evas_Font_Spacing Evas_Font_Spacing;
-
/* General types - used for script type chceking */
#define OPAQUE_TYPE(type) struct __##type { int a; }; \
typedef struct __##type type
@@ -1281,50 +1217,6 @@ struct _Evas_Data_Node
void *data;
};
-struct _Evas_Font_Dir
-{
- Eina_Hash *lookup;
- Eina_List *fonts;
- Eina_List *aliases;
- DATA64 dir_mod_time;
- DATA64 fonts_dir_mod_time;
- DATA64 fonts_alias_mod_time;
-};
-
-struct _Evas_Font
-{
- struct {
- const char *prop[14];
- } x;
- struct {
- const char *name;
- } simple;
- const char *path;
- char type;
-};
-
-struct _Evas_Font_Alias
-{
- const char *alias;
- Evas_Font *fn;
-};
-
-struct _Evas_Font_Description
-{
- int ref;
- Eina_Stringshare *name;
- Eina_Stringshare *fallbacks;
- Eina_Stringshare *lang;
- Eina_Stringshare *style;
-
- Evas_Font_Slant slant;
- Evas_Font_Weight weight;
- Evas_Font_Width width;
- Evas_Font_Spacing spacing;
-
- Eina_Bool is_new : 1;
-};
-
struct _Efl_Canvas_Output
{
Eo *canvas;
@@ -1703,7 +1595,7 @@ void evas_debug_generic(const char *str);
const char *evas_debug_magic_string_get(DATA32 magic);
void evas_render_update_del(Evas_Public_Data *e, int x, int y, int w, int h);
void evas_render_object_render_cache_free(Evas_Object *eo_obj, void *data);
-
+
void evas_object_smart_use(Evas_Smart *s);
void evas_object_smart_unuse(Evas_Smart *s);
void evas_smart_cb_descriptions_fix(Evas_Smart_Cb_Description_Array *a) EINA_ARG_NONNULL(1);
@@ -1764,23 +1656,6 @@ void evas_object_inform_call_image_resize(Evas_Object *obj);
void evas_object_intercept_cleanup(Evas_Object *obj);
void evas_object_grabs_cleanup(Evas_Object *obj, Evas_Object_Protected_Data *pd);
void evas_key_grab_free(Evas_Object *obj, Evas_Object_Protected_Data *pd, const char *keyname, Evas_Modifier_Mask modifiers, Evas_Modifier_Mask not_modifiers);
-void evas_font_dir_cache_free(void);
-const char *evas_font_dir_cache_find(char *dir, char *font);
-Eina_List *evas_font_dir_available_list(const Evas* evas);
-void evas_font_dir_available_list_free(Eina_List *available);
-void evas_font_free(Evas *evas, void *font);
-void evas_fonts_zero_free(Evas *evas);
-void evas_fonts_zero_pressure(Evas *evas);
-void evas_font_name_parse(Evas_Font_Description *fdesc, const char *name);
-int evas_font_style_find(const char *start, const char *end, Evas_Font_Style style);
-Evas_Font_Description *evas_font_desc_new(void);
-Evas_Font_Description *evas_font_desc_dup(const Evas_Font_Description *fdesc);
-void evas_font_desc_unref(Evas_Font_Description *fdesc);
-int evas_font_desc_cmp(const Evas_Font_Description *a, const Evas_Font_Description *b);
-Evas_Font_Description *evas_font_desc_ref(Evas_Font_Description *fdesc);
-const char *evas_font_lang_normalize(const char *lang);
-void * evas_font_load(Evas *evas, Evas_Font_Description *fdesc, const char *source, Evas_Font_Size size, Efl_Text_Font_Bitmap_Scalable bitmap_scalable);
-void evas_font_load_hinting_set(Evas *evas, void *font, int hinting);
void evas_object_smart_member_cache_invalidate(Evas_Object *obj, Eina_Bool pass_events, Eina_Bool freeze_events, Eina_Bool sourve_invisible);
void evas_text_style_pad_get(Evas_Text_Style_Type style, int *l, int *r, int *t, int *b);
void _evas_object_text_rehint(Evas_Object *obj);