Evas font: Cache Harfbuzz font structure for fonts we use.
authortasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 17 Oct 2011 14:24:49 +0000 (14:24 +0000)
committertasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 17 Oct 2011 14:24:49 +0000 (14:24 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@64136 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/engines/common/evas_font_load.c
src/lib/engines/common/evas_font_ot.c
src/lib/include/evas_common.h

index ceaf0c7..c39becd 100644 (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);
index 3bd0c59..cb1eada 100644 (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;
-
-   hb_ft_font = hb_ft_font_create(fi->src->ft.face, NULL);
-   hb_font = hb_font_create_sub_font(hb_ft_font);
+   /* Create hb_font if not previously created */
+   if (!fi->src->ft.hb_font)
+     {
+        hb_font_t *hb_ft_font;
 
-   hb_font_set_funcs(hb_font, _evas_common_font_ot_font_funcs_get(), fi, NULL);
+        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_shape(hb_font, buffer, NULL, 0);
+        hb_font_set_funcs(fi->src->ft.hb_font,
+              _evas_common_font_ot_font_funcs_get(), fi, NULL);
+     }
 
-   hb_font_destroy(hb_font);
-   hb_font_destroy(hb_ft_font);
+   hb_shape(fi->src->ft.hb_font, buffer, NULL, 0);
 }
 
 EAPI Eina_Bool
index 6d68240..d518fcc 100644 (file)
@@ -942,6 +942,9 @@ struct _RGBA_Font_Source
    struct {
       int            orig_upem;
       FT_Face        face;
+#ifdef USE_HARFBUZZ
+      void *hb_font;
+#endif
    } ft;
 };