parent
325aaa82ad
commit
7fd07d8712
199
src/bin/e_font.c
199
src/bin/e_font.c
|
@ -2,8 +2,8 @@
|
|||
|
||||
#define E_TOK_STYLE ":style="
|
||||
|
||||
static Eina_Bool _font_hash_free_cb(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *data, void *fdata __UNUSED__);
|
||||
static Eina_Hash *_e_font_available_hash_add(Eina_Hash *font_hash, const char *full_name);
|
||||
static Eina_Bool _font_hash_free_cb(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *data, void *fdata __UNUSED__);
|
||||
static Eina_Hash *_e_font_available_hash_add(Eina_Hash *font_hash, const char *full_name);
|
||||
static E_Font_Properties *_e_font_fontconfig_name_parse(Eina_Hash **font_hash, E_Font_Properties *efp, const char *font);
|
||||
static char _fn_buf[1024];
|
||||
|
||||
|
@ -38,29 +38,29 @@ e_font_apply(void)
|
|||
l = e_config->font_fallbacks;
|
||||
if (l)
|
||||
{
|
||||
eff = eina_list_data_get(l);
|
||||
len = strlen(eff->name);
|
||||
if (len < blen)
|
||||
{
|
||||
strcpy(buf, eff->name);
|
||||
blen -= len;
|
||||
}
|
||||
EINA_LIST_FOREACH(eina_list_next(l), l, eff)
|
||||
{
|
||||
len = 1;
|
||||
if (len < blen)
|
||||
{
|
||||
strcat(buf, ",");
|
||||
blen -= len;
|
||||
}
|
||||
len = strlen(eff->name);
|
||||
if (len < blen)
|
||||
{
|
||||
strcat(buf, eff->name);
|
||||
blen -= len;
|
||||
}
|
||||
}
|
||||
edje_fontset_append_set(buf);
|
||||
eff = eina_list_data_get(l);
|
||||
len = strlen(eff->name);
|
||||
if (len < blen)
|
||||
{
|
||||
strcpy(buf, eff->name);
|
||||
blen -= len;
|
||||
}
|
||||
EINA_LIST_FOREACH(eina_list_next(l), l, eff)
|
||||
{
|
||||
len = 1;
|
||||
if (len < blen)
|
||||
{
|
||||
strcat(buf, ",");
|
||||
blen -= len;
|
||||
}
|
||||
len = strlen(eff->name);
|
||||
if (len < blen)
|
||||
{
|
||||
strcat(buf, eff->name);
|
||||
blen -= len;
|
||||
}
|
||||
}
|
||||
edje_fontset_append_set(buf);
|
||||
}
|
||||
else
|
||||
edje_fontset_append_set(NULL);
|
||||
|
@ -68,13 +68,13 @@ e_font_apply(void)
|
|||
/* setup edje text classes */
|
||||
EINA_LIST_FOREACH(e_config->font_defaults, l, efd)
|
||||
{
|
||||
edje_text_class_set(efd->text_class, efd->font, efd->size);
|
||||
edje_text_class_set(efd->text_class, efd->font, efd->size);
|
||||
}
|
||||
|
||||
/* Update borders */
|
||||
EINA_LIST_FOREACH(e_border_client_list(), l, bd)
|
||||
{
|
||||
e_border_frame_recalc(bd);
|
||||
e_border_frame_recalc(bd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,11 +99,11 @@ e_font_available_list(void)
|
|||
e_fonts = NULL;
|
||||
EINA_LIST_FOREACH(evas_fonts, l, evas_font)
|
||||
{
|
||||
E_Font_Available *efa;
|
||||
E_Font_Available *efa;
|
||||
|
||||
efa = E_NEW(E_Font_Available, 1);
|
||||
efa->name = eina_stringshare_add(evas_font);
|
||||
e_fonts = eina_list_append(e_fonts, efa);
|
||||
efa = E_NEW(E_Font_Available, 1);
|
||||
efa->name = eina_stringshare_add(evas_font);
|
||||
e_fonts = eina_list_append(e_fonts, efa);
|
||||
}
|
||||
|
||||
evas_font_available_list_free(con->bg_evas, evas_fonts);
|
||||
|
@ -118,9 +118,9 @@ e_font_available_list_free(Eina_List *available)
|
|||
|
||||
EINA_LIST_FREE(available, efa)
|
||||
{
|
||||
if (efa->name) eina_stringshare_del(efa->name);
|
||||
E_FREE(efa);
|
||||
}
|
||||
if (efa->name) eina_stringshare_del(efa->name);
|
||||
E_FREE(efa);
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
|
@ -195,10 +195,10 @@ _e_font_fontconfig_name_parse(Eina_Hash **font_hash, E_Font_Properties *efp, con
|
|||
efp = calloc(1, sizeof(E_Font_Properties));
|
||||
efp->name = eina_stringshare_add(name);
|
||||
if (font_hash)
|
||||
{
|
||||
if (!*font_hash) *font_hash = eina_hash_string_superfast_new(NULL);
|
||||
eina_hash_add(*font_hash, name, efp);
|
||||
}
|
||||
{
|
||||
if (!*font_hash) *font_hash = eina_hash_string_superfast_new(NULL);
|
||||
eina_hash_add(*font_hash, name, efp);
|
||||
}
|
||||
}
|
||||
s2 = strchr(style, ',');
|
||||
if (s2)
|
||||
|
@ -225,16 +225,15 @@ _e_font_fontconfig_name_parse(Eina_Hash **font_hash, E_Font_Properties *efp, con
|
|||
efp = calloc(1, sizeof(E_Font_Properties));
|
||||
efp->name = eina_stringshare_add(font);
|
||||
if (font_hash)
|
||||
{
|
||||
if (!*font_hash) *font_hash = eina_hash_string_superfast_new(NULL);
|
||||
eina_hash_add(*font_hash, font, efp);
|
||||
}
|
||||
{
|
||||
if (!*font_hash) *font_hash = eina_hash_string_superfast_new(NULL);
|
||||
eina_hash_add(*font_hash, font, efp);
|
||||
}
|
||||
}
|
||||
}
|
||||
return efp;
|
||||
}
|
||||
|
||||
|
||||
static Eina_Hash *
|
||||
_e_font_available_hash_add(Eina_Hash *font_hash, const char *full_name)
|
||||
{
|
||||
|
@ -273,7 +272,6 @@ e_font_available_list_parse(Eina_List *list)
|
|||
return font_hash;
|
||||
}
|
||||
|
||||
|
||||
EAPI const char *
|
||||
e_font_fontconfig_name_get(const char *name, const char *style)
|
||||
{
|
||||
|
@ -281,7 +279,7 @@ e_font_fontconfig_name_get(const char *name, const char *style)
|
|||
|
||||
if (!name) return NULL;
|
||||
if (!style || style[0] == 0) return eina_stringshare_add(name);
|
||||
snprintf(buf, 256, "%s"E_TOK_STYLE"%s", name, style);
|
||||
snprintf(buf, 256, "%s"E_TOK_STYLE "%s", name, style);
|
||||
return eina_stringshare_add(buf);
|
||||
}
|
||||
|
||||
|
@ -292,9 +290,9 @@ e_font_fallback_clear(void)
|
|||
|
||||
EINA_LIST_FREE(e_config->font_fallbacks, eff)
|
||||
{
|
||||
if (eff->name) eina_stringshare_del(eff->name);
|
||||
E_FREE(eff);
|
||||
}
|
||||
if (eff->name) eina_stringshare_del(eff->name);
|
||||
E_FREE(eff);
|
||||
}
|
||||
}
|
||||
|
||||
EAPI void
|
||||
|
@ -329,14 +327,14 @@ e_font_fallback_remove(const char *font)
|
|||
|
||||
EINA_LIST_FOREACH(e_config->font_fallbacks, next, eff)
|
||||
{
|
||||
if (!strcmp(eff->name, font))
|
||||
{
|
||||
e_config->font_fallbacks =
|
||||
if (!strcmp(eff->name, font))
|
||||
{
|
||||
e_config->font_fallbacks =
|
||||
eina_list_remove_list(e_config->font_fallbacks, next);
|
||||
if (eff->name) eina_stringshare_del(eff->name);
|
||||
E_FREE(eff);
|
||||
break;
|
||||
}
|
||||
if (eff->name) eina_stringshare_del(eff->name);
|
||||
E_FREE(eff);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -355,18 +353,18 @@ e_font_default_set(const char *text_class, const char *font, Evas_Font_Size size
|
|||
/* search for the text class */
|
||||
EINA_LIST_FOREACH(e_config->font_defaults, next, efd)
|
||||
{
|
||||
if (!strcmp(efd->text_class, text_class))
|
||||
{
|
||||
if (efd->font) eina_stringshare_del(efd->font);
|
||||
efd->font = eina_stringshare_add(font);
|
||||
efd->size = size;
|
||||
/* move to the front of the list */
|
||||
e_config->font_defaults =
|
||||
if (!strcmp(efd->text_class, text_class))
|
||||
{
|
||||
if (efd->font) eina_stringshare_del(efd->font);
|
||||
efd->font = eina_stringshare_add(font);
|
||||
efd->size = size;
|
||||
/* move to the front of the list */
|
||||
e_config->font_defaults =
|
||||
eina_list_remove_list(e_config->font_defaults, next);
|
||||
e_config->font_defaults =
|
||||
e_config->font_defaults =
|
||||
eina_list_prepend(e_config->font_defaults, efd);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* the text class doesn't exist */
|
||||
|
@ -390,18 +388,18 @@ e_font_default_get(const char *text_class)
|
|||
/* search for the text class */
|
||||
EINA_LIST_FOREACH(e_config->font_defaults, next, efd)
|
||||
{
|
||||
if (!strcmp(efd->text_class, text_class))
|
||||
{
|
||||
/* move to the front of the list */
|
||||
e_config->font_defaults =
|
||||
if (!strcmp(efd->text_class, text_class))
|
||||
{
|
||||
/* move to the front of the list */
|
||||
e_config->font_defaults =
|
||||
eina_list_remove_list(e_config->font_defaults, next);
|
||||
e_config->font_defaults =
|
||||
e_config->font_defaults =
|
||||
eina_list_prepend(e_config->font_defaults, efd);
|
||||
return efd;
|
||||
}
|
||||
if (!strcmp(efd->text_class, "default")) defd = efd;
|
||||
return efd;
|
||||
}
|
||||
if (!strcmp(efd->text_class, "default")) defd = efd;
|
||||
}
|
||||
if (!defd) defd = efd;
|
||||
if (!defd) defd = efd;
|
||||
return defd;
|
||||
}
|
||||
|
||||
|
@ -414,17 +412,17 @@ e_font_default_remove(const char *text_class)
|
|||
/* search for the text class */
|
||||
EINA_LIST_FOREACH(e_config->font_defaults, next, efd)
|
||||
{
|
||||
if (!strcmp(efd->text_class, text_class))
|
||||
{
|
||||
e_config->font_defaults =
|
||||
if (!strcmp(efd->text_class, text_class))
|
||||
{
|
||||
e_config->font_defaults =
|
||||
eina_list_remove_list(e_config->font_defaults, next);
|
||||
if (efd->text_class) eina_stringshare_del(efd->text_class);
|
||||
if (efd->font) eina_stringshare_del(efd->font);
|
||||
E_FREE(efd);
|
||||
edje_text_class_del(text_class);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (efd->text_class) eina_stringshare_del(efd->text_class);
|
||||
if (efd->font) eina_stringshare_del(efd->font);
|
||||
E_FREE(efd);
|
||||
edje_text_class_del(text_class);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EAPI Eina_List *
|
||||
|
@ -449,34 +447,35 @@ e_font_default_string_get(const char *text_class, Evas_Font_Size *size_ret)
|
|||
efd = e_font_default_get(text_class);
|
||||
if (!efd)
|
||||
{
|
||||
if (size_ret) *size_ret = 0;
|
||||
return "";
|
||||
if (size_ret) *size_ret = 0;
|
||||
return "";
|
||||
}
|
||||
blen = sizeof(_fn_buf) - 1;
|
||||
|
||||
len = strlen(efd->font);
|
||||
if (len < blen)
|
||||
{
|
||||
strcpy(_fn_buf, efd->font);
|
||||
blen -= len;
|
||||
strcpy(_fn_buf, efd->font);
|
||||
blen -= len;
|
||||
}
|
||||
|
||||
EINA_LIST_FOREACH(e_config->font_fallbacks, next, eff)
|
||||
{
|
||||
len = 1;
|
||||
if (len < blen)
|
||||
{
|
||||
strcat(_fn_buf, ",");
|
||||
blen -= len;
|
||||
}
|
||||
len = strlen(eff->name);
|
||||
if (len < blen)
|
||||
{
|
||||
strcat(_fn_buf, eff->name);
|
||||
blen -= len;
|
||||
}
|
||||
len = 1;
|
||||
if (len < blen)
|
||||
{
|
||||
strcat(_fn_buf, ",");
|
||||
blen -= len;
|
||||
}
|
||||
len = strlen(eff->name);
|
||||
if (len < blen)
|
||||
{
|
||||
strcat(_fn_buf, eff->name);
|
||||
blen -= len;
|
||||
}
|
||||
}
|
||||
|
||||
if (size_ret) *size_ret = efd->size;
|
||||
return _fn_buf;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue