From 6358ff45ae8cfc0b58b4976619319e3dde43add2 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 5 Nov 2009 17:39:16 -0500 Subject: [PATCH] Add hb_ft_face_create_cached --- src/hb-ft.c | 16 ++++++++++++++++ src/hb-ft.h | 3 +++ 2 files changed, 19 insertions(+) diff --git a/src/hb-ft.c b/src/hb-ft.c index 146fd3c..8a062c7 100644 --- a/src/hb-ft.c +++ b/src/hb-ft.c @@ -178,6 +178,22 @@ hb_ft_face_create (FT_Face ft_face, return face; } +hb_face_t * +hb_ft_face_create_cached (FT_Face ft_face) +{ + /* TODO: Not thread-safe */ + if (HB_LIKELY (ft_face->generic.data && ft_face->generic.finalizer == (FT_Generic_Finalizer) hb_face_destroy)) + return ft_face->generic.data; + + if (ft_face->generic.finalizer) + ft_face->generic.finalizer (ft_face->generic.data); + + ft_face->generic.data = hb_ft_face_create (ft_face, NULL); + ft_face->generic.finalizer = (FT_Generic_Finalizer) hb_face_destroy; + + return ft_face->generic.data; +} + hb_font_t * hb_ft_font_create (FT_Face ft_face, diff --git a/src/hb-ft.h b/src/hb-ft.h index e6a4f86..b73a02c 100644 --- a/src/hb-ft.h +++ b/src/hb-ft.h @@ -43,6 +43,9 @@ hb_face_t * hb_ft_face_create (FT_Face ft_face, hb_destroy_func_t destroy); +hb_face_t * +hb_ft_face_create_cached (FT_Face ft_face); + hb_font_t * hb_ft_font_create (FT_Face ft_face, hb_destroy_func_t destroy); -- 2.7.4