Evas font: Cache Harfbuzz font structure for fonts we use.

SVN revision: 64136
This commit is contained in:
Tom Hacohen 2011-10-17 14:24:49 +00:00
parent 387bff89fb
commit 4906d50afc
3 changed files with 22 additions and 8 deletions

View File

@ -6,6 +6,11 @@
#include "evas_font_private.h" /* for Frame-Queuing support */
#include "evas_font_ot.h"
#ifdef USE_HARFBUZZ
# include <hb.h>
# include <hb-ft.h>
#endif
extern FT_Library evas_ft_lib;
static int font_cache_usage = 0;
@ -51,6 +56,9 @@ _evas_common_font_source_free(RGBA_Font_Source *fs)
{
FTLOCK();
FT_Done_Face(fs->ft.face);
#ifdef USE_HARFBUZZ
hb_font_destroy(fs->ft.hb_font);
#endif
FTUNLOCK();
if (fs->name) eina_stringshare_del(fs->name);
if (fs->file) eina_stringshare_del(fs->file);

View File

@ -245,17 +245,20 @@ _evas_common_font_ot_unicode_funcs_get(void)
static void
_evas_common_font_ot_shape(hb_buffer_t *buffer, RGBA_Font_Int *fi)
{
hb_font_t *hb_font, *hb_ft_font;
/* Create hb_font if not previously created */
if (!fi->src->ft.hb_font)
{
hb_font_t *hb_ft_font;
hb_ft_font = hb_ft_font_create(fi->src->ft.face, NULL);
hb_font = hb_font_create_sub_font(hb_ft_font);
hb_ft_font = hb_ft_font_create(fi->src->ft.face, NULL);
fi->src->ft.hb_font = hb_font_create_sub_font(hb_ft_font);
hb_font_destroy(hb_ft_font);
hb_font_set_funcs(hb_font, _evas_common_font_ot_font_funcs_get(), fi, NULL);
hb_font_set_funcs(fi->src->ft.hb_font,
_evas_common_font_ot_font_funcs_get(), fi, NULL);
}
hb_shape(hb_font, buffer, NULL, 0);
hb_font_destroy(hb_font);
hb_font_destroy(hb_ft_font);
hb_shape(fi->src->ft.hb_font, buffer, NULL, 0);
}
EAPI Eina_Bool

View File

@ -942,6 +942,9 @@ struct _RGBA_Font_Source
struct {
int orig_upem;
FT_Face face;
#ifdef USE_HARFBUZZ
void *hb_font;
#endif
} ft;
};