{
if (tc_data->font)
{
- const char *name;
+ char *name;
name = elm_font_fontconfig_name_get(tc_data->font,
tc_data->style);
_font_preview_update(Evas_Object *win)
{
Evas_Font_Size sz;
- const char *name;
+ char *name;
if (!fdata.cur_font)
return;
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;
#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>
{
Elm_Text_Class *tc;
tc = malloc(sizeof(*tc));
+ if (!tc) continue;
*tc = _elm_text_classes[i];
len = s1 - font;
name = calloc(sizeof(char), len + 1);
+ if (!name) return NULL;
strncpy(name, font, len);
/* get subname (should be english) */
{
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)))
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, ',');
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,
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)
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);
}
*
* 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.
*
* @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
* 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().
*
* @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.
* 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);
/**
_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 *
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);
}
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);
}
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");
"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;
}