From 4906d50afca6b51292e2a72d4a2a175264ad0616 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Mon, 17 Oct 2011 14:24:49 +0000 Subject: [PATCH] Evas font: Cache Harfbuzz font structure for fonts we use. SVN revision: 64136 --- .../src/lib/engines/common/evas_font_load.c | 8 ++++++++ .../src/lib/engines/common/evas_font_ot.c | 19 +++++++++++-------- legacy/evas/src/lib/include/evas_common.h | 3 +++ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/legacy/evas/src/lib/engines/common/evas_font_load.c b/legacy/evas/src/lib/engines/common/evas_font_load.c index ceaf0c7d7c..c39becd035 100644 --- a/legacy/evas/src/lib/engines/common/evas_font_load.c +++ b/legacy/evas/src/lib/engines/common/evas_font_load.c @@ -6,6 +6,11 @@ #include "evas_font_private.h" /* for Frame-Queuing support */ #include "evas_font_ot.h" +#ifdef USE_HARFBUZZ +# include +# include +#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); diff --git a/legacy/evas/src/lib/engines/common/evas_font_ot.c b/legacy/evas/src/lib/engines/common/evas_font_ot.c index 3bd0c59fe0..cb1eada82e 100644 --- a/legacy/evas/src/lib/engines/common/evas_font_ot.c +++ b/legacy/evas/src/lib/engines/common/evas_font_ot.c @@ -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 diff --git a/legacy/evas/src/lib/include/evas_common.h b/legacy/evas/src/lib/include/evas_common.h index 6d6824089e..d518fccc0a 100644 --- a/legacy/evas/src/lib/include/evas_common.h +++ b/legacy/evas/src/lib/include/evas_common.h @@ -942,6 +942,9 @@ struct _RGBA_Font_Source struct { int orig_upem; FT_Face face; +#ifdef USE_HARFBUZZ + void *hb_font; +#endif } ft; };