From 067b81750004a883209ae9936b1e9c4b31ab3b1a Mon Sep 17 00:00:00 2001 From: adrian Date: Wed, 16 Dec 2009 11:11:31 +0000 Subject: Fix a crash when fontconfig is unable to select a font. e.g. if no config directory could be found. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30044 b3059339-0415-0410-9bf9-f77b7e298cf2 --- help/help_mp-en.h | 1 + libvo/font_load_ft.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/help/help_mp-en.h b/help/help_mp-en.h index 52d0484c93..5d9413fa33 100644 --- a/help/help_mp-en.h +++ b/help/help_mp-en.h @@ -856,6 +856,7 @@ static const char help_text[]= #define MSGTR_LIBVO_FONT_LOAD_FT_CannotPrepareOSDFont "Cannot prepare OSD font.\n" #define MSGTR_LIBVO_FONT_LOAD_FT_CannotGenerateTables "Cannot generate tables.\n" #define MSGTR_LIBVO_FONT_LOAD_FT_DoneFreeTypeFailed "FT_Done_FreeType failed.\n" +#define MSGTR_LIBVO_FONT_LOAD_FT_FontconfigNoMatch "Fontconfig failed to select a font. Trying without fontconfig...\n" // sub.c #define MSGTR_VO_SUB_Seekbar "Seekbar" diff --git a/libvo/font_load_ft.c b/libvo/font_load_ft.c index fe3845f7a9..5a5a09d108 100644 --- a/libvo/font_load_ft.c +++ b/libvo/font_load_ft.c @@ -1144,6 +1144,7 @@ void load_font_ft(int width, int height, font_desc_t** fontp, const char *font_n FcChar8 *s; int face_index; FcBool scalable; + FcResult result; #endif font_desc_t *vo_font = *fontp; vo_image_width = width; @@ -1162,7 +1163,8 @@ void load_font_ft(int width, int height, font_desc_t** fontp, const char *font_n FcConfigSubstitute(0, fc_pattern, FcMatchPattern); FcDefaultSubstitute(fc_pattern); fc_pattern2 = fc_pattern; - fc_pattern = FcFontMatch(0, fc_pattern, 0); + fc_pattern = FcFontMatch(0, fc_pattern, &result); + if (result == FcResultMatch) { FcPatternDestroy(fc_pattern2); FcPatternGetBool(fc_pattern, FC_SCALABLE, 0, &scalable); if (scalable != FcTrue) { @@ -1179,8 +1181,11 @@ void load_font_ft(int width, int height, font_desc_t** fontp, const char *font_n FcPatternGetInteger(fc_pattern, FC_INDEX, 0, &face_index); *fontp=read_font_desc_ft(s, face_index, width, height, font_scale_factor); FcPatternDestroy(fc_pattern); + return; + } + // Failed to match any font, try without fontconfig + mp_msg(MSGT_OSD, MSGL_ERR, MSGTR_LIBVO_FONT_LOAD_FT_FontconfigNoMatch); } - else #endif *fontp=read_font_desc_ft(font_name, 0, width, height, font_scale_factor); } -- cgit v1.2.3