From 2b526db0e8a85d9f42cb05660fd4399963220858 Mon Sep 17 00:00:00 2001 From: Salah-Eddin Shaban Date: Tue, 12 May 2015 09:16:00 +0300 Subject: [PATCH] freetype: avoid redundant calls to FT_Set_Pixel_Sizes() Signed-off-by: Jean-Baptiste Kempf --- modules/text_renderer/freetype.c | 11 +++++++++++ modules/text_renderer/text_layout.c | 24 +++++++++--------------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/modules/text_renderer/freetype.c b/modules/text_renderer/freetype.c index ab04f0ccdb..af5572fae6 100644 --- a/modules/text_renderer/freetype.c +++ b/modules/text_renderer/freetype.c @@ -1442,6 +1442,17 @@ FT_Face LoadFace( filter_t *p_filter, return NULL; } + int i_font_width = p_style->i_style_flags & STYLE_HALFWIDTH + ? p_style->i_font_size / 2 : p_style->i_font_size; + + if( FT_Set_Pixel_Sizes( p_face, i_font_width, p_style->i_font_size ) ) + { + msg_Err( p_filter, + "Failed to set font size to %d", p_style->i_font_size ); + FT_Done_Face( p_face ); + return NULL; + } + if( p_cache->i_faces_count == p_cache->i_cache_size ) { FT_Face *p_new_faces = diff --git a/modules/text_renderer/text_layout.c b/modules/text_renderer/text_layout.c index c55ae80e40..71b3a816f8 100644 --- a/modules/text_renderer/text_layout.c +++ b/modules/text_renderer/text_layout.c @@ -517,19 +517,16 @@ static int ShapeParagraphHarfBuzz( filter_t *p_filter, { p_face = LoadFace( p_filter, p_style ); if( !p_face ) + { p_face = p_sys->p_face; + p_style = &p_sys->style; + p_run->p_style = p_style; + } p_run->p_face = p_face; } else p_face = p_run->p_face; - int i_font_width = p_style->i_style_flags & STYLE_HALFWIDTH - ? p_style->i_font_size / 2 : p_style->i_font_size; - - if( FT_Set_Pixel_Sizes( p_face, i_font_width, p_style->i_font_size ) ) - msg_Err( p_filter, - "Failed to set font size to %d", p_style->i_font_size ); - p_run->p_hb_font = hb_ft_font_create( p_face, 0 ); if( !p_run->p_hb_font ) { @@ -773,24 +770,21 @@ static int LoadGlyphs( filter_t *p_filter, paragraph_t *p_paragraph, run_desc_t *p_run = p_paragraph->p_runs + i; text_style_t *p_style = p_run->p_style; - FT_Face p_face; + FT_Face p_face = 0; if( !p_run->p_face ) { p_face = LoadFace( p_filter, p_style ); if( !p_face ) + { p_face = p_sys->p_face; + p_style = &p_sys->style; + p_run->p_style = p_style; + } p_run->p_face = p_face; } else p_face = p_run->p_face; - int i_font_width = p_style->i_style_flags & STYLE_HALFWIDTH ? - p_style->i_font_size / 2 : p_style->i_font_size; - - if( FT_Set_Pixel_Sizes( p_face, i_font_width, p_style->i_font_size ) ) - msg_Err( p_filter, - "Failed to set font size to %d", p_style->i_font_size ); - if( p_sys->p_stroker ) { double f_outline_thickness = -- 2.11.4.GIT