EAPI RGBA_Font *evas_common_font_add (RGBA_Font *fn, const char *name, int size, Font_Rend_Flags wanted_rend);
EAPI RGBA_Font *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);
EAPI void evas_common_font_free (RGBA_Font *fn);
+EAPI void evas_common_font_int_unref (RGBA_Font_Int *fi);
EAPI void evas_common_font_hinting_set (RGBA_Font *fn, Font_Hint_Flags hinting);
EAPI Eina_Bool evas_common_hinting_available (Font_Hint_Flags hinting);
EAPI RGBA_Font *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);
hb_font_destroy(fi->ft.hb_font);
#endif
evas_common_font_source_free(fi->src);
- if (fi->references == 0) fonts_lru = eina_list_remove(fonts_lru, fi);
+ if (fi->references <= 0) fonts_lru = eina_list_remove(fonts_lru, fi);
if (fi->fash) fi->fash->freeme(fi->fash);
if (fi->inuse)
{
fn = calloc(1, sizeof(RGBA_Font));
if (!fn)
{
- fi->references--;
- if (fi->references == 0)
- {
- fonts_lru = eina_list_prepend(fonts_lru, fi);
- evas_common_font_int_modify_cache_by(fi, 1);
- evas_common_font_flush();
- }
+ evas_common_font_int_unref(fi);
return NULL;
}
fn->fonts = eina_list_append(fn->fonts, fi);
{
if (evas_common_font_source_load_complete(fi->src))
{
- fi->references--;
- if (fi->references == 0)
- {
- fonts_lru = eina_list_prepend(fonts_lru, fi);
- evas_common_font_int_modify_cache_by(fi, 1);
- evas_common_font_flush();
- }
+ evas_common_font_int_unref(fi);
return NULL;
}
}
fn = calloc(1, sizeof(RGBA_Font));
if (!fn)
{
- fi->references--;
- if (fi->references == 0)
- {
- fonts_lru = eina_list_prepend(fonts_lru, fi);
- evas_common_font_int_modify_cache_by(fi, 1);
- evas_common_font_flush();
- }
+ evas_common_font_int_unref(fi);
return NULL;
}
}
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();
+ }
+}
+
+EAPI void
evas_common_font_free(RGBA_Font *fn)
{
Eina_List *l;
fn->references--;
if (fn->references > 0) return;
EINA_LIST_FOREACH(fn->fonts, l, 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_int_unref(fi);
evas_common_font_flush();
eina_list_free(fn->fonts);
if (fn->fash) fn->fash->freeme(fn->fash);
return;
}
evas_common_font_int_modify_cache_by(fi, -1);
- if (fi->fash)
- {
- for (k = 0; k <= 0xff; k++) // 24bits for unicode - v6 up to E01EF (chrs) & 10FFFD for private use (plane 16)
- {
- Fash_Glyph_Map2 *fmap2 = fi->fash->bucket[k];
- if (fmap2)
- {
- for (j = 0; j <= 0xff; j++) // 24bits for unicode - v6 up to E01EF (chrs) & 10FFFD for private use (plane 16)
- {
- Fash_Glyph_Map *fmap = fmap2->bucket[j];
- if (fmap)
+ if (fi->references <= 1)
+ {
+ if (fi->fash)
+ {
+ for (k = 0; k <= 0xff; k++) // 24bits for unicode - v6 up to E01EF (chrs) & 10FFFD for private use (plane 16)
+ {
+ Fash_Glyph_Map2 *fmap2 = fi->fash->bucket[k];
+ if (fmap2)
{
- for (i = 0; i <= 0xff; i++)
- {
- RGBA_Font_Glyph *fg = fmap->item[i];
- if ((fg) && (fg != (void *)(-1)))
- {
- FT_Done_Glyph(fg->glyph);
- /* extension calls */
- if (fg->ext_dat_free) fg->ext_dat_free(fg->ext_dat);
- if (fg->glyph_out_free) fg->glyph_out_free(fg->glyph_out);
- free(fg);
- fmap->item[i] = NULL;
- }
- }
+ for (j = 0; j <= 0xff; j++) // 24bits for unicode - v6 up to E01EF (chrs) & 10FFFD for private use (plane 16)
+ {
+ Fash_Glyph_Map *fmap = fmap2->bucket[j];
+ if (fmap)
+ {
+ for (i = 0; i <= 0xff; i++)
+ {
+ RGBA_Font_Glyph *fg = fmap->item[i];
+ if ((fg) && (fg != (void *)(-1)))
+ {
+ FT_Done_Glyph(fg->glyph);
+ /* extension calls */
+ if (fg->ext_dat_free) fg->ext_dat_free(fg->ext_dat);
+ if (fg->glyph_out_free) fg->glyph_out_free(fg->glyph_out);
+ free(fg);
+ fmap->item[i] = NULL;
+ }
+ }
+ }
+ }
}
- }
- }
- }
- fi->fash->freeme(fi->fash);
- fi->fash = NULL;
+ }
+ fi->fash->freeme(fi->fash);
+ fi->fash = NULL;
+ }
}
if (fi->inuse) fonts_use_usage -= fi->usage;
fi->usage = 0;
return;
props->info->refcount++;
+ if (props->font_instance)
+ ((RGBA_Font_Int *)props->font_instance)->references++;
}
void
if (!props->info)
return;
+ if (props->font_instance)
+ {
+ evas_common_font_int_unref(props->font_instance);
+ props->font_instance = NULL;
+ }
+
if (--(props->info->refcount) == 0)
{
if (props->bin)
}
text_props->info = calloc(1, sizeof(Evas_Text_Props_Info));
- text_props->font_instance = fi;
-
+ if (text_props->font_instance != fi)
+ {
+ if (text_props->font_instance)
+ evas_common_font_int_unref(text_props->font_instance);
+ text_props->font_instance = fi;
+ fi->references++;
+ }
+
evas_common_font_int_reload(fi);
if (fi->src->current_size != fi->size)
{