From 67f3c4cc828806d1668abc8b3ae3d883c23a63ab Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Thu, 29 May 2014 13:28:55 +0000 Subject: Avoid crash when XftFontOpenPattern() returns NULL. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10175 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/fl_font_xft.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/fl_font_xft.cxx b/src/fl_font_xft.cxx index c69d39f0f..7e629aa87 100644 --- a/src/fl_font_xft.cxx +++ b/src/fl_font_xft.cxx @@ -270,7 +270,10 @@ static XftFont* fontopen(const char* name, Fl_Fontsize size, bool core, int angl free(picked_name); #endif - if (!match_pat) { + // open the matched font + if (match_pat) the_font = XftFontOpenPattern(fl_display, match_pat); + + if (!match_pat || !the_font) { // last chance, just open any font in the right size the_font = XftFontOpen (fl_display, fl_screen, XFT_FAMILY, XftTypeString, "sans", @@ -284,9 +287,6 @@ static XftFont* fontopen(const char* name, Fl_Fontsize size, bool core, int angl return the_font; } - // open the matched font - the_font = XftFontOpenPattern(fl_display, match_pat); - #if 0 // diagnostic to print the "full name" of the font we actually opened. This works. FcChar8 *picked_name2 = FcNameUnparse(the_font->pattern); printf("Open : %s\n", picked_name2); -- cgit v1.2.3