2012-11-04 03:51:42 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2002-11-08 00:02:15 -08:00
|
|
|
|
2019-08-20 16:30:23 -07:00
|
|
|
#include "evas_common_private.h"
|
2009-06-15 08:07:13 -07:00
|
|
|
#include <assert.h>
|
2017-11-06 18:22:09 -08:00
|
|
|
#include "evas_font_ot.h"
|
2013-11-21 02:55:37 -08:00
|
|
|
|
2012-11-04 03:51:42 -08:00
|
|
|
#ifdef USE_HARFBUZZ
|
|
|
|
# include <hb.h>
|
|
|
|
#endif
|
|
|
|
|
2010-05-21 00:10:45 -07:00
|
|
|
#include "evas_font_private.h" /* for Frame-Queuing support */
|
2013-11-30 19:16:28 -08:00
|
|
|
|
2017-11-06 18:22:09 -08:00
|
|
|
#include <ft2build.h>
|
2013-11-30 19:16:28 -08:00
|
|
|
#include FT_TRUETYPE_TABLES_H /* Freetype2 OS/2 font table. */
|
2010-05-21 00:10:45 -07:00
|
|
|
|
2004-01-15 06:58:03 -08:00
|
|
|
extern FT_Library evas_ft_lib;
|
2002-11-08 00:02:15 -08:00
|
|
|
|
|
|
|
static int font_cache_usage = 0;
|
|
|
|
static int font_cache = 0;
|
2017-10-11 23:15:34 -07:00
|
|
|
static int font_dpi_h = 75;
|
|
|
|
static int font_dpi_v = 75;
|
2009-06-15 08:07:13 -07:00
|
|
|
|
2010-10-29 05:55:42 -07:00
|
|
|
static Eina_Hash *fonts_src = NULL;
|
|
|
|
static Eina_Hash *fonts = NULL;
|
|
|
|
static Eina_List *fonts_lru = NULL;
|
|
|
|
static Eina_Inlist *fonts_use_lru = NULL;
|
|
|
|
static int fonts_use_usage = 0;
|
2002-11-08 00:02:15 -08:00
|
|
|
|
2010-04-12 01:23:53 -07:00
|
|
|
static void _evas_common_font_int_clear(RGBA_Font_Int *fi);
|
2002-11-08 00:02:15 -08:00
|
|
|
|
2009-06-15 08:07:13 -07:00
|
|
|
static int
|
2012-11-04 03:51:42 -08:00
|
|
|
_evas_font_cache_int_cmp(const RGBA_Font_Int *k1, int k1_length EINA_UNUSED,
|
|
|
|
const RGBA_Font_Int *k2, int k2_length EINA_UNUSED)
|
2009-06-15 08:07:13 -07:00
|
|
|
{
|
|
|
|
/* RGBA_Font_Source->name is a stringshare */
|
|
|
|
if (k1->src->name == k2->src->name)
|
2011-04-12 02:05:47 -07:00
|
|
|
{
|
|
|
|
if (k1->size == k2->size)
|
2017-09-25 02:34:22 -07:00
|
|
|
{
|
|
|
|
if (k1->wanted_rend == k2->wanted_rend)
|
|
|
|
return k1->bitmap_scalable - k2->bitmap_scalable;
|
|
|
|
else
|
|
|
|
return k1->wanted_rend - k2->wanted_rend;
|
|
|
|
}
|
2011-04-12 02:05:47 -07:00
|
|
|
else
|
2017-09-25 02:34:22 -07:00
|
|
|
{
|
|
|
|
return k1->size - k2->size;
|
|
|
|
}
|
2011-04-12 02:05:47 -07:00
|
|
|
}
|
2011-10-26 07:33:51 -07:00
|
|
|
return strcmp(k1->src->name, k2->src->name);
|
2009-06-15 08:07:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-11-04 03:51:42 -08:00
|
|
|
_evas_font_cache_int_hash(const RGBA_Font_Int *key, int key_length EINA_UNUSED)
|
2009-06-15 08:07:13 -07:00
|
|
|
{
|
|
|
|
int hash;
|
2011-04-12 02:05:47 -07:00
|
|
|
unsigned int wanted_rend = key->wanted_rend;
|
2009-06-15 08:07:13 -07:00
|
|
|
hash = eina_hash_djb2(key->src->name, eina_stringshare_strlen(key->src->name) + 1);
|
|
|
|
hash ^= eina_hash_int32(&key->size, sizeof (int));
|
2011-04-12 02:05:47 -07:00
|
|
|
hash ^= eina_hash_int32(&wanted_rend, sizeof (int));
|
2017-09-25 02:34:22 -07:00
|
|
|
hash ^= eina_hash_int32(&key->bitmap_scalable, sizeof (int));
|
2009-06-15 08:07:13 -07:00
|
|
|
return hash;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_evas_common_font_source_free(RGBA_Font_Source *fs)
|
|
|
|
{
|
2010-05-21 00:10:45 -07:00
|
|
|
FTLOCK();
|
2009-06-15 08:07:13 -07:00
|
|
|
FT_Done_Face(fs->ft.face);
|
2010-05-21 00:10:45 -07:00
|
|
|
FTUNLOCK();
|
2009-06-15 08:07:13 -07:00
|
|
|
if (fs->name) eina_stringshare_del(fs->name);
|
2011-02-23 03:53:29 -08:00
|
|
|
if (fs->file) eina_stringshare_del(fs->file);
|
2009-06-15 08:07:13 -07:00
|
|
|
free(fs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_evas_common_font_int_free(RGBA_Font_Int *fi)
|
|
|
|
{
|
2013-04-04 21:05:25 -07:00
|
|
|
FTLOCK();
|
2009-06-15 08:07:13 -07:00
|
|
|
FT_Done_Size(fi->ft.size);
|
2013-04-04 21:05:25 -07:00
|
|
|
FTUNLOCK();
|
2009-06-15 08:07:13 -07:00
|
|
|
|
|
|
|
evas_common_font_int_modify_cache_by(fi, -1);
|
2010-04-12 01:23:53 -07:00
|
|
|
_evas_common_font_int_clear(fi);
|
|
|
|
eina_hash_free(fi->kerning);
|
2009-06-15 08:07:13 -07:00
|
|
|
|
2012-03-18 23:18:44 -07:00
|
|
|
LKD(fi->ft_mutex);
|
2011-10-18 02:58:49 -07:00
|
|
|
#ifdef USE_HARFBUZZ
|
|
|
|
hb_font_destroy(fi->ft.hb_font);
|
2009-06-15 08:07:13 -07:00
|
|
|
#endif
|
|
|
|
evas_common_font_source_free(fi->src);
|
2012-06-28 03:13:05 -07:00
|
|
|
if (fi->references <= 0) fonts_lru = eina_list_remove(fonts_lru, fi);
|
2010-02-03 03:18:00 -08:00
|
|
|
if (fi->fash) fi->fash->freeme(fi->fash);
|
2010-10-29 05:55:42 -07:00
|
|
|
if (fi->inuse)
|
|
|
|
{
|
|
|
|
fonts_use_lru = eina_inlist_remove(fonts_use_lru, EINA_INLIST_GET(fi));
|
|
|
|
fi->inuse = 0;
|
|
|
|
fonts_use_usage -= fi->usage;
|
|
|
|
fi->usage = 0;
|
|
|
|
}
|
2009-06-15 08:07:13 -07:00
|
|
|
free(fi);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_common_font_load_init(void)
|
|
|
|
{
|
|
|
|
fonts_src = eina_hash_string_small_new(EINA_FREE_CB(_evas_common_font_source_free));
|
2009-06-18 05:14:29 -07:00
|
|
|
fonts = eina_hash_new(NULL,
|
2009-06-15 08:07:13 -07:00
|
|
|
EINA_KEY_CMP(_evas_font_cache_int_cmp),
|
|
|
|
EINA_KEY_HASH(_evas_font_cache_int_hash),
|
|
|
|
EINA_FREE_CB(_evas_common_font_int_free),
|
|
|
|
5);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_common_font_load_shutdown(void)
|
|
|
|
{
|
|
|
|
eina_hash_free(fonts);
|
|
|
|
fonts = NULL;
|
|
|
|
eina_hash_free(fonts_src);
|
|
|
|
fonts_src = NULL;
|
|
|
|
}
|
|
|
|
|
2010-01-07 23:10:53 -08:00
|
|
|
EAPI void
|
2017-10-11 23:15:34 -07:00
|
|
|
evas_common_font_dpi_set(int dpi_h, int dpi_v)
|
2010-01-07 23:10:53 -08:00
|
|
|
{
|
2017-10-11 23:15:34 -07:00
|
|
|
if (dpi_v <= 0) dpi_v = dpi_h;
|
|
|
|
font_dpi_h = dpi_h;
|
|
|
|
font_dpi_v = dpi_v;
|
2010-01-07 23:10:53 -08:00
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI RGBA_Font_Source *
|
2004-01-22 18:14:45 -08:00
|
|
|
evas_common_font_source_memory_load(const char *name, const void *data, int data_size)
|
|
|
|
{
|
2017-11-06 18:22:09 -08:00
|
|
|
int error;
|
2004-01-22 18:14:45 -08:00
|
|
|
RGBA_Font_Source *fs;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2010-08-25 18:34:13 -07:00
|
|
|
assert(name != NULL);
|
2014-03-12 18:57:38 -07:00
|
|
|
if (data_size <= 0) return NULL;
|
2005-11-30 00:45:20 -08:00
|
|
|
fs = calloc(1, sizeof(RGBA_Font_Source) + data_size);
|
2004-01-22 18:14:45 -08:00
|
|
|
if (!fs) return NULL;
|
2005-11-30 00:45:20 -08:00
|
|
|
fs->data = ((unsigned char *)fs) + sizeof(RGBA_Font_Source);
|
2005-12-01 19:15:08 -08:00
|
|
|
fs->data_size = data_size;
|
2004-01-22 21:58:34 -08:00
|
|
|
fs->current_size = 0;
|
2004-01-22 18:14:45 -08:00
|
|
|
memcpy(fs->data, data, data_size);
|
2010-05-21 00:10:45 -07:00
|
|
|
FTLOCK();
|
2004-01-22 18:14:45 -08:00
|
|
|
error = FT_New_Memory_Face(evas_ft_lib, fs->data, fs->data_size, 0, &(fs->ft.face));
|
2010-05-21 00:10:45 -07:00
|
|
|
FTUNLOCK();
|
2004-01-22 18:14:45 -08:00
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
free(fs);
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-10-15 07:38:34 -07:00
|
|
|
fs->name = eina_stringshare_add(name);
|
2005-12-01 19:15:08 -08:00
|
|
|
fs->file = NULL;
|
2010-05-21 00:10:45 -07:00
|
|
|
FTLOCK();
|
2004-01-26 00:21:00 -08:00
|
|
|
error = FT_Select_Charmap(fs->ft.face, ft_encoding_unicode);
|
2013-07-08 06:15:24 -07:00
|
|
|
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
FT_Done_Face(fs->ft.face);
|
2013-07-08 06:15:41 -07:00
|
|
|
FTUNLOCK();
|
2013-07-08 06:15:24 -07:00
|
|
|
fs->ft.face = NULL;
|
|
|
|
free(fs);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-05-21 00:10:45 -07:00
|
|
|
FTUNLOCK();
|
2004-01-26 00:21:00 -08:00
|
|
|
fs->ft.orig_upem = fs->ft.face->units_per_EM;
|
2004-01-22 18:14:45 -08:00
|
|
|
fs->references = 1;
|
2009-06-15 08:07:13 -07:00
|
|
|
eina_hash_direct_add(fonts_src, fs->name, fs);
|
2004-01-22 18:14:45 -08:00
|
|
|
return fs;
|
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI RGBA_Font_Source *
|
2004-01-22 18:14:45 -08:00
|
|
|
evas_common_font_source_load(const char *name)
|
|
|
|
{
|
|
|
|
RGBA_Font_Source *fs;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2010-08-25 18:34:13 -07:00
|
|
|
assert(name != NULL);
|
2005-11-30 00:45:20 -08:00
|
|
|
fs = calloc(1, sizeof(RGBA_Font_Source));
|
2004-01-22 18:14:45 -08:00
|
|
|
if (!fs) return NULL;
|
2004-01-22 21:58:34 -08:00
|
|
|
fs->data = NULL;
|
|
|
|
fs->data_size = 0;
|
|
|
|
fs->current_size = 0;
|
2006-04-08 17:02:47 -07:00
|
|
|
fs->ft.face = NULL;
|
2008-10-15 07:38:34 -07:00
|
|
|
fs->name = eina_stringshare_add(name);
|
2011-02-23 03:50:09 -08:00
|
|
|
fs->file = eina_stringshare_ref(fs->name);
|
2006-04-08 17:02:47 -07:00
|
|
|
fs->ft.orig_upem = 0;
|
2004-01-22 18:14:45 -08:00
|
|
|
fs->references = 1;
|
2009-06-15 08:07:13 -07:00
|
|
|
eina_hash_direct_add(fonts_src, fs->name, fs);
|
2004-01-22 18:14:45 -08:00
|
|
|
return fs;
|
|
|
|
}
|
|
|
|
|
2010-10-29 05:55:42 -07:00
|
|
|
void
|
|
|
|
evas_common_font_source_unload(RGBA_Font_Source *fs)
|
|
|
|
{
|
|
|
|
FTLOCK();
|
|
|
|
FT_Done_Face(fs->ft.face);
|
|
|
|
fs->ft.face = NULL;
|
|
|
|
FTUNLOCK();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_common_font_source_reload(RGBA_Font_Source *fs)
|
|
|
|
{
|
|
|
|
if (fs->ft.face) return;
|
|
|
|
if (fs->data)
|
|
|
|
{
|
|
|
|
int error;
|
2017-11-06 18:22:09 -08:00
|
|
|
|
2010-10-29 05:55:42 -07:00
|
|
|
FTLOCK();
|
|
|
|
error = FT_New_Memory_Face(evas_ft_lib, fs->data, fs->data_size, 0, &(fs->ft.face));
|
|
|
|
FTUNLOCK();
|
|
|
|
if (error) return;
|
|
|
|
FTLOCK();
|
|
|
|
error = FT_Select_Charmap(fs->ft.face, ft_encoding_unicode);
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
FT_Done_Face(fs->ft.face);
|
|
|
|
fs->ft.face = NULL;
|
|
|
|
}
|
|
|
|
FTUNLOCK();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
evas_common_font_source_load_complete(fs);
|
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI int
|
2006-04-08 17:02:47 -07:00
|
|
|
evas_common_font_source_load_complete(RGBA_Font_Source *fs)
|
|
|
|
{
|
|
|
|
int error;
|
2008-07-10 11:12:45 -07:00
|
|
|
|
2010-05-21 00:10:45 -07:00
|
|
|
FTLOCK();
|
2008-07-10 11:12:45 -07:00
|
|
|
error = FT_New_Face(evas_ft_lib, fs->file, 0, &(fs->ft.face));
|
|
|
|
if (error)
|
2007-05-05 03:30:11 -07:00
|
|
|
{
|
2010-05-21 00:10:45 -07:00
|
|
|
FTUNLOCK();
|
2007-05-05 03:30:11 -07:00
|
|
|
fs->ft.face = NULL;
|
|
|
|
return error;
|
|
|
|
}
|
2006-04-08 17:02:47 -07:00
|
|
|
error = FT_Select_Charmap(fs->ft.face, ft_encoding_unicode);
|
2008-07-10 11:12:45 -07:00
|
|
|
if (error)
|
2007-05-05 03:30:11 -07:00
|
|
|
{
|
|
|
|
FT_Done_Face(fs->ft.face);
|
2010-10-29 05:55:42 -07:00
|
|
|
FTUNLOCK();
|
2007-05-05 03:30:11 -07:00
|
|
|
fs->ft.face = NULL;
|
|
|
|
return error;
|
|
|
|
}
|
2010-05-21 00:10:45 -07:00
|
|
|
FTUNLOCK();
|
2006-04-08 17:02:47 -07:00
|
|
|
fs->ft.orig_upem = fs->ft.face->units_per_EM;
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI RGBA_Font_Source *
|
2004-01-22 18:14:45 -08:00
|
|
|
evas_common_font_source_find(const char *name)
|
|
|
|
{
|
2008-10-20 05:36:48 -07:00
|
|
|
RGBA_Font_Source *fs;
|
2004-01-23 03:03:07 -08:00
|
|
|
|
2004-01-22 18:14:45 -08:00
|
|
|
if (!name) return NULL;
|
2009-06-15 08:07:13 -07:00
|
|
|
fs = eina_hash_find(fonts_src, name);
|
|
|
|
if (fs)
|
2004-01-22 18:14:45 -08:00
|
|
|
{
|
2009-06-15 08:07:13 -07:00
|
|
|
fs->references++;
|
|
|
|
return fs;
|
2004-01-22 18:14:45 -08:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI void
|
2004-01-22 18:14:45 -08:00
|
|
|
evas_common_font_source_free(RGBA_Font_Source *fs)
|
|
|
|
{
|
|
|
|
fs->references--;
|
2013-04-04 21:05:25 -07:00
|
|
|
fs->current_size = 0;
|
2004-01-22 18:14:45 -08:00
|
|
|
if (fs->references > 0) return;
|
2009-06-15 08:07:13 -07:00
|
|
|
eina_hash_del(fonts_src, fs->name, fs);
|
2004-01-22 18:14:45 -08:00
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI void
|
2004-01-22 18:14:45 -08:00
|
|
|
evas_common_font_size_use(RGBA_Font *fn)
|
|
|
|
{
|
2009-06-15 08:07:13 -07:00
|
|
|
RGBA_Font_Int *fi;
|
2008-10-21 09:31:05 -07:00
|
|
|
Eina_List *l;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2009-06-15 08:07:13 -07:00
|
|
|
EINA_LIST_FOREACH(fn->fonts, l, fi)
|
2005-03-20 07:57:55 -08:00
|
|
|
{
|
2005-03-20 09:14:41 -08:00
|
|
|
if (fi->src->current_size != fi->size)
|
|
|
|
{
|
2010-10-29 05:55:42 -07:00
|
|
|
evas_common_font_source_reload(fi->src);
|
|
|
|
FTLOCK();
|
2005-03-20 09:14:41 -08:00
|
|
|
FT_Activate_Size(fi->ft.size);
|
2010-10-29 05:55:42 -07:00
|
|
|
FTUNLOCK();
|
2005-03-20 09:14:41 -08:00
|
|
|
fi->src->current_size = fi->size;
|
|
|
|
}
|
2005-03-20 07:57:55 -08:00
|
|
|
}
|
2004-01-22 18:14:45 -08:00
|
|
|
}
|
|
|
|
|
2009-02-10 07:53:17 -08:00
|
|
|
static int
|
2012-11-04 03:51:42 -08:00
|
|
|
_evas_common_font_double_int_cmp(const int *key1, EINA_UNUSED int key1_length,
|
|
|
|
const int *key2, EINA_UNUSED int key2_length)
|
2009-02-10 07:53:17 -08:00
|
|
|
{
|
2010-10-29 05:55:42 -07:00
|
|
|
if (key1[0] - key2[0] == 0) return key1[1] - key2[1];
|
2009-02-10 07:53:17 -08:00
|
|
|
return key1[0] - key2[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2009-03-19 12:29:05 -07:00
|
|
|
_evas_common_font_double_int_hash(const unsigned int key[2], int key_length)
|
2009-02-10 07:53:17 -08:00
|
|
|
{
|
2017-11-06 18:22:09 -08:00
|
|
|
return
|
|
|
|
eina_hash_int32(&key[0], key_length) ^
|
2010-10-29 05:55:42 -07:00
|
|
|
eina_hash_int32(&key[1], key_length);
|
2009-02-10 07:53:17 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-06-15 08:07:13 -07:00
|
|
|
_evas_common_font_int_cache_init(RGBA_Font_Int *fi)
|
2009-02-10 07:53:17 -08:00
|
|
|
{
|
|
|
|
/* Add some font kerning cache. */
|
2010-02-23 05:31:10 -08:00
|
|
|
fi->kerning = eina_hash_new(NULL,
|
|
|
|
EINA_KEY_CMP(_evas_common_font_double_int_cmp),
|
|
|
|
EINA_KEY_HASH(_evas_common_font_double_int_hash),
|
|
|
|
free, 3);
|
2012-03-18 23:18:44 -07:00
|
|
|
LKI(fi->ft_mutex);
|
2009-02-10 07:53:17 -08:00
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI RGBA_Font_Int *
|
2017-09-25 02:34:22 -07:00
|
|
|
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)
|
2004-01-22 18:14:45 -08:00
|
|
|
{
|
2005-03-20 07:57:55 -08:00
|
|
|
RGBA_Font_Int *fi;
|
2017-11-06 18:22:09 -08:00
|
|
|
char fake_name[PATH_MAX];
|
2004-01-22 18:14:45 -08:00
|
|
|
|
2017-11-06 18:22:09 -08:00
|
|
|
eina_file_path_join(fake_name, sizeof(fake_name), source, name);
|
2017-09-25 02:34:22 -07:00
|
|
|
fi = evas_common_font_int_find(fake_name, size, wanted_rend, bitmap_scalable);
|
2012-06-22 13:31:31 -07:00
|
|
|
if (fi)
|
|
|
|
{
|
|
|
|
return fi;
|
|
|
|
}
|
2005-05-21 19:49:50 -07:00
|
|
|
fi = calloc(1, sizeof(RGBA_Font_Int));
|
2012-06-22 13:31:31 -07:00
|
|
|
if (!fi)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
fi->src = evas_common_font_source_find(fake_name);
|
2010-11-01 21:56:57 -07:00
|
|
|
if (!fi->src)
|
2012-06-22 13:31:31 -07:00
|
|
|
fi->src = evas_common_font_source_memory_load(fake_name, data, data_size);
|
2005-03-20 07:57:55 -08:00
|
|
|
if (!fi->src)
|
2004-01-22 18:14:45 -08:00
|
|
|
{
|
2017-11-06 18:22:09 -08:00
|
|
|
free(fi);
|
|
|
|
return NULL;
|
2004-01-22 18:14:45 -08:00
|
|
|
}
|
2005-03-20 07:57:55 -08:00
|
|
|
fi->size = size;
|
2017-09-25 02:34:22 -07:00
|
|
|
fi->bitmap_scalable = bitmap_scalable;
|
2009-06-15 08:07:13 -07:00
|
|
|
_evas_common_font_int_cache_init(fi);
|
2006-04-08 19:36:03 -07:00
|
|
|
fi = evas_common_font_int_load_init(fi);
|
|
|
|
evas_common_font_int_load_complete(fi);
|
|
|
|
return fi;
|
2004-01-22 18:14:45 -08:00
|
|
|
}
|
2002-11-08 00:02:15 -08:00
|
|
|
|
2017-11-06 18:22:09 -08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI RGBA_Font_Int *
|
2011-04-12 02:05:47 -07:00
|
|
|
evas_common_font_int_load(const char *name, int size,
|
2017-09-25 02:34:22 -07:00
|
|
|
Font_Rend_Flags wanted_rend,
|
|
|
|
Efl_Text_Font_Bitmap_Scalable bitmap_scalable)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2005-03-20 07:57:55 -08:00
|
|
|
RGBA_Font_Int *fi;
|
2002-11-08 00:02:15 -08:00
|
|
|
|
2017-09-25 02:34:22 -07:00
|
|
|
fi = evas_common_font_int_find(name, size, wanted_rend, bitmap_scalable);
|
2005-03-20 07:57:55 -08:00
|
|
|
if (fi) return fi;
|
2005-05-21 19:49:50 -07:00
|
|
|
fi = calloc(1, sizeof(RGBA_Font_Int));
|
2005-03-20 07:57:55 -08:00
|
|
|
if (!fi) return NULL;
|
|
|
|
fi->src = evas_common_font_source_find(name);
|
2017-11-06 18:22:09 -08:00
|
|
|
if (!fi->src && _file_path_is_file_helper(name))
|
2005-11-25 21:24:25 -08:00
|
|
|
fi->src = evas_common_font_source_load(name);
|
2011-04-12 02:05:47 -07:00
|
|
|
|
2005-03-20 07:57:55 -08:00
|
|
|
if (!fi->src)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2005-03-20 07:57:55 -08:00
|
|
|
free(fi);
|
2002-11-08 00:02:15 -08:00
|
|
|
return NULL;
|
|
|
|
}
|
2005-03-20 07:57:55 -08:00
|
|
|
fi->size = size;
|
2011-04-12 02:05:47 -07:00
|
|
|
fi->wanted_rend = wanted_rend;
|
2017-09-25 02:34:22 -07:00
|
|
|
fi->bitmap_scalable = bitmap_scalable;
|
2009-06-15 08:07:13 -07:00
|
|
|
_evas_common_font_int_cache_init(fi);
|
2010-11-01 21:56:57 -07:00
|
|
|
fi = evas_common_font_int_load_init(fi);
|
|
|
|
// evas_common_font_int_load_complete(fi);
|
|
|
|
return fi;
|
2004-01-22 18:14:45 -08:00
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI RGBA_Font_Int *
|
2005-03-20 07:57:55 -08:00
|
|
|
evas_common_font_int_load_init(RGBA_Font_Int *fi)
|
2006-04-08 17:02:47 -07:00
|
|
|
{
|
2006-04-08 19:36:03 -07:00
|
|
|
fi->ft.size = NULL;
|
2006-04-08 17:02:47 -07:00
|
|
|
fi->references = 1;
|
2009-06-15 08:07:13 -07:00
|
|
|
eina_hash_direct_add(fonts, fi, fi);
|
2006-04-08 17:02:47 -07:00
|
|
|
return fi;
|
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI RGBA_Font_Int *
|
2006-04-08 17:02:47 -07:00
|
|
|
evas_common_font_int_load_complete(RGBA_Font_Int *fi)
|
2004-01-22 18:14:45 -08:00
|
|
|
{
|
2009-10-09 05:10:27 -07:00
|
|
|
int val, dv;
|
|
|
|
int ret;
|
2004-01-22 18:14:45 -08:00
|
|
|
int error;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2010-05-21 00:10:45 -07:00
|
|
|
FTLOCK();
|
2005-03-20 07:57:55 -08:00
|
|
|
error = FT_New_Size(fi->src->ft.face, &(fi->ft.size));
|
2004-01-26 00:21:00 -08:00
|
|
|
if (!error)
|
2004-01-25 19:31:40 -08:00
|
|
|
{
|
2005-03-20 07:57:55 -08:00
|
|
|
FT_Activate_Size(fi->ft.size);
|
2004-01-25 19:31:40 -08:00
|
|
|
}
|
2005-03-20 07:57:55 -08:00
|
|
|
fi->real_size = fi->size * 64;
|
2017-09-25 02:34:22 -07:00
|
|
|
fi->scale_factor = 1.0;
|
2017-10-11 23:15:34 -07:00
|
|
|
error = FT_Set_Char_Size(fi->src->ft.face, 0, fi->real_size, font_dpi_h, font_dpi_v);
|
2002-11-08 00:02:15 -08:00
|
|
|
if (error)
|
2012-06-12 17:54:27 -07:00
|
|
|
error = FT_Set_Pixel_Sizes(fi->src->ft.face, 0, fi->real_size);
|
2010-05-21 00:10:45 -07:00
|
|
|
FTUNLOCK();
|
2002-11-08 00:02:15 -08:00
|
|
|
if (error)
|
|
|
|
{
|
2012-06-12 17:54:27 -07:00
|
|
|
int i, maxd = 0x7fffffff;
|
2002-11-08 00:02:15 -08:00
|
|
|
int chosen_size = 0;
|
2012-06-12 17:54:27 -07:00
|
|
|
int chosen_size2 = 0;
|
2015-03-19 03:02:02 -07:00
|
|
|
FT_Int strike_index = 0;
|
2002-11-08 00:02:15 -08:00
|
|
|
|
2005-03-20 07:57:55 -08:00
|
|
|
for (i = 0; i < fi->src->ft.face->num_fixed_sizes; i++)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2012-06-12 17:54:27 -07:00
|
|
|
int s, cd;
|
2017-11-06 18:22:09 -08:00
|
|
|
|
2012-06-12 17:54:27 -07:00
|
|
|
s = fi->src->ft.face->available_sizes[i].size;
|
|
|
|
cd = chosen_size - fi->real_size;
|
2002-11-08 00:02:15 -08:00
|
|
|
if (cd < 0) cd = -cd;
|
2012-06-12 17:54:27 -07:00
|
|
|
if (cd < maxd)
|
|
|
|
{
|
|
|
|
maxd = cd;
|
2002-11-08 00:02:15 -08:00
|
|
|
chosen_size = s;
|
2012-06-12 17:54:27 -07:00
|
|
|
chosen_size2 = fi->src->ft.face->available_sizes[i].y_ppem;
|
2015-03-19 03:02:02 -07:00
|
|
|
strike_index = (FT_Int)i;
|
2012-06-12 17:54:27 -07:00
|
|
|
if (maxd == 0) break;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
}
|
2005-03-20 07:57:55 -08:00
|
|
|
fi->real_size = chosen_size;
|
2010-10-29 05:55:42 -07:00
|
|
|
FTLOCK();
|
2015-03-19 03:02:02 -07:00
|
|
|
|
|
|
|
if (FT_HAS_FIXED_SIZES(fi->src->ft.face))
|
2017-09-25 02:34:22 -07:00
|
|
|
{
|
|
|
|
error = FT_Select_Size(fi->src->ft.face, strike_index);
|
|
|
|
|
|
|
|
if (!error)
|
|
|
|
{
|
|
|
|
if (FT_HAS_COLOR(fi->src->ft.face) &&
|
|
|
|
fi->bitmap_scalable & EFL_TEXT_FONT_BITMAP_SCALABLE_COLOR)
|
2017-09-27 17:08:44 -07:00
|
|
|
{
|
|
|
|
if (fi->real_size > 0)
|
evas_text: reduce Video Memory & RAM needed for text textures (Color Glyphs)
Summary:
Texture created for bitmap font glyph, with a fixed size in the font, this size could be much bigger than the needed size in application.
Then a scale factor is applied to these textures when drawn.
Now, instead, we will create smaller bitmaps and create texture from them with reduced texture size (that is not needed).
** This will affect both Video Memory and Ram needed to store glyphs**
Open this file {F3883874} in terminology before and after applying the patch and notice the difference.
Test Plan:
**Notes**
- You need to scroll down to make all glyphs visible, then notice Video/Ram memory
| | Video | Ram
|----------------------|-------|-----
| Before (Font_size=50) | 360 | 300
| After (Font_size=50) | 40 | 100
| Ration After/before | 11% | 33%
**I notice speed up in text rendering for small font size**
```
#include <Elementary.h>
typedef struct _APP
{
Evas_Object *tb1;
Evas_Object *btnLoad;
} APP;
char *text = "<align=center><color=#4DE0FFFF underline=on underline_color=#4DE0FFFF><a href='tel:1234567890'>1234567890</a></color>😀😁😂🤣😃😄😅😆😉😊😋😎😍😘😗😙😚☺🙂🤗🤔😐😑😶🙄😏😣😥😮🤐😯😪😫😴😌🤓😛😜😝🤤😒😓😔😕🙃🤑😲☹🙁😖😞😟😤😢😭😦😧😨😩😬😰😱😳😵😡😠😇🤠🤡🤥😷🤒🤕🤢🤧☻😈👿👹👺💀☠👻👽👾🤖💩😺😸😹😻😼😽🙀😿😾🙈🙉🙊👦👧👨👩👵👶👼👨⚕️👩⚕️👨🎓👩🎓👨🏫👩🏫👨⚖👩⚖👨🌾👩🌾👨🍳👩🍳👨🔧👩🔧👨🏭👩🏭👨💼👩💼👨🔬👩🔬👨💻👩💻👨🎤👩🎤👨🎨👩🎨👨✈️👩✈️👨🚀👩🚀👨🚒👩🚒👮♂️👮♀️🕵️♂️🕵️♀️💂♂️💂♀️👷♂️👷♀️👳♂️👳♀️👱♂️👱♀️🎅🤶👸🤴👰🤵🤰👲🙍♂️🙍♀️🙎♂️🙎♀️🙅♂️🙅♀️🙆♂️🙆♀️💁♂️💁♀️🙋♂️🙋♀️🙇♂️🙇♀️🤦♂️🤦♀️🤷♂️🤷♀️💆♂️💆♀️💇♂️💇♀️🚶♂️🚶♀️🏃♂️🏃♀️💃🕺👯♂️👯♀️🕴🗣👤👥👫👬👭💏💑👪👨👩👧👨👩👧👦👨👩👦👦👨👩👧👧👨👦👨👦👦👨👧👨👧👦👨👧👧👩👦👩👦👦👩👧👩👧👦👩👧👧💪🤳👈👉☝️👆🖕👇✌🤞🖖🤘👊🖐✋👌👍👎✊👊🤛🤜🤚👋👏✍👐🙌🙏🤝💅👂👃👣👀👁👅👄💋💘❤💓💔💕💖💗💙💚💛💜🖤💝💞💟❣💌💤💢💣💥💦💨💫💬🗨🗯💭🕳👓🕶👔👕👖👗👘👙👚👛👜👝🛍🎒👞👟👠👡👢👑👒🎩🎓⛑📿💄💍💎🐵🐒🦍🐶🐕🐩🐺🦊🐱🐈🦁🐯🐅🐆🐴🐎🦌🦄🐮🐂🐃🐄🐷🐖🐗🐽🐏🐑🐐🐪🐫🐘🦏🐭🐁🐀🐹🐰🐇🐿🦇🐻🐨🐼🐾🦃🐔🐓🐣🐤🐥🐦🐧🕊🦅🦆🦉🐸🐊🐢🦎🐍🐲🐉🐳🐋🐬🐟🐠🐡🦈🐙🐚🦀🦐🦑🦋🐌🐛🐜🐝🐞🕷🕸🦂💐🌸💮🏵🌹🥀🌺🌻🌼🌷⚘🌱🌲🌳🌴🌵🌾🌿☘🍀🍁🍂🍃🍇🍈🍉🍊🍋🍌🍍🍎🍏🍐🍑🍒🍓🍅🥝🥑🍆🥔🥕🌽🌶🥒🍄🥜🌰🍞🥐🥖🥞🧀🍖🍗🥓🍔🍟🍕🌭🌮🌯🥙🥚🍳🥘🍲🥗🍿🍱🍘🍙🍚🍛🍜🍝🍠🍢🍣🍤🍥🍡🍦🍧🍨🍩🍪🎂🍰🍫🍬🍭🍮🍯🍼🥛☕🍵🍶🍾🍷🍸🍹🍺🍻🥂🍽🍴🥄🔪🏺🎃🎄🎆🎇✨🎈🎉🎊🎋🎍🎎🎏🎐🎑🎀🎁🎗🎟🎫🎖🏆🏅🥇🥈🥉⚽️⚾️🏀🏐🏈🏉🎾🎱🎳🏏🏑🏒🏓🏸🥊🥋🥅🎯⛳🏌️♂️🏌️♀️⛸🎣🎽🎿⛷🏂🏄♂️🏄♀️🏇🏊♂️🏊♀️⛹️♂️⛹️♀️🏋️♂️🏋️♀️🚴♂️🚴♀️🚵♂️🚵♀️🏎🏍🤸♂️🤸♀️🤼♂️🤼♀️🤽♂️🤽♀️🤾♂️🤾♀️🤺🤹♂️🤹♀️🎮🕹🎲♠️♥️♦️♣️🃏🀄🎴🌍🌎🌏🌐🗺🏔⛰🌋🗻🏕🏖🏜🏝🏞🏟🏛🏗🏘🏙🏚🏠🏡🏢🏣🏤🏥🏦🏨🏩🏪🏫🏬🏭🏯🏰💒🗼🗽⛪🕌🕍⛩🕋⛲⛺🌁🌃🌄🌅🌆🌇🌉⛼♨️🌌🎠🎡🎢💈🎪🎭🖼🎨🎰🚂🚃🚄🚅🚆🚇🚈🚉🚊🚝🚞🚋🚌🚍🚎🚐🚑🚒🚓🚔🚕🚖🚗🚘🚙🚚🚛⛟🚜🚲🛴🛵🚏🛣🛤⛽🚨🚥🚦🚧🛑⚓⛵🚣♂️🚣♀️🛶🚤🛳⛴🛥🚢✈🛩🛫🛬💺🚁🚟🚠🚡🚀🛰🛎🚪🛌🛏🛋🚽🚿🛀🛁⌛⏳⌚⏰⏱⏲🕰🕛🕧🕐🕜🕑🕝🕒🕞🕓🕟🕔🕠🕕🕡🕖🕢🕗🕣🕘🕤🕙🕥🕚🕦🌑🌒🌓🌔🌕🌖🌗🌘🌙🌚🌛🌜🌡☀️🌝🌞⭐🌟🌠☁️⛅⛈🌤🌥🌦🌧🌨🌩🌪🌫🌬🌀🌈🌂☂️☔⛱⚡❄☃️⛄☄🔥💧🌊🔇🔈🔉🔊📢📣📯🔔🔕🎼🎵🎶🎙🎚🎛🎤🎧📻🎷🎸🎹🎺🎻🥁📱📲☎️📞📟📠🔋🔌💻🖥🖨⌨🖱🖲💽💾💿📀🎥🎞📽🎬📺📷📸📹📼🔍🔎🔬🔭📡🕯💡🔦🏮📔📕📖📗📘📙📚📓📒📃📜📄📰🗞📑🔖🏷💰💴💵💶💷💸💳💱💲✉📧📨📩📤📥📦📫📪📬📭📮🗳✏✒🖋🖊🖌🖍📝💼📁📂🗂📅📆🗒🗓📇📈📉📊📋📌📍📎🖇📏📐✂️🗃🗄🗑🔒🔓🔏🔐🔑🗝🔨⛏⚒🛠🗡⚔🔫🏹🛡🔧🔩⚙🗜⚗⚖🔗⛓💉💊🚬⚰⚱🗿🛢🔮🔮🏧🚮🚰♿🚹🚺🚻🚼🚾🛂🛃🛄🛅⚠️🚸⛔🚫🚳🚭🚯🚱🚷📵🔞☢☣⬆️↗️➡️↘️⬇️↙️⬅️↖️↕️↔️↩↪⤴️⤵️🔃🔄🔙🔚🔛🔜🔝🛐⚛🕉✡☸☯️☦☮🕎🔯♈♉♊♋♌♍♎♏♐♑♒♓⛎🔀🔁🔂▶️⏩⏭⏯◀️⏪⏮🔼⏫🔽⏬⏸⏹⏺⏏🎦🔅🔆📶📳📴♻️📛⚜🔰🔱⭕✅☑✔✖❌❎➕♀️♂️⚕➖➗➰➿〽✳✴❇⁉️❓❔❕❗〰🔟💯🔠🔡🔢🔣🔤🅰️🆎️🅱️🆑️🆒️🆓️ℹ🆔️Ⓜ️🆕️🆖️🅾️🆗️🅿️🆘️🆙️🆚️🈁🈂🈷🈶🈯🉐🈹🈚🈲🉑🈸🈴🈳㊗㊙🈺🈵▫️◻◼◽◾⬛⬜🔶️🔷️🔸️🔹️🔺️🔻💠🔘🔲🔳⚪⚫🔴🔵🏁🚩🏴🏳🏳️🌈⚀⚁⚂⚃⚄⚅⛾♾🇦🇨🇦🇩🇦🇪🇦🇫🇦🇬🇦🇮🇦🇱🇦🇲🇦🇴🇦🇶🇦🇷🇦🇸🇦🇹🇦🇺🇦🇼🇦🇽🇦🇿🇧🇦🇧🇧🇧🇩🇧🇪🇧🇫🇧🇬🇧🇭🇧🇮🇧🇯🇧🇱🇧🇲🇧🇳🇧🇴🇧🇶🇧🇷🇧🇸🇧🇹🇧🇼🇧🇾🇧🇿🇨🇦🇨🇨🇨🇩🇨🇫🇨🇬🇨🇭🇨🇮🇨🇰🇨🇱🇨🇲🇨🇳🇨🇴🇨🇷🇨🇺🇨🇻🇨🇼🇨🇽🇨🇾🇨🇿🇩🇪🇩🇯🇩🇰🇩🇲🇩🇴🇩🇿🇪🇨🇪🇪🇪🇬🇪🇭🇪🇷🇪🇸🇪🇹🇪🇺🇫🇮🇫🇯🇫🇰🇫🇲🇫🇴🇫🇷🇬🇦🇬🇧🇬🇩🇬🇪🇬🇫🇬🇬🇬🇭🇬🇮🇬🇱🇬🇲🇬🇳🇬🇵🇬🇶🇬🇷🇬🇸🇬🇹🇬🇺🇬🇼🇬🇾🇭🇰🇭🇲🇭🇳🇭🇷🇭🇹🇭🇺🇮🇨🇮🇩🇮🇪🇮🇱🇮🇲🇮🇳🇮🇴🇮🇶🇮🇷🇮🇸🇮🇹🇯🇪🇯🇲🇯🇴🇯🇵🇰🇪🇰🇬🇰🇭🇰🇮🇰🇲🇰🇳🇰🇵🇰🇷🇰🇼🇰🇾🇰🇿🇱🇦🇱🇧🇱🇨🇱🇮🇱🇰🇱🇷🇱🇸🇱🇹🇱🇺🇱🇻🇱🇾🇲🇦🇲🇨🇲🇩🇲🇪🇲🇬🇲🇭🇲🇰🇲🇱🇲🇲🇲🇳🇲🇴🇲🇵🇲🇶🇲🇷🇲🇸🇲🇹🇲🇺🇲🇻🇲🇼🇲🇽🇲🇾🇲🇿🇳🇦🇳🇨🇳🇪🇳🇫🇳🇬🇳🇮🇳🇱🇳🇴🇳🇵🇳🇷🇳🇺🇳🇿🇴🇲🇵🇦🇵🇪🇵🇫🇵🇬🇵🇭🇵🇰🇵🇱🇵🇲🇵🇳🇵🇷🇵🇸🇵🇹🇵🇼🇵🇾🇶🇦🇷🇪🇷🇴🇷🇸🇷🇺🇷🇼🇸🇦🇸🇧🇸🇨🇸🇩🇸🇪🇸🇬🇸🇭🇸🇮🇸🇰🇸🇱🇸🇲🇸🇳🇸🇴🇸🇷🇸🇸🇸🇹🇸🇻🇸🇽🇸🇾🇸🇿🇹🇦🇹🇨🇹🇩🇹🇫🇹🇬🇹🇭🇹🇯🇹🇰🇹🇱🇹🇲🇹🇳🇹🇴🇹🇷🇹🇹🇹🇻🇹🇼🇹🇿🇺🇦🇺🇬🇺🇳🇺🇸🇺🇾🇺🇿🇻🇦🇻🇨🇻🇪🇻🇬🇻🇮🇻🇳🇻🇺🇼🇫🇼🇸🇽🇰🇾🇪🇾🇹🇿🇦🇿🇲🇿🇼8<br/><br/><br/><br/>Sent from my Samsung Galaxy smartphone.</align>";
int font_size = 100;
void _button_clicked(void *data, Evas_Object *obj, void *event_info)
{
APP *app = data;
font_size = font_size - font_size/5;
char buffer[100] = {0};
sprintf(buffer, "DEFAULT='font=NotoColorEmoji font_size=%i color=red ellipsis=-1.0 wrap=mixed'", font_size);
Evas_Textblock_Style *style = evas_textblock_style_new();
evas_textblock_style_set(style, buffer);
evas_object_textblock_style_set(app->tb1, style);
evas_textblock_style_free(style);
sprintf(buffer, "font_size = %i",font_size);
elm_object_text_set(app->btnLoad, buffer);
style = NULL;
}
EAPI_MAIN int
elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
APP *app = calloc(1, sizeof(APP));
Evas_Object *win, *scroller1, *scroller2, *box;
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
win = elm_win_util_standard_add("", "");
elm_win_autodel_set(win, EINA_TRUE);
box = elm_box_add(win);
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
scroller1 = elm_scroller_add(win);
evas_object_size_hint_weight_set(scroller1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(scroller1, EVAS_HINT_FILL, EVAS_HINT_FILL);
//evas_text_cache_policy_set(EVAS_TEXT_CACHE_POLICY_TEXTURE ,EVAS_TEXT_CACHE_NONE);
app->tb1 = evas_object_textblock_add(win);
Evas_Textblock_Style *style = evas_textblock_style_new();
char buffer[100] = {0};
sprintf(buffer, "DEFAULT='font=NotoColorEmoji font_size=%i color=red ellipsis=-1.0 wrap=mixed'", font_size);
evas_textblock_style_set(style, buffer);
evas_object_textblock_style_set(app->tb1, style);
evas_textblock_style_free(style);
style = NULL;
int w,h;
evas_object_textblock_text_markup_set(app->tb1, "");
evas_object_size_hint_min_set(app->tb1, 360, 720);
elm_object_content_set(scroller1, app->tb1);
elm_box_pack_end(box, scroller1);
elm_object_content_set(win, box);
app->btnLoad = elm_button_add(win);
sprintf(buffer, "font_size = %i",font_size);
elm_object_text_set(app->btnLoad, buffer);
evas_object_smart_callback_add(app->btnLoad, "clicked", _button_clicked, app);
evas_object_show(app->btnLoad);
evas_object_move(app->btnLoad, 0, 20);
evas_object_resize(app->btnLoad, 150, 20);
evas_object_textblock_text_markup_set(app->tb1, text);
evas_object_textblock_size_formatted_get(app->tb1, &w, &h);
evas_object_size_hint_min_set(app->tb1, 800, w/800 + h + 150);
evas_object_resize(win, 800, 800);
evas_object_show(box);
evas_object_show(scroller1);
evas_object_show(scroller2);
evas_object_show(win);
elm_run();
return 0;
}
ELM_MAIN()
```
Reviewers: raster, woohyun, bu5hm4n, zmike, Hermet, segfaultxavi
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Maniphest Tasks: T8712
Differential Revision: https://phab.enlightenment.org/D11814
2020-05-29 02:10:28 -07:00
|
|
|
{
|
|
|
|
fi->scale_factor = (double)fi->size * 64.0 / (double)fi->real_size;
|
|
|
|
fi->is_resized = EINA_FALSE;
|
|
|
|
if ((fi->scale_factor <= 0.9) && (fi->scale_factor != 0))
|
|
|
|
fi->is_resized = EINA_TRUE;
|
|
|
|
}
|
2017-09-27 17:08:44 -07:00
|
|
|
else
|
evas_text: reduce Video Memory & RAM needed for text textures (Color Glyphs)
Summary:
Texture created for bitmap font glyph, with a fixed size in the font, this size could be much bigger than the needed size in application.
Then a scale factor is applied to these textures when drawn.
Now, instead, we will create smaller bitmaps and create texture from them with reduced texture size (that is not needed).
** This will affect both Video Memory and Ram needed to store glyphs**
Open this file {F3883874} in terminology before and after applying the patch and notice the difference.
Test Plan:
**Notes**
- You need to scroll down to make all glyphs visible, then notice Video/Ram memory
| | Video | Ram
|----------------------|-------|-----
| Before (Font_size=50) | 360 | 300
| After (Font_size=50) | 40 | 100
| Ration After/before | 11% | 33%
**I notice speed up in text rendering for small font size**
```
#include <Elementary.h>
typedef struct _APP
{
Evas_Object *tb1;
Evas_Object *btnLoad;
} APP;
char *text = "<align=center><color=#4DE0FFFF underline=on underline_color=#4DE0FFFF><a href='tel:1234567890'>1234567890</a></color>😀😁😂🤣😃😄😅😆😉😊😋😎😍😘😗😙😚☺🙂🤗🤔😐😑😶🙄😏😣😥😮🤐😯😪😫😴😌🤓😛😜😝🤤😒😓😔😕🙃🤑😲☹🙁😖😞😟😤😢😭😦😧😨😩😬😰😱😳😵😡😠😇🤠🤡🤥😷🤒🤕🤢🤧☻😈👿👹👺💀☠👻👽👾🤖💩😺😸😹😻😼😽🙀😿😾🙈🙉🙊👦👧👨👩👵👶👼👨⚕️👩⚕️👨🎓👩🎓👨🏫👩🏫👨⚖👩⚖👨🌾👩🌾👨🍳👩🍳👨🔧👩🔧👨🏭👩🏭👨💼👩💼👨🔬👩🔬👨💻👩💻👨🎤👩🎤👨🎨👩🎨👨✈️👩✈️👨🚀👩🚀👨🚒👩🚒👮♂️👮♀️🕵️♂️🕵️♀️💂♂️💂♀️👷♂️👷♀️👳♂️👳♀️👱♂️👱♀️🎅🤶👸🤴👰🤵🤰👲🙍♂️🙍♀️🙎♂️🙎♀️🙅♂️🙅♀️🙆♂️🙆♀️💁♂️💁♀️🙋♂️🙋♀️🙇♂️🙇♀️🤦♂️🤦♀️🤷♂️🤷♀️💆♂️💆♀️💇♂️💇♀️🚶♂️🚶♀️🏃♂️🏃♀️💃🕺👯♂️👯♀️🕴🗣👤👥👫👬👭💏💑👪👨👩👧👨👩👧👦👨👩👦👦👨👩👧👧👨👦👨👦👦👨👧👨👧👦👨👧👧👩👦👩👦👦👩👧👩👧👦👩👧👧💪🤳👈👉☝️👆🖕👇✌🤞🖖🤘👊🖐✋👌👍👎✊👊🤛🤜🤚👋👏✍👐🙌🙏🤝💅👂👃👣👀👁👅👄💋💘❤💓💔💕💖💗💙💚💛💜🖤💝💞💟❣💌💤💢💣💥💦💨💫💬🗨🗯💭🕳👓🕶👔👕👖👗👘👙👚👛👜👝🛍🎒👞👟👠👡👢👑👒🎩🎓⛑📿💄💍💎🐵🐒🦍🐶🐕🐩🐺🦊🐱🐈🦁🐯🐅🐆🐴🐎🦌🦄🐮🐂🐃🐄🐷🐖🐗🐽🐏🐑🐐🐪🐫🐘🦏🐭🐁🐀🐹🐰🐇🐿🦇🐻🐨🐼🐾🦃🐔🐓🐣🐤🐥🐦🐧🕊🦅🦆🦉🐸🐊🐢🦎🐍🐲🐉🐳🐋🐬🐟🐠🐡🦈🐙🐚🦀🦐🦑🦋🐌🐛🐜🐝🐞🕷🕸🦂💐🌸💮🏵🌹🥀🌺🌻🌼🌷⚘🌱🌲🌳🌴🌵🌾🌿☘🍀🍁🍂🍃🍇🍈🍉🍊🍋🍌🍍🍎🍏🍐🍑🍒🍓🍅🥝🥑🍆🥔🥕🌽🌶🥒🍄🥜🌰🍞🥐🥖🥞🧀🍖🍗🥓🍔🍟🍕🌭🌮🌯🥙🥚🍳🥘🍲🥗🍿🍱🍘🍙🍚🍛🍜🍝🍠🍢🍣🍤🍥🍡🍦🍧🍨🍩🍪🎂🍰🍫🍬🍭🍮🍯🍼🥛☕🍵🍶🍾🍷🍸🍹🍺🍻🥂🍽🍴🥄🔪🏺🎃🎄🎆🎇✨🎈🎉🎊🎋🎍🎎🎏🎐🎑🎀🎁🎗🎟🎫🎖🏆🏅🥇🥈🥉⚽️⚾️🏀🏐🏈🏉🎾🎱🎳🏏🏑🏒🏓🏸🥊🥋🥅🎯⛳🏌️♂️🏌️♀️⛸🎣🎽🎿⛷🏂🏄♂️🏄♀️🏇🏊♂️🏊♀️⛹️♂️⛹️♀️🏋️♂️🏋️♀️🚴♂️🚴♀️🚵♂️🚵♀️🏎🏍🤸♂️🤸♀️🤼♂️🤼♀️🤽♂️🤽♀️🤾♂️🤾♀️🤺🤹♂️🤹♀️🎮🕹🎲♠️♥️♦️♣️🃏🀄🎴🌍🌎🌏🌐🗺🏔⛰🌋🗻🏕🏖🏜🏝🏞🏟🏛🏗🏘🏙🏚🏠🏡🏢🏣🏤🏥🏦🏨🏩🏪🏫🏬🏭🏯🏰💒🗼🗽⛪🕌🕍⛩🕋⛲⛺🌁🌃🌄🌅🌆🌇🌉⛼♨️🌌🎠🎡🎢💈🎪🎭🖼🎨🎰🚂🚃🚄🚅🚆🚇🚈🚉🚊🚝🚞🚋🚌🚍🚎🚐🚑🚒🚓🚔🚕🚖🚗🚘🚙🚚🚛⛟🚜🚲🛴🛵🚏🛣🛤⛽🚨🚥🚦🚧🛑⚓⛵🚣♂️🚣♀️🛶🚤🛳⛴🛥🚢✈🛩🛫🛬💺🚁🚟🚠🚡🚀🛰🛎🚪🛌🛏🛋🚽🚿🛀🛁⌛⏳⌚⏰⏱⏲🕰🕛🕧🕐🕜🕑🕝🕒🕞🕓🕟🕔🕠🕕🕡🕖🕢🕗🕣🕘🕤🕙🕥🕚🕦🌑🌒🌓🌔🌕🌖🌗🌘🌙🌚🌛🌜🌡☀️🌝🌞⭐🌟🌠☁️⛅⛈🌤🌥🌦🌧🌨🌩🌪🌫🌬🌀🌈🌂☂️☔⛱⚡❄☃️⛄☄🔥💧🌊🔇🔈🔉🔊📢📣📯🔔🔕🎼🎵🎶🎙🎚🎛🎤🎧📻🎷🎸🎹🎺🎻🥁📱📲☎️📞📟📠🔋🔌💻🖥🖨⌨🖱🖲💽💾💿📀🎥🎞📽🎬📺📷📸📹📼🔍🔎🔬🔭📡🕯💡🔦🏮📔📕📖📗📘📙📚📓📒📃📜📄📰🗞📑🔖🏷💰💴💵💶💷💸💳💱💲✉📧📨📩📤📥📦📫📪📬📭📮🗳✏✒🖋🖊🖌🖍📝💼📁📂🗂📅📆🗒🗓📇📈📉📊📋📌📍📎🖇📏📐✂️🗃🗄🗑🔒🔓🔏🔐🔑🗝🔨⛏⚒🛠🗡⚔🔫🏹🛡🔧🔩⚙🗜⚗⚖🔗⛓💉💊🚬⚰⚱🗿🛢🔮🔮🏧🚮🚰♿🚹🚺🚻🚼🚾🛂🛃🛄🛅⚠️🚸⛔🚫🚳🚭🚯🚱🚷📵🔞☢☣⬆️↗️➡️↘️⬇️↙️⬅️↖️↕️↔️↩↪⤴️⤵️🔃🔄🔙🔚🔛🔜🔝🛐⚛🕉✡☸☯️☦☮🕎🔯♈♉♊♋♌♍♎♏♐♑♒♓⛎🔀🔁🔂▶️⏩⏭⏯◀️⏪⏮🔼⏫🔽⏬⏸⏹⏺⏏🎦🔅🔆📶📳📴♻️📛⚜🔰🔱⭕✅☑✔✖❌❎➕♀️♂️⚕➖➗➰➿〽✳✴❇⁉️❓❔❕❗〰🔟💯🔠🔡🔢🔣🔤🅰️🆎️🅱️🆑️🆒️🆓️ℹ🆔️Ⓜ️🆕️🆖️🅾️🆗️🅿️🆘️🆙️🆚️🈁🈂🈷🈶🈯🉐🈹🈚🈲🉑🈸🈴🈳㊗㊙🈺🈵▫️◻◼◽◾⬛⬜🔶️🔷️🔸️🔹️🔺️🔻💠🔘🔲🔳⚪⚫🔴🔵🏁🚩🏴🏳🏳️🌈⚀⚁⚂⚃⚄⚅⛾♾🇦🇨🇦🇩🇦🇪🇦🇫🇦🇬🇦🇮🇦🇱🇦🇲🇦🇴🇦🇶🇦🇷🇦🇸🇦🇹🇦🇺🇦🇼🇦🇽🇦🇿🇧🇦🇧🇧🇧🇩🇧🇪🇧🇫🇧🇬🇧🇭🇧🇮🇧🇯🇧🇱🇧🇲🇧🇳🇧🇴🇧🇶🇧🇷🇧🇸🇧🇹🇧🇼🇧🇾🇧🇿🇨🇦🇨🇨🇨🇩🇨🇫🇨🇬🇨🇭🇨🇮🇨🇰🇨🇱🇨🇲🇨🇳🇨🇴🇨🇷🇨🇺🇨🇻🇨🇼🇨🇽🇨🇾🇨🇿🇩🇪🇩🇯🇩🇰🇩🇲🇩🇴🇩🇿🇪🇨🇪🇪🇪🇬🇪🇭🇪🇷🇪🇸🇪🇹🇪🇺🇫🇮🇫🇯🇫🇰🇫🇲🇫🇴🇫🇷🇬🇦🇬🇧🇬🇩🇬🇪🇬🇫🇬🇬🇬🇭🇬🇮🇬🇱🇬🇲🇬🇳🇬🇵🇬🇶🇬🇷🇬🇸🇬🇹🇬🇺🇬🇼🇬🇾🇭🇰🇭🇲🇭🇳🇭🇷🇭🇹🇭🇺🇮🇨🇮🇩🇮🇪🇮🇱🇮🇲🇮🇳🇮🇴🇮🇶🇮🇷🇮🇸🇮🇹🇯🇪🇯🇲🇯🇴🇯🇵🇰🇪🇰🇬🇰🇭🇰🇮🇰🇲🇰🇳🇰🇵🇰🇷🇰🇼🇰🇾🇰🇿🇱🇦🇱🇧🇱🇨🇱🇮🇱🇰🇱🇷🇱🇸🇱🇹🇱🇺🇱🇻🇱🇾🇲🇦🇲🇨🇲🇩🇲🇪🇲🇬🇲🇭🇲🇰🇲🇱🇲🇲🇲🇳🇲🇴🇲🇵🇲🇶🇲🇷🇲🇸🇲🇹🇲🇺🇲🇻🇲🇼🇲🇽🇲🇾🇲🇿🇳🇦🇳🇨🇳🇪🇳🇫🇳🇬🇳🇮🇳🇱🇳🇴🇳🇵🇳🇷🇳🇺🇳🇿🇴🇲🇵🇦🇵🇪🇵🇫🇵🇬🇵🇭🇵🇰🇵🇱🇵🇲🇵🇳🇵🇷🇵🇸🇵🇹🇵🇼🇵🇾🇶🇦🇷🇪🇷🇴🇷🇸🇷🇺🇷🇼🇸🇦🇸🇧🇸🇨🇸🇩🇸🇪🇸🇬🇸🇭🇸🇮🇸🇰🇸🇱🇸🇲🇸🇳🇸🇴🇸🇷🇸🇸🇸🇹🇸🇻🇸🇽🇸🇾🇸🇿🇹🇦🇹🇨🇹🇩🇹🇫🇹🇬🇹🇭🇹🇯🇹🇰🇹🇱🇹🇲🇹🇳🇹🇴🇹🇷🇹🇹🇹🇻🇹🇼🇹🇿🇺🇦🇺🇬🇺🇳🇺🇸🇺🇾🇺🇿🇻🇦🇻🇨🇻🇪🇻🇬🇻🇮🇻🇳🇻🇺🇼🇫🇼🇸🇽🇰🇾🇪🇾🇹🇿🇦🇿🇲🇿🇼8<br/><br/><br/><br/>Sent from my Samsung Galaxy smartphone.</align>";
int font_size = 100;
void _button_clicked(void *data, Evas_Object *obj, void *event_info)
{
APP *app = data;
font_size = font_size - font_size/5;
char buffer[100] = {0};
sprintf(buffer, "DEFAULT='font=NotoColorEmoji font_size=%i color=red ellipsis=-1.0 wrap=mixed'", font_size);
Evas_Textblock_Style *style = evas_textblock_style_new();
evas_textblock_style_set(style, buffer);
evas_object_textblock_style_set(app->tb1, style);
evas_textblock_style_free(style);
sprintf(buffer, "font_size = %i",font_size);
elm_object_text_set(app->btnLoad, buffer);
style = NULL;
}
EAPI_MAIN int
elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
APP *app = calloc(1, sizeof(APP));
Evas_Object *win, *scroller1, *scroller2, *box;
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
win = elm_win_util_standard_add("", "");
elm_win_autodel_set(win, EINA_TRUE);
box = elm_box_add(win);
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
scroller1 = elm_scroller_add(win);
evas_object_size_hint_weight_set(scroller1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(scroller1, EVAS_HINT_FILL, EVAS_HINT_FILL);
//evas_text_cache_policy_set(EVAS_TEXT_CACHE_POLICY_TEXTURE ,EVAS_TEXT_CACHE_NONE);
app->tb1 = evas_object_textblock_add(win);
Evas_Textblock_Style *style = evas_textblock_style_new();
char buffer[100] = {0};
sprintf(buffer, "DEFAULT='font=NotoColorEmoji font_size=%i color=red ellipsis=-1.0 wrap=mixed'", font_size);
evas_textblock_style_set(style, buffer);
evas_object_textblock_style_set(app->tb1, style);
evas_textblock_style_free(style);
style = NULL;
int w,h;
evas_object_textblock_text_markup_set(app->tb1, "");
evas_object_size_hint_min_set(app->tb1, 360, 720);
elm_object_content_set(scroller1, app->tb1);
elm_box_pack_end(box, scroller1);
elm_object_content_set(win, box);
app->btnLoad = elm_button_add(win);
sprintf(buffer, "font_size = %i",font_size);
elm_object_text_set(app->btnLoad, buffer);
evas_object_smart_callback_add(app->btnLoad, "clicked", _button_clicked, app);
evas_object_show(app->btnLoad);
evas_object_move(app->btnLoad, 0, 20);
evas_object_resize(app->btnLoad, 150, 20);
evas_object_textblock_text_markup_set(app->tb1, text);
evas_object_textblock_size_formatted_get(app->tb1, &w, &h);
evas_object_size_hint_min_set(app->tb1, 800, w/800 + h + 150);
evas_object_resize(win, 800, 800);
evas_object_show(box);
evas_object_show(scroller1);
evas_object_show(scroller2);
evas_object_show(win);
elm_run();
return 0;
}
ELM_MAIN()
```
Reviewers: raster, woohyun, bu5hm4n, zmike, Hermet, segfaultxavi
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Maniphest Tasks: T8712
Differential Revision: https://phab.enlightenment.org/D11814
2020-05-29 02:10:28 -07:00
|
|
|
fi->scale_factor = 64.0;
|
2017-09-27 17:08:44 -07:00
|
|
|
}
|
2017-09-25 02:34:22 -07:00
|
|
|
}
|
|
|
|
}
|
2015-03-19 03:02:02 -07:00
|
|
|
else
|
2017-09-25 02:34:22 -07:00
|
|
|
{
|
|
|
|
error = FT_Set_Pixel_Sizes(fi->src->ft.face, 0, fi->real_size);
|
|
|
|
}
|
2015-03-19 03:02:02 -07:00
|
|
|
|
2010-10-29 05:55:42 -07:00
|
|
|
FTUNLOCK();
|
2002-11-08 00:02:15 -08:00
|
|
|
if (error)
|
|
|
|
{
|
2017-10-11 23:15:34 -07:00
|
|
|
error = FT_Set_Char_Size(fi->src->ft.face, 0, fi->real_size, font_dpi_h, font_dpi_v);
|
2012-06-12 17:54:27 -07:00
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
/* hack around broken fonts */
|
|
|
|
fi->real_size = (chosen_size2 / 64) * 60;
|
2017-10-11 23:15:34 -07:00
|
|
|
error = FT_Set_Char_Size(fi->src->ft.face, 0, fi->real_size, font_dpi_h, font_dpi_v);
|
2012-06-12 17:54:27 -07:00
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
/* couldn't choose the size anyway... what now? */
|
|
|
|
}
|
|
|
|
}
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
}
|
2010-02-03 03:18:00 -08:00
|
|
|
fi->src->current_size = 0;
|
2009-10-09 05:10:27 -07:00
|
|
|
fi->max_h = 0;
|
|
|
|
val = (int)fi->src->ft.face->bbox.yMax;
|
|
|
|
if (fi->src->ft.face->units_per_EM != 0)
|
|
|
|
{
|
|
|
|
dv = (fi->src->ft.orig_upem * 2048) / fi->src->ft.face->units_per_EM;
|
2012-10-10 00:00:07 -07:00
|
|
|
ret = FONT_METRIC_CONV(val, dv, fi->src->ft.face->size->metrics.y_scale);
|
2009-10-09 05:10:27 -07:00
|
|
|
}
|
2012-06-09 20:23:57 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((fi->src->ft.face->bbox.yMax == 0) &&
|
|
|
|
(fi->src->ft.face->bbox.yMin == 0))
|
2012-10-09 23:07:38 -07:00
|
|
|
ret = FONT_METRIC_ROUNDUP((int)fi->ft.size->metrics.ascender);
|
2012-06-09 20:23:57 -07:00
|
|
|
else
|
|
|
|
ret = val;
|
|
|
|
}
|
2009-10-09 05:10:27 -07:00
|
|
|
fi->max_h += ret;
|
|
|
|
val = -(int)fi->src->ft.face->bbox.yMin;
|
|
|
|
if (fi->src->ft.face->units_per_EM != 0)
|
|
|
|
{
|
|
|
|
dv = (fi->src->ft.orig_upem * 2048) / fi->src->ft.face->units_per_EM;
|
2012-10-10 00:00:07 -07:00
|
|
|
ret = FONT_METRIC_CONV(val, dv, fi->src->ft.face->size->metrics.y_scale);
|
2009-10-09 05:10:27 -07:00
|
|
|
}
|
2012-06-09 20:23:57 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((fi->src->ft.face->bbox.yMax == 0) &&
|
|
|
|
(fi->src->ft.face->bbox.yMin == 0))
|
2012-10-09 23:07:38 -07:00
|
|
|
ret = FONT_METRIC_ROUNDUP(-(int)fi->ft.size->metrics.descender);
|
2012-06-09 20:23:57 -07:00
|
|
|
else
|
|
|
|
ret = val;
|
|
|
|
}
|
2009-10-09 05:10:27 -07:00
|
|
|
fi->max_h += ret;
|
2011-04-12 02:05:47 -07:00
|
|
|
|
|
|
|
/* If the loaded font doesn't match with wanted_rend value requested by
|
2011-08-01 02:11:42 -07:00
|
|
|
* textobject and textblock, Set the runtime_rend value as FONT_REND_SLANT
|
|
|
|
* or FONT_REND_WEIGHT for software rendering. */
|
2011-04-12 02:05:47 -07:00
|
|
|
fi->runtime_rend = FONT_REND_REGULAR;
|
2011-08-01 02:11:42 -07:00
|
|
|
if ((fi->wanted_rend & FONT_REND_SLANT) &&
|
2011-04-12 02:05:47 -07:00
|
|
|
!(fi->src->ft.face->style_flags & FT_STYLE_FLAG_ITALIC))
|
2011-08-01 02:11:42 -07:00
|
|
|
fi->runtime_rend |= FONT_REND_SLANT;
|
2011-04-12 02:05:47 -07:00
|
|
|
|
2011-08-01 02:11:42 -07:00
|
|
|
if ((fi->wanted_rend & FONT_REND_WEIGHT) &&
|
2011-04-12 02:05:47 -07:00
|
|
|
!(fi->src->ft.face->style_flags & FT_STYLE_FLAG_BOLD))
|
2013-04-04 08:05:27 -07:00
|
|
|
{
|
|
|
|
TT_OS2 *tt_os2 = FT_Get_Sfnt_Table(fi->src->ft.face, ft_sfnt_os2);
|
|
|
|
if (!tt_os2 || (tt_os2->usWeightClass < 600))
|
|
|
|
{
|
|
|
|
fi->runtime_rend |= FONT_REND_WEIGHT;
|
|
|
|
}
|
|
|
|
}
|
2011-04-12 02:05:47 -07:00
|
|
|
|
2005-03-20 07:57:55 -08:00
|
|
|
return fi;
|
|
|
|
}
|
2008-07-16 13:46:47 -07:00
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI RGBA_Font *
|
2017-09-25 02:34:22 -07:00
|
|
|
evas_common_font_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)
|
2005-03-20 07:57:55 -08:00
|
|
|
{
|
|
|
|
RGBA_Font *fn;
|
|
|
|
RGBA_Font_Int *fi;
|
2008-07-10 11:12:45 -07:00
|
|
|
|
2012-06-22 13:31:31 -07:00
|
|
|
fi = evas_common_font_int_memory_load(source, name, size, data, data_size,
|
2017-09-25 02:34:22 -07:00
|
|
|
wanted_rend, bitmap_scalable);
|
2005-03-20 07:57:55 -08:00
|
|
|
if (!fi) return NULL;
|
|
|
|
fn = calloc(1, sizeof(RGBA_Font));
|
2005-08-26 01:00:49 -07:00
|
|
|
if (!fn)
|
2006-02-27 06:03:27 -08:00
|
|
|
{
|
2012-06-28 03:13:05 -07:00
|
|
|
evas_common_font_int_unref(fi);
|
2006-02-27 06:03:27 -08:00
|
|
|
return NULL;
|
|
|
|
}
|
2008-10-21 09:31:05 -07:00
|
|
|
fn->fonts = eina_list_append(fn->fonts, fi);
|
2006-02-27 06:03:27 -08:00
|
|
|
fn->hinting = FONT_BYTECODE_HINT;
|
|
|
|
fi->hinting = fn->hinting;
|
2006-11-13 15:23:44 -08:00
|
|
|
fn->references = 1;
|
|
|
|
LKI(fn->lock);
|
2010-10-29 05:55:42 -07:00
|
|
|
if (fi->inuse) evas_common_font_int_promote(fi);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fi->inuse = 1;
|
|
|
|
fonts_use_lru = eina_inlist_prepend(fonts_use_lru, EINA_INLIST_GET(fi));
|
|
|
|
}
|
2002-11-08 00:02:15 -08:00
|
|
|
return fn;
|
|
|
|
}
|
|
|
|
|
2010-10-29 05:55:42 -07:00
|
|
|
|
|
|
|
//ZZZ: font struct looks like:
|
|
|
|
// fn->(fi, fi, fi, ...)
|
|
|
|
// fi->fs
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI RGBA_Font *
|
2017-09-25 02:34:22 -07:00
|
|
|
evas_common_font_load(const char *name, int size, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable)
|
2005-03-20 07:57:55 -08:00
|
|
|
{
|
|
|
|
RGBA_Font *fn;
|
|
|
|
RGBA_Font_Int *fi;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2017-09-25 02:34:22 -07:00
|
|
|
fi = evas_common_font_int_load(name, size, wanted_rend, bitmap_scalable);
|
2005-03-20 07:57:55 -08:00
|
|
|
if (!fi) return NULL;
|
2008-07-10 11:12:45 -07:00
|
|
|
/* First font, complete load */
|
2006-04-08 17:02:47 -07:00
|
|
|
if (!fi->ft.size)
|
|
|
|
{
|
|
|
|
if (!fi->src->ft.face)
|
|
|
|
{
|
|
|
|
if (evas_common_font_source_load_complete(fi->src))
|
|
|
|
{
|
2012-06-28 03:13:05 -07:00
|
|
|
evas_common_font_int_unref(fi);
|
2006-04-08 17:02:47 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
evas_common_font_int_load_complete(fi);
|
|
|
|
}
|
2005-03-20 07:57:55 -08:00
|
|
|
fn = calloc(1, sizeof(RGBA_Font));
|
2005-08-26 01:00:49 -07:00
|
|
|
if (!fn)
|
2006-02-27 06:03:27 -08:00
|
|
|
{
|
2012-06-28 03:13:05 -07:00
|
|
|
evas_common_font_int_unref(fi);
|
2006-02-27 06:03:27 -08:00
|
|
|
return NULL;
|
|
|
|
}
|
2011-04-12 02:05:47 -07:00
|
|
|
|
2008-10-21 09:31:05 -07:00
|
|
|
fn->fonts = eina_list_append(fn->fonts, fi);
|
2006-02-27 06:03:27 -08:00
|
|
|
fn->hinting = FONT_BYTECODE_HINT;
|
|
|
|
fi->hinting = fn->hinting;
|
2006-11-13 15:23:44 -08:00
|
|
|
fn->references = 1;
|
|
|
|
LKI(fn->lock);
|
2010-10-29 05:55:42 -07:00
|
|
|
if (fi->inuse) evas_common_font_int_promote(fi);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fi->inuse = 1;
|
|
|
|
fonts_use_lru = eina_inlist_prepend(fonts_use_lru, EINA_INLIST_GET(fi));
|
|
|
|
}
|
2005-03-20 07:57:55 -08:00
|
|
|
return fn;
|
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI RGBA_Font *
|
2017-09-25 02:34:22 -07:00
|
|
|
evas_common_font_add(RGBA_Font *fn, const char *name, int size, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable)
|
2005-03-20 07:57:55 -08:00
|
|
|
{
|
|
|
|
RGBA_Font_Int *fi;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2010-10-29 05:55:42 -07:00
|
|
|
if (!fn) return NULL;
|
2017-09-25 02:34:22 -07:00
|
|
|
fi = evas_common_font_int_load(name, size, wanted_rend, bitmap_scalable);
|
2005-03-20 07:57:55 -08:00
|
|
|
if (fi)
|
|
|
|
{
|
2008-10-21 09:31:05 -07:00
|
|
|
fn->fonts = eina_list_append(fn->fonts, fi);
|
2006-02-27 07:40:46 -08:00
|
|
|
fi->hinting = fn->hinting;
|
2010-10-29 05:55:42 -07:00
|
|
|
if (fi->inuse) evas_common_font_int_promote(fi);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fi->inuse = 1;
|
|
|
|
fonts_use_lru = eina_inlist_prepend(fonts_use_lru, EINA_INLIST_GET(fi));
|
|
|
|
}
|
2005-03-20 08:41:49 -08:00
|
|
|
return fn;
|
2005-03-20 07:57:55 -08:00
|
|
|
}
|
2005-03-20 08:41:49 -08:00
|
|
|
return NULL;
|
2005-03-20 07:57:55 -08:00
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI RGBA_Font *
|
2017-09-25 02:34:22 -07:00
|
|
|
evas_common_font_memory_add(RGBA_Font *fn, 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)
|
2005-03-20 07:57:55 -08:00
|
|
|
{
|
|
|
|
RGBA_Font_Int *fi;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2005-08-26 01:00:49 -07:00
|
|
|
if (!fn)
|
|
|
|
return NULL;
|
2017-09-25 02:34:22 -07:00
|
|
|
fi = evas_common_font_int_memory_load(source, name, size, data, data_size, wanted_rend, bitmap_scalable);
|
2005-03-20 07:57:55 -08:00
|
|
|
if (fi)
|
|
|
|
{
|
2008-10-21 09:31:05 -07:00
|
|
|
fn->fonts = eina_list_append(fn->fonts, fi);
|
2006-02-27 07:40:46 -08:00
|
|
|
fi->hinting = fn->hinting;
|
2010-10-29 05:55:42 -07:00
|
|
|
if (fi->inuse) evas_common_font_int_promote(fi);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fi->inuse = 1;
|
|
|
|
fonts_use_lru = eina_inlist_prepend(fonts_use_lru, EINA_INLIST_GET(fi));
|
|
|
|
}
|
2005-03-20 08:41:49 -08:00
|
|
|
return fn;
|
2005-03-20 07:57:55 -08:00
|
|
|
}
|
2005-03-20 08:41:49 -08:00
|
|
|
return NULL;
|
2005-03-20 07:57:55 -08:00
|
|
|
}
|
|
|
|
|
2012-06-28 03:13:05 -07:00
|
|
|
EAPI void
|
|
|
|
evas_common_font_int_unref(RGBA_Font_Int *fi)
|
|
|
|
{
|
|
|
|
fi->references--;
|
|
|
|
if (fi->references == 0)
|
|
|
|
{
|
|
|
|
fonts_lru = eina_list_append(fonts_lru, fi);
|
|
|
|
evas_common_font_int_modify_cache_by(fi, 1);
|
|
|
|
evas_common_font_flush();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI void
|
2002-11-13 21:38:10 -08:00
|
|
|
evas_common_font_free(RGBA_Font *fn)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2008-10-21 09:31:05 -07:00
|
|
|
Eina_List *l;
|
2008-12-09 09:56:31 -08:00
|
|
|
RGBA_Font_Int *fi;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2010-02-03 03:18:00 -08:00
|
|
|
if (!fn) return;
|
2006-11-13 15:23:44 -08:00
|
|
|
fn->references--;
|
|
|
|
if (fn->references > 0) return;
|
2008-12-09 09:56:31 -08:00
|
|
|
EINA_LIST_FOREACH(fn->fonts, l, fi)
|
2012-06-28 03:13:05 -07:00
|
|
|
evas_common_font_int_unref(fi);
|
2009-06-15 08:07:13 -07:00
|
|
|
evas_common_font_flush();
|
2008-10-21 09:31:05 -07:00
|
|
|
eina_list_free(fn->fonts);
|
evas_object_textblock: add support for variation sequences
Summary: update font processing to handle variation sequences unicodes to select proper glypg in respect to variation seqences
Test Plan:
```
#define EFL_EO_API_SUPPORT 1
#define EFL_BETA_API_SUPPORT 1
#include <Eina.h>
#include <Efl.h>
#include <Elementary.h>
EAPI_MAIN int
elm_main(int argc, char **argv)
{
Evas_Object *win, *textblock;
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
win = elm_win_util_standard_add("Main", "");
elm_win_autodel_set(win, EINA_TRUE);
textblock = evas_object_textblock_add(win);
efl_canvas_text_style_set(textblock,NULL,"DEFAULT='font=DejaVuSans font_fallbacks=SamsungColorEmoji color=#000 font_size=20'");
evas_object_textblock_text_markup_set(textblock, "8️⃣☪️AAA☪︎1234567️⃣");
evas_object_size_hint_weight_set(textblock, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(textblock, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(textblock);
evas_object_move(textblock, 0, 0);
evas_object_resize(textblock, 320, 320);
evas_object_resize(win, 320, 320);
evas_object_show(win);
elm_run();
return 0;
}
ELM_MAIN()
```
Reviewers: woohyun, bowonryu, segfaultxavi, cedric, bu5hm4n
Reviewed By: woohyun, cedric
Subscribers: raster, bu5hm4n, subodh6129, herdsman, segfaultxavi, zmike, cedric, #committers, #reviewers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D9053
2019-12-11 23:22:12 -08:00
|
|
|
if (fn->fash)
|
|
|
|
{
|
|
|
|
fn->fash->freeme(fn->fash);
|
|
|
|
fn->fash = NULL;
|
|
|
|
}
|
2006-11-13 15:23:44 -08:00
|
|
|
LKD(fn->lock);
|
2005-03-20 07:57:55 -08:00
|
|
|
free(fn);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI void
|
2006-02-27 06:03:27 -08:00
|
|
|
evas_common_font_hinting_set(RGBA_Font *fn, Font_Hint_Flags hinting)
|
|
|
|
{
|
2008-10-21 09:31:05 -07:00
|
|
|
Eina_List *l;
|
2008-12-09 09:56:31 -08:00
|
|
|
RGBA_Font_Int *fi;
|
2008-07-10 11:12:45 -07:00
|
|
|
|
2010-10-29 05:55:42 -07:00
|
|
|
if (!fn) return;
|
2006-02-27 06:03:27 -08:00
|
|
|
fn->hinting = hinting;
|
2008-12-09 09:56:31 -08:00
|
|
|
EINA_LIST_FOREACH(fn->fonts, l, fi)
|
2010-10-29 05:55:42 -07:00
|
|
|
{
|
2013-06-04 03:44:52 -07:00
|
|
|
if (fi->hinting != fn->hinting)
|
2013-06-24 05:28:27 -07:00
|
|
|
_evas_common_font_int_clear(fi);
|
2010-10-29 05:55:42 -07:00
|
|
|
fi->hinting = fn->hinting;
|
|
|
|
}
|
2006-02-27 06:03:27 -08:00
|
|
|
}
|
|
|
|
|
2009-06-17 03:01:52 -07:00
|
|
|
EAPI Eina_Bool
|
2006-02-27 06:03:27 -08:00
|
|
|
evas_common_hinting_available(Font_Hint_Flags hinting)
|
|
|
|
{
|
2006-10-08 06:00:26 -07:00
|
|
|
switch (hinting)
|
2006-02-27 06:03:27 -08:00
|
|
|
{
|
2006-10-08 06:00:26 -07:00
|
|
|
case FONT_NO_HINT:
|
|
|
|
case FONT_AUTO_HINT:
|
|
|
|
/* these two hinting modes are always available */
|
2009-06-17 03:01:52 -07:00
|
|
|
return EINA_TRUE;
|
2006-10-08 06:00:26 -07:00
|
|
|
case FONT_BYTECODE_HINT:
|
|
|
|
/* Only use the bytecode interpreter if support for the _patented_
|
|
|
|
* algorithms is available because the free bytecode
|
|
|
|
* interpreter's results are too crappy.
|
|
|
|
*
|
|
|
|
* On freetyp 2.2+, we can ask the library about support for
|
|
|
|
* the patented interpreter. On older versions, we need to use
|
|
|
|
* macros to check for it.
|
|
|
|
*/
|
|
|
|
#if FREETYPE_MINOR >= 2
|
|
|
|
return FT_Get_TrueType_Engine_Type(evas_ft_lib) >=
|
|
|
|
FT_TRUETYPE_ENGINE_TYPE_PATENTED;
|
2006-02-27 06:03:27 -08:00
|
|
|
#else
|
2006-10-08 06:58:58 -07:00
|
|
|
/* we may not rely on TT_CONFIG_OPTION_BYTECODE_INTERPRETER
|
|
|
|
* here to find out whether it's supported.
|
|
|
|
*
|
|
|
|
* so, assume it is. o_O
|
|
|
|
*/
|
2009-06-17 03:01:52 -07:00
|
|
|
return EINA_TRUE;
|
2006-02-27 06:03:27 -08:00
|
|
|
#endif
|
|
|
|
}
|
2006-10-08 06:00:26 -07:00
|
|
|
/* shouldn't get here - need to add another case statement */
|
2009-06-17 03:01:52 -07:00
|
|
|
return EINA_FALSE;
|
2006-02-27 06:03:27 -08:00
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI RGBA_Font *
|
2017-09-25 02:34:22 -07:00
|
|
|
evas_common_font_memory_hinting_load(const char *source, const char *name, int size, const void *data, int data_size, Font_Hint_Flags hinting, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable)
|
2006-02-27 07:40:46 -08:00
|
|
|
{
|
|
|
|
RGBA_Font *fn;
|
|
|
|
|
2017-09-25 02:34:22 -07:00
|
|
|
fn = evas_common_font_memory_load(source, name, size, data, data_size, wanted_rend, bitmap_scalable);
|
2006-02-27 07:40:46 -08:00
|
|
|
if (fn) evas_common_font_hinting_set(fn, hinting);
|
|
|
|
return fn;
|
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI RGBA_Font *
|
2017-09-25 02:34:22 -07:00
|
|
|
evas_common_font_hinting_load(const char *name, int size, Font_Hint_Flags hinting, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable)
|
2006-02-27 07:40:46 -08:00
|
|
|
{
|
|
|
|
RGBA_Font *fn;
|
|
|
|
|
2017-09-25 02:34:22 -07:00
|
|
|
fn = evas_common_font_load(name, size, wanted_rend, bitmap_scalable);
|
2006-02-27 07:40:46 -08:00
|
|
|
if (fn) evas_common_font_hinting_set(fn, hinting);
|
|
|
|
return fn;
|
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI RGBA_Font *
|
2017-09-25 02:34:22 -07:00
|
|
|
evas_common_font_hinting_add(RGBA_Font *fn, const char *name, int size, Font_Hint_Flags hinting, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable)
|
2006-02-27 07:40:46 -08:00
|
|
|
{
|
2017-09-25 02:34:22 -07:00
|
|
|
fn = evas_common_font_add(fn, name, size, wanted_rend, bitmap_scalable);
|
2006-02-27 07:40:46 -08:00
|
|
|
if (fn) evas_common_font_hinting_set(fn, hinting);
|
|
|
|
return fn;
|
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI RGBA_Font *
|
2017-09-25 02:34:22 -07:00
|
|
|
evas_common_font_memory_hinting_add(RGBA_Font *fn, const char *source, const char *name, int size, const void *data, int data_size, Font_Hint_Flags hinting, Font_Rend_Flags wanted_rend, Efl_Text_Font_Bitmap_Scalable bitmap_scalable)
|
2006-02-27 07:40:46 -08:00
|
|
|
{
|
2012-06-22 13:31:31 -07:00
|
|
|
fn = evas_common_font_memory_add(fn, source, name, size, data, data_size,
|
2017-09-25 02:34:22 -07:00
|
|
|
wanted_rend, bitmap_scalable);
|
2006-02-27 07:40:46 -08:00
|
|
|
if (fn) evas_common_font_hinting_set(fn, hinting);
|
|
|
|
return fn;
|
|
|
|
}
|
|
|
|
|
2010-04-12 01:23:53 -07:00
|
|
|
static void
|
|
|
|
_evas_common_font_int_clear(RGBA_Font_Int *fi)
|
|
|
|
{
|
|
|
|
LKL(fi->ft_mutex);
|
|
|
|
if (!fi->fash)
|
|
|
|
{
|
|
|
|
LKU(fi->ft_mutex);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
evas_common_font_int_modify_cache_by(fi, -1);
|
2012-06-28 03:13:05 -07:00
|
|
|
if (fi->references <= 1)
|
|
|
|
{
|
|
|
|
if (fi->fash)
|
|
|
|
{
|
|
|
|
fi->fash->freeme(fi->fash);
|
|
|
|
fi->fash = NULL;
|
|
|
|
}
|
2010-04-12 01:23:53 -07:00
|
|
|
}
|
2010-10-29 05:55:42 -07:00
|
|
|
if (fi->inuse) fonts_use_usage -= fi->usage;
|
|
|
|
fi->usage = 0;
|
2012-05-10 18:50:40 -07:00
|
|
|
fi->generation++;
|
2010-04-12 01:23:53 -07:00
|
|
|
LKU(fi->ft_mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2012-11-04 03:51:42 -08:00
|
|
|
_evas_common_font_all_clear_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata EINA_UNUSED)
|
2010-04-12 01:23:53 -07:00
|
|
|
{
|
|
|
|
RGBA_Font_Int *fi = data;
|
|
|
|
_evas_common_font_int_clear(fi);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
evas_common_font_all_clear(void)
|
|
|
|
{
|
|
|
|
eina_hash_foreach(fonts, _evas_common_font_all_clear_cb, NULL);
|
|
|
|
}
|
|
|
|
|
2010-10-29 05:55:42 -07:00
|
|
|
void
|
2014-01-10 01:48:42 -08:00
|
|
|
evas_common_font_int_promote(RGBA_Font_Int *fi EINA_UNUSED)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2010-10-29 05:55:42 -07:00
|
|
|
return;
|
2017-11-06 18:22:09 -08:00
|
|
|
/* unused - keep for reference
|
2010-10-29 05:55:42 -07:00
|
|
|
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));
|
|
|
|
fonts_use_lru = eina_inlist_prepend(fonts_use_lru, EINA_INLIST_GET(fi));
|
2014-01-10 01:48:42 -08:00
|
|
|
*/
|
2010-10-29 05:55:42 -07:00
|
|
|
}
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2010-10-29 05:55:42 -07:00
|
|
|
void
|
|
|
|
evas_common_font_int_use_increase(int size)
|
|
|
|
{
|
|
|
|
fonts_use_usage += size;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_common_font_int_use_trim(void)
|
|
|
|
{
|
2014-01-10 01:48:42 -08:00
|
|
|
return;
|
2017-11-06 18:22:09 -08:00
|
|
|
/* unused - keep for reference
|
2010-10-29 05:55:42 -07:00
|
|
|
Eina_Inlist *l;
|
|
|
|
|
|
|
|
if (fonts_use_usage <= (font_cache << 1)) return;
|
|
|
|
if (!fonts_use_lru) return;
|
|
|
|
l = fonts_use_lru->last;
|
|
|
|
while (l)
|
|
|
|
{
|
|
|
|
RGBA_Font_Int *fi = (RGBA_Font_Int *)l;
|
|
|
|
if (fonts_use_usage <= (font_cache << 1)) break;
|
|
|
|
// FIXME: del fi->kerning content
|
|
|
|
_evas_common_font_int_clear(fi);
|
|
|
|
evas_common_font_int_unload(fi);
|
|
|
|
evas_common_font_int_promote(fi);
|
|
|
|
l = l->prev;
|
|
|
|
}
|
2014-01-10 01:48:42 -08:00
|
|
|
*/
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
2010-10-29 05:55:42 -07:00
|
|
|
|
|
|
|
void
|
2014-01-10 01:48:42 -08:00
|
|
|
evas_common_font_int_unload(RGBA_Font_Int *fi EINA_UNUSED)
|
2010-10-29 05:55:42 -07:00
|
|
|
{
|
|
|
|
return;
|
2017-11-06 18:22:09 -08:00
|
|
|
/* unused - keep for reference
|
2010-10-29 05:55:42 -07:00
|
|
|
if (!fi->src->ft.face) return;
|
|
|
|
_evas_common_font_int_clear(fi);
|
|
|
|
FT_Done_Size(fi->ft.size);
|
|
|
|
fi->ft.size = NULL;
|
|
|
|
evas_common_font_source_unload(fi->src);
|
2014-01-10 01:48:42 -08:00
|
|
|
*/
|
2010-10-29 05:55:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
evas_common_font_int_reload(RGBA_Font_Int *fi)
|
|
|
|
{
|
|
|
|
if (fi->src->ft.face) return;
|
2010-11-01 21:56:57 -07:00
|
|
|
evas_common_font_source_load_complete(fi->src);
|
|
|
|
return;
|
2017-11-06 18:22:09 -08:00
|
|
|
/* unused - keep for reference
|
2010-10-29 05:55:42 -07:00
|
|
|
evas_common_font_source_reload(fi->src);
|
|
|
|
evas_common_font_int_load_complete(fi);
|
2014-01-10 01:48:42 -08:00
|
|
|
*/
|
2010-10-29 05:55:42 -07:00
|
|
|
}
|
|
|
|
|
2007-05-05 03:30:11 -07:00
|
|
|
/* when the fi->references == 0 we increase this instead of really deleting
|
2008-07-10 11:12:45 -07:00
|
|
|
* we then check if the cache_useage size is larger than allowed
|
|
|
|
* !If the cache is NOT too large we dont delete font_int
|
2007-05-05 03:30:11 -07:00
|
|
|
* !If the cache is too large we really delete font_int */
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI void
|
2005-03-20 07:57:55 -08:00
|
|
|
evas_common_font_int_modify_cache_by(RGBA_Font_Int *fi, int dir)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2010-10-29 05:55:42 -07:00
|
|
|
font_cache_usage += dir * (sizeof(RGBA_Font) + fi->usage +
|
|
|
|
sizeof(FT_FaceRec) + 16384); /* fudge values */
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI int
|
2002-11-13 21:38:10 -08:00
|
|
|
evas_common_font_cache_get(void)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
return font_cache;
|
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI void
|
2002-11-13 21:38:10 -08:00
|
|
|
evas_common_font_cache_set(int size)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
font_cache = size;
|
2002-11-13 21:38:10 -08:00
|
|
|
evas_common_font_flush();
|
2010-10-29 05:55:42 -07:00
|
|
|
evas_common_font_int_use_trim();
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI void
|
2002-11-13 21:38:10 -08:00
|
|
|
evas_common_font_flush(void)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
if (font_cache_usage < font_cache) return;
|
2010-05-17 21:22:33 -07:00
|
|
|
while (font_cache_usage > font_cache)
|
|
|
|
{
|
|
|
|
int pfont_cache_usage;
|
2017-11-06 18:22:09 -08:00
|
|
|
|
2010-05-17 21:22:33 -07:00
|
|
|
pfont_cache_usage = font_cache_usage;
|
|
|
|
evas_common_font_flush_last();
|
|
|
|
if (pfont_cache_usage == font_cache_usage) break;
|
|
|
|
}
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2007-05-05 03:30:11 -07:00
|
|
|
/* We run this when the cache gets larger than allowed size
|
|
|
|
* We check cache size each time a fi->references goes to 0
|
|
|
|
* PERFORMS: Find font_int(s) with references == 0 and delete them */
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI void
|
2002-11-13 21:38:10 -08:00
|
|
|
evas_common_font_flush_last(void)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2005-03-20 07:57:55 -08:00
|
|
|
RGBA_Font_Int *fi = NULL;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2013-06-20 04:28:18 -07:00
|
|
|
if (!fonts_lru) return;
|
2009-06-15 08:07:13 -07:00
|
|
|
fi = eina_list_data_get(fonts_lru);
|
|
|
|
fonts_lru = eina_list_remove_list(fonts_lru, fonts_lru);
|
|
|
|
eina_hash_del(fonts, fi, fi);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI RGBA_Font_Int *
|
2011-04-12 02:05:47 -07:00
|
|
|
evas_common_font_int_find(const char *name, int size,
|
2017-09-25 02:34:22 -07:00
|
|
|
Font_Rend_Flags wanted_rend,
|
|
|
|
Efl_Text_Font_Bitmap_Scalable bitmap_scalable)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2009-06-15 08:07:13 -07:00
|
|
|
RGBA_Font_Int tmp_fi;
|
|
|
|
RGBA_Font_Source tmp_fn;
|
2008-10-20 05:36:48 -07:00
|
|
|
RGBA_Font_Int *fi;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2009-06-15 08:07:13 -07:00
|
|
|
tmp_fn.name = (char*) eina_stringshare_add(name);
|
|
|
|
tmp_fi.src = &tmp_fn;
|
|
|
|
tmp_fi.size = size;
|
2011-04-12 02:05:47 -07:00
|
|
|
tmp_fi.wanted_rend = wanted_rend;
|
2017-09-25 02:34:22 -07:00
|
|
|
tmp_fi.bitmap_scalable = bitmap_scalable;
|
2009-06-15 08:07:13 -07:00
|
|
|
fi = eina_hash_find(fonts, &tmp_fi);
|
|
|
|
if (fi)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2009-06-15 08:07:13 -07:00
|
|
|
if (fi->references == 0)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2009-06-15 08:07:13 -07:00
|
|
|
evas_common_font_int_modify_cache_by(fi, -1);
|
|
|
|
fonts_lru = eina_list_remove(fonts_lru, fi);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
2009-06-15 08:07:13 -07:00
|
|
|
fi->references++;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
2009-06-15 08:07:13 -07:00
|
|
|
eina_stringshare_del(tmp_fn.name);
|
|
|
|
return fi;
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
2016-04-11 20:47:30 -07:00
|
|
|
|
|
|
|
static void
|
|
|
|
_font_int_ext_clear(RGBA_Font_Int *fi)
|
|
|
|
{
|
|
|
|
RGBA_Font_Glyph *fg;
|
|
|
|
Fash_Glyph_Map *fmap;
|
|
|
|
Fash_Glyph_Map2 *fash2;
|
|
|
|
Fash_Glyph *fash;
|
|
|
|
int i, j, k;
|
|
|
|
|
|
|
|
fash = fi->fash;
|
|
|
|
if (!fash) return;
|
|
|
|
for (k = 0; k <= 0xff; k++)
|
|
|
|
{
|
|
|
|
fash2 = fash->bucket[k];
|
|
|
|
if (fash2)
|
|
|
|
{
|
|
|
|
for (j = 0; j <= 0xff; j++)
|
|
|
|
{
|
|
|
|
fmap = fash2->bucket[j];
|
|
|
|
if (fmap)
|
|
|
|
{
|
|
|
|
for (i = 0; i <= 0xff; i++)
|
|
|
|
{
|
|
|
|
fg = fmap->item[i];
|
|
|
|
if ((fg) && (fg != (void *)(-1)))
|
|
|
|
{
|
|
|
|
if (fg->ext_dat)
|
|
|
|
{
|
|
|
|
if (fg->ext_dat_free)
|
|
|
|
fg->ext_dat_free(fg->ext_dat);
|
|
|
|
fg->ext_dat = NULL;
|
|
|
|
fg->ext_dat_free = NULL;
|
|
|
|
}
|
2019-08-20 16:30:23 -07:00
|
|
|
if (fg->col_dat) evas_cache_image_drop(fg->col_dat);
|
|
|
|
fg->col_dat = NULL;
|
2016-04-11 20:47:30 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_cb_hash_font_ext(const Eina_Hash *hash EINA_UNUSED,
|
|
|
|
const void *key EINA_UNUSED,
|
|
|
|
void *data EINA_UNUSED,
|
|
|
|
void *fdata EINA_UNUSED)
|
|
|
|
{
|
|
|
|
_font_int_ext_clear(data);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
evas_common_font_ext_clear(void)
|
|
|
|
{
|
|
|
|
eina_hash_foreach(fonts, _cb_hash_font_ext, NULL);
|
|
|
|
}
|