From a7214683bede0bb05ee23d63331d289c37d3b667 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 13 Dec 2018 11:58:09 -0800 Subject: [PATCH] Simplify mainline Harfbuzz-using code * src/ftfont.c (ft_face_destroy): Omit unnecessary cast. (hb_ft_font_create_referenced) [!HAVE_HB_FT_FONT_CREATE_REFERENCED]: New function. (ftfont_get_hb_font): Use it. --- src/ftfont.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/ftfont.c b/src/ftfont.c index a645bbf0294..47442df0e5a 100644 --- a/src/ftfont.c +++ b/src/ftfont.c @@ -478,28 +478,27 @@ ftfont_get_otf (struct ftfont_info *ftfont_info) #ifdef HAVE_HARFBUZZ -#ifndef HAVE_HB_FT_FONT_CREATE_REFERENCED +# ifndef HAVE_HB_FT_FONT_CREATE_REFERENCED static void ft_face_destroy (void *data) { - FT_Done_Face ((FT_Face) data); + FT_Done_Face (data); } -#endif + +static hb_font_t * +hb_ft_font_create_referenced (FT_Face face) +{ + FT_Reference_Face (face); + return hb_ft_font_create (face, ft_face_destroy); +} +# endif static hb_font_t * ftfont_get_hb_font (struct ftfont_info *ftfont_info) { if (! ftfont_info->hb_font) - { - hb_font_t *hb_font; -#ifdef HAVE_HB_FT_FONT_CREATE_REFERENCED - hb_font = hb_ft_font_create_referenced (ftfont_info->ft_size->face); -#else - FT_Reference_Face (ftfont_info->ft_size->face); - hb_font = hb_ft_font_create (ftfont_info->ft_size->face, ft_face_destroy); -#endif - ftfont_info->hb_font = hb_font; - } + ftfont_info->hb_font + = hb_ft_font_create_referenced (ftfont_info->ft_size->face); return ftfont_info->hb_font; } -- 2.39.2