diff options
author | jenglish <jenglish@flightlab.com> | 2008-03-12 16:35:26 (GMT) |
---|---|---|
committer | jenglish <jenglish@flightlab.com> | 2008-03-12 16:35:26 (GMT) |
commit | 51fd3d6cd0010209fd4d6b2180c08c075fc2a8d7 (patch) | |
tree | 6afe51d0b3e5c831360d04746bc11720b9741960 | |
parent | 8363dbeaf5ab0a17acd7be7e499d009245452fae (diff) | |
download | tk-51fd3d6cd0010209fd4d6b2180c08c075fc2a8d7.zip tk-51fd3d6cd0010209fd4d6b2180c08c075fc2a8d7.tar.gz tk-51fd3d6cd0010209fd4d6b2180c08c075fc2a8d7.tar.bz2 |
Try a fallback font if XftFontOpenPattern() fails in GetFont
(workaround for [Bug 1090382]).
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | unix/tkUnixRFont.c | 29 |
2 files changed, 30 insertions, 4 deletions
@@ -1,3 +1,8 @@ +2008-03-12 Joe English <jenglish@users.sourceforge.net> + + * unix/tkUnixRFont.c: Try a fallback font if XftFontOpenPattern() + fails in GetFont (workaround for [Bug 1090382]). + 2008-03-11 Daniel Steffen <das@users.sourceforge.net> * 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; } |