forked from enlightenment/efl
parent
12de48bd81
commit
5213c0720a
|
@ -881,7 +881,7 @@ _font_overlay_change(void *data __UNUSED__,
|
|||
{
|
||||
if (tc_data->font)
|
||||
{
|
||||
const char *name;
|
||||
char *name;
|
||||
|
||||
name = elm_font_fontconfig_name_get(tc_data->font,
|
||||
tc_data->style);
|
||||
|
@ -1483,7 +1483,7 @@ static void
|
|||
_font_preview_update(Evas_Object *win)
|
||||
{
|
||||
Evas_Font_Size sz;
|
||||
const char *name;
|
||||
char *name;
|
||||
|
||||
if (!fdata.cur_font)
|
||||
return;
|
||||
|
@ -1733,7 +1733,8 @@ _font_classes_list_load(Evas_Object *li)
|
|||
static void
|
||||
_fonts_data_fill(Evas *evas)
|
||||
{
|
||||
const Eina_List *fo_list, *text_classes, *l;
|
||||
const Eina_List *fo_list, *l;
|
||||
Eina_List *text_classes;
|
||||
Elm_Text_Class_Data *tc_data;
|
||||
Elm_Font_Size_Data *sd;
|
||||
Elm_Font_Overlay *efo;
|
||||
|
|
|
@ -199,7 +199,7 @@ EAPI extern Elm_Version *elm_version;
|
|||
#include <elm_flip.h> //Done. There are many TODOs in flip.c
|
||||
#include <elm_flipselector.h> //Done.
|
||||
#include <elm_focus.h>
|
||||
#include <elm_fonts.h>
|
||||
#include <elm_fonts.h> //Done.
|
||||
#include <elm_frame.h> //Done.
|
||||
#include <elm_gengrid.h>
|
||||
#include <elm_genlist.h>
|
||||
|
|
|
@ -537,6 +537,7 @@ _elm_config_text_classes_get(void)
|
|||
{
|
||||
Elm_Text_Class *tc;
|
||||
tc = malloc(sizeof(*tc));
|
||||
if (!tc) continue;
|
||||
|
||||
*tc = _elm_text_classes[i];
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ _elm_font_properties_get(Eina_Hash **font_hash,
|
|||
|
||||
len = s1 - font;
|
||||
name = calloc(sizeof(char), len + 1);
|
||||
if (!name) return NULL;
|
||||
strncpy(name, font, len);
|
||||
|
||||
/* get subname (should be english) */
|
||||
|
@ -32,8 +33,11 @@ _elm_font_properties_get(Eina_Hash **font_hash,
|
|||
{
|
||||
len = s2 - name;
|
||||
name = realloc(name, sizeof(char) * len + 1);
|
||||
memset(name, 0, sizeof(char) * len + 1);
|
||||
strncpy(name, font, len);
|
||||
if (!name)
|
||||
{
|
||||
memset(name, 0, sizeof(char) * len + 1);
|
||||
strncpy(name, font, len);
|
||||
}
|
||||
}
|
||||
|
||||
if (!strncmp(s1, ELM_FONT_TOKEN_STYLE, strlen(ELM_FONT_TOKEN_STYLE)))
|
||||
|
@ -44,12 +48,15 @@ _elm_font_properties_get(Eina_Hash **font_hash,
|
|||
if (!efp)
|
||||
{
|
||||
efp = calloc(1, sizeof(Elm_Font_Properties));
|
||||
efp->name = eina_stringshare_add(name);
|
||||
if (font_hash)
|
||||
if (efp)
|
||||
{
|
||||
if (!*font_hash)
|
||||
*font_hash = eina_hash_string_superfast_new(NULL);
|
||||
eina_hash_add(*font_hash, name, efp);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
s2 = strchr(style, ',');
|
||||
|
@ -60,10 +67,13 @@ _elm_font_properties_get(Eina_Hash **font_hash,
|
|||
len = s2 - style;
|
||||
style_old = style;
|
||||
style = calloc(sizeof(char), len + 1);
|
||||
strncpy(style, style_old, len);
|
||||
efp->styles = eina_list_append(efp->styles,
|
||||
eina_stringshare_add(style));
|
||||
free(style);
|
||||
if (style)
|
||||
{
|
||||
strncpy(style, style_old, len);
|
||||
efp->styles = eina_list_append(efp->styles,
|
||||
eina_stringshare_add(style));
|
||||
free(style);
|
||||
}
|
||||
}
|
||||
else
|
||||
efp->styles = eina_list_append(efp->styles,
|
||||
|
@ -77,19 +87,21 @@ _elm_font_properties_get(Eina_Hash **font_hash,
|
|||
if (!efp)
|
||||
{
|
||||
efp = calloc(1, sizeof(Elm_Font_Properties));
|
||||
efp->name = eina_stringshare_add(font);
|
||||
if (font_hash)
|
||||
if (efp)
|
||||
{
|
||||
if (!*font_hash)
|
||||
*font_hash = eina_hash_string_superfast_new(NULL);
|
||||
eina_hash_add(*font_hash, font, efp);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return efp;
|
||||
}
|
||||
|
||||
/* FIXME: do we really need it? */
|
||||
Eina_Hash *
|
||||
_elm_font_available_hash_add(Eina_Hash *font_hash,
|
||||
const char *full_name)
|
||||
|
@ -123,7 +135,8 @@ _font_hash_free_cb(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__,
|
|||
void
|
||||
_elm_font_available_hash_del(Eina_Hash *hash)
|
||||
{
|
||||
if (!hash) return ;
|
||||
if (!hash) return;
|
||||
|
||||
eina_hash_foreach(hash, _font_hash_free_cb, NULL);
|
||||
eina_hash_free(hash);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ typedef struct _Elm_Font_Properties
|
|||
*
|
||||
* Release the list with elm_text_classes_list_free().
|
||||
*/
|
||||
EAPI const Eina_List *elm_text_classes_list_get(void);
|
||||
EAPI Eina_List *elm_text_classes_list_get(void);
|
||||
|
||||
/**
|
||||
* Free Elementary's list of supported text classes.
|
||||
|
@ -45,7 +45,7 @@ EAPI const Eina_List *elm_text_classes_list_get(void);
|
|||
*
|
||||
* @see elm_text_classes_list_get().
|
||||
*/
|
||||
EAPI void elm_text_classes_list_free(const Eina_List *list);
|
||||
EAPI void elm_text_classes_list_free(Eina_List *list);
|
||||
|
||||
/**
|
||||
* Get Elementary's list of font overlays, set with
|
||||
|
@ -140,7 +140,7 @@ EAPI void elm_font_properties_free(Elm_Font_Properties *efp);
|
|||
* elm_font_properties_get(), for one style only (single font
|
||||
* instance, not family).
|
||||
*/
|
||||
EAPI const char *elm_font_fontconfig_name_get(const char *name, const char *style);
|
||||
EAPI char *elm_font_fontconfig_name_get(const char *name, const char *style);
|
||||
|
||||
/**
|
||||
* Free the font string return by elm_font_fontconfig_name_get().
|
||||
|
@ -149,7 +149,7 @@ EAPI const char *elm_font_fontconfig_name_get(const char *name, const char
|
|||
*
|
||||
* @ingroup Fonts
|
||||
*/
|
||||
EAPI void elm_font_fontconfig_name_free(const char *name);
|
||||
EAPI void elm_font_fontconfig_name_free(char *name);
|
||||
|
||||
/**
|
||||
* Create a font hash table of available system fonts.
|
||||
|
@ -168,15 +168,17 @@ EAPI void elm_font_fontconfig_name_free(const char *name);
|
|||
* default font families (Sans, Serif, Monospace), which should be
|
||||
* present on most systems.
|
||||
*/
|
||||
//XXX: How about elm_font_system_available_hash_add() ?
|
||||
EAPI Eina_Hash *elm_font_available_hash_add(Eina_List *list);
|
||||
|
||||
/**
|
||||
* Free the hash return by elm_font_available_hash_add().
|
||||
* Free the hash returned by elm_font_available_hash_add().
|
||||
*
|
||||
* @param hash the hash to be freed.
|
||||
*
|
||||
* @ingroup Fonts
|
||||
*/
|
||||
//XXX: How about elm_font_system_available_hash_del() ?
|
||||
EAPI void elm_font_available_hash_del(Eina_Hash *hash);
|
||||
|
||||
/**
|
||||
|
|
|
@ -1155,16 +1155,16 @@ elm_engine_set(const char *engine)
|
|||
_elm_config_engine_set(engine);
|
||||
}
|
||||
|
||||
EAPI const Eina_List *
|
||||
EAPI Eina_List *
|
||||
elm_text_classes_list_get(void)
|
||||
{
|
||||
return _elm_config_text_classes_get();
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_text_classes_list_free(const Eina_List *list)
|
||||
elm_text_classes_list_free(Eina_List *list)
|
||||
{
|
||||
_elm_config_text_classes_free((Eina_List *)list);
|
||||
_elm_config_text_classes_free(list);
|
||||
}
|
||||
|
||||
EAPI const Eina_List *
|
||||
|
@ -1178,12 +1178,14 @@ elm_font_overlay_set(const char *text_class,
|
|||
const char *font,
|
||||
Evas_Font_Size size)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN(text_class);
|
||||
_elm_config_font_overlay_set(text_class, font, size);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_font_overlay_unset(const char *text_class)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN(text_class);
|
||||
_elm_config_font_overlay_remove(text_class);
|
||||
}
|
||||
|
||||
|
@ -1212,20 +1214,20 @@ elm_font_properties_free(Elm_Font_Properties *efp)
|
|||
free(efp);
|
||||
}
|
||||
|
||||
EAPI const char *
|
||||
EAPI char *
|
||||
elm_font_fontconfig_name_get(const char *name,
|
||||
const char *style)
|
||||
{
|
||||
char buf[256];
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
|
||||
if (!style || style[0] == 0) return eina_stringshare_add(name);
|
||||
if (!style || style[0] == 0) return (char *) eina_stringshare_add(name);
|
||||
snprintf(buf, 256, "%s" ELM_FONT_TOKEN_STYLE "%s", name, style);
|
||||
return eina_stringshare_add(buf);
|
||||
return (char *) eina_stringshare_add(buf);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_font_fontconfig_name_free(const char *name)
|
||||
elm_font_fontconfig_name_free(char *name)
|
||||
{
|
||||
eina_stringshare_del(name);
|
||||
}
|
||||
|
@ -1240,6 +1242,7 @@ elm_font_available_hash_add(Eina_List *list)
|
|||
font_hash = NULL;
|
||||
|
||||
/* populate with default font families */
|
||||
//FIXME: Need to check whether fonts are being added multiple times.
|
||||
font_hash = _elm_font_available_hash_add(font_hash, "Sans:style=Regular");
|
||||
font_hash = _elm_font_available_hash_add(font_hash, "Sans:style=Bold");
|
||||
font_hash = _elm_font_available_hash_add(font_hash, "Sans:style=Oblique");
|
||||
|
@ -1262,7 +1265,7 @@ elm_font_available_hash_add(Eina_List *list)
|
|||
"Monospace:style=Bold Oblique");
|
||||
|
||||
EINA_LIST_FOREACH(list, l, key)
|
||||
font_hash = _elm_font_available_hash_add(font_hash, key);
|
||||
if (key) _elm_font_available_hash_add(font_hash, key);
|
||||
|
||||
return font_hash;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue