From 51fd3d6cd0010209fd4d6b2180c08c075fc2a8d7 Mon Sep 17 00:00:00 2001 From: jenglish Date: Wed, 12 Mar 2008 16:35:26 +0000 Subject: Try a fallback font if XftFontOpenPattern() fails in GetFont (workaround for [Bug 1090382]). --- ChangeLog | 5 +++++ unix/tkUnixRFont.c | 29 +++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index a2ae1ed..8b2ea45 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-03-12 Joe English + + * unix/tkUnixRFont.c: Try a fallback font if XftFontOpenPattern() + fails in GetFont (workaround for [Bug 1090382]). + 2008-03-11 Daniel Steffen * library/demos/knightstour.tcl: Aqua GOOBE. diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c index 2487b30..73e091c 100644 --- a/unix/tkUnixRFont.c +++ b/unix/tkUnixRFont.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUnixRFont.c,v 1.23 2008/01/28 15:56:40 jenglish Exp $ + * RCS: @(#) $Id: tkUnixRFont.c,v 1.24 2008/03/12 16:35:27 jenglish Exp $ */ #include "tkUnixInt.h" @@ -80,10 +80,31 @@ GetFont( i = 0; } if (!fontPtr->faces[i].ftFont) { - FcPattern *pat = FcFontRenderPrepare(0, fontPtr->pattern, - fontPtr->faces[i].source); + FcPattern *pat = FcFontRenderPrepare(0, + fontPtr->pattern, fontPtr->faces[i].source); + XftFont *ftFont = XftFontOpenPattern(fontPtr->display, pat); + + if (!ftFont) { + /* + * The previous call to XftFontOpenPattern() should not fail, + * but sometimes does anyway. Usual cause appears to be + * a misconfigured fontconfig installation; see [Bug 1090382]. + * Try a fallback: + */ + ftFont = XftFontOpen(fontPtr->display, fontPtr->screen, + FC_FAMILY, FcTypeString, "sans", + FC_SIZE, FcTypeDouble, 12.0, + NULL); + } + if (!ftFont) { + /* + * The previous call should definitely not fail. + * Impossible to proceed at this point. + */ + Tcl_Panic("Cannot find a usable font."); + } - fontPtr->faces[i].ftFont = XftFontOpenPattern(fontPtr->display, pat); + fontPtr->faces[i].ftFont = ftFont; } return fontPtr->faces[i].ftFont; } -- cgit v0.12