summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorjenglish@flightlab.com <jenglish>2008-03-12 16:35:26 (GMT)
committerjenglish@flightlab.com <jenglish>2008-03-12 16:35:26 (GMT)
commit3f22c6e816f8032958d3a58b79cf88869bfe0ced (patch)
tree6afe51d0b3e5c831360d04746bc11720b9741960 /unix
parent3b76db2d88e3ef84a25ea526e8c9c20f4f4bd7af (diff)
downloadtk-3f22c6e816f8032958d3a58b79cf88869bfe0ced.zip
tk-3f22c6e816f8032958d3a58b79cf88869bfe0ced.tar.gz
tk-3f22c6e816f8032958d3a58b79cf88869bfe0ced.tar.bz2
Try a fallback font if XftFontOpenPattern() fails in GetFont
(workaround for [Bug 1090382]).
Diffstat (limited to 'unix')
-rw-r--r--unix/tkUnixRFont.c29
1 files changed, 25 insertions, 4 deletions
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;
}