optimized usage of harfbuzz
authorChunEon Park <chuneon.park@samsung.com>
Thu, 20 Oct 2011 05:25:20 +0000 (14:25 +0900)
committerChunEon Park <chuneon.park@samsung.com>
Thu, 20 Oct 2011 05:25:20 +0000 (14:25 +0900)
configure.ac
src/lib/engines/common/evas_font_load.c
src/lib/engines/common/evas_font_ot.c
src/lib/include/evas_common.h

index 04df91b..8a9b58b 100644 (file)
@@ -89,7 +89,7 @@ AC_DEFINE_UNQUOTED(MODULE_ARCH, "$MODULE_ARCH", "Module architecture")
 
 want_fontconfig="auto"
 want_fribidi="auto"
-want_harfbuzz="no"
+want_harfbuzz="auto"
 want_pixman="no"
 want_evas_cserve="yes"
 
index ceaf0c7..98b47f9 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;
@@ -69,6 +74,9 @@ _evas_common_font_int_free(RGBA_Font_Int *fi)
 #ifdef HAVE_PTHREAD
    pthread_mutex_destroy(&fi->ft_mutex);
 #endif
+#ifdef USE_HARFBUZZ
+   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->fash) fi->fash->freeme(fi->fash);
index c3ba53f..a907831 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->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->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->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->ft.hb_font, buffer, NULL, 0);
 }
 
 EAPI Eina_Bool
index e00398c..95c7cc8 100644 (file)
@@ -898,6 +898,8 @@ struct _RGBA_Font
    unsigned char    sizeok : 1;
 };
 
+#include "../engines/common/evas_font_ot.h"
+
 struct _RGBA_Font_Int
 {
    EINA_INLIST;
@@ -911,6 +913,9 @@ struct _RGBA_Font_Int
    int               usage;
    struct {
       FT_Size       size;
+#ifdef USE_HARFBUZZ
+      void         *hb_font;
+#endif
    } ft;
    LK(ft_mutex);
    Font_Hint_Flags  hinting;
@@ -921,8 +926,6 @@ struct _RGBA_Font_Int
    unsigned char    inuse : 1;
 };
 
-#include "../engines/common/evas_font_ot.h"
-
 struct _RGBA_Font_Source
 {
    const char       *name;