diff options
author | dkf <dkf@noemail.net> | 2009-09-10 12:47:13 (GMT) |
---|---|---|
committer | dkf <dkf@noemail.net> | 2009-09-10 12:47:13 (GMT) |
commit | 5bc016eeffbea3eff6fe2948ef21da5df8a5e6e3 (patch) | |
tree | 49ed37276011f737c431c8504927a71bf597ff3e | |
parent | 5a1b7d884835dd306658d0dcb60211ef21ac9149 (diff) | |
download | tk-5bc016eeffbea3eff6fe2948ef21da5df8a5e6e3.zip tk-5bc016eeffbea3eff6fe2948ef21da5df8a5e6e3.tar.gz tk-5bc016eeffbea3eff6fe2948ef21da5df8a5e6e3.tar.bz2 |
Backport of "misconfigured xft font engine" fixes.
FossilOrigin-Name: e4f4e763817eafb1e3380954d12a864c5615ed77
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | generic/tkFont.c | 15 | ||||
-rw-r--r-- | unix/tkUnixRFont.c | 17 |
3 files changed, 42 insertions, 3 deletions
@@ -1,3 +1,16 @@ +2009-09-10 Donal K. Fellows <dkf@users.sf.net> + + * unix/tkUnixRFont.c (InitFont): Move pattern disposal in error case + to callers so they have more options when they come to recovering from + the failure. + (TkpGetFontFromAttributes): If the default attributes don't work, try + adding a setting to turn off use of XRender. That seems to work for + some people for unexplained reasons (possibly local misconfiguration). + * generic/tkFont.c (Tk_AllocFontFromObj): Stop this function from + keeling over in a heap when the low-level font allocation fails. An + error beats a crash! (Issue reported on comp.lang.tcl by Denis + Berezhnoy.) + 2009-08-25 Donal K. Fellows <dkf@users.sf.net> * unix/tkUnixSend.c (ServerSecure): [Bug 1909931]: Added some support diff --git a/generic/tkFont.c b/generic/tkFont.c index 3839ef0..4852f14 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkFont.c,v 1.42.2.2 2009/05/13 21:49:12 patthoyts Exp $ + * RCS: @(#) $Id: tkFont.c,v 1.42.2.3 2009/09/10 12:47:15 dkf Exp $ */ #include "tkInt.h" @@ -1194,6 +1194,19 @@ Tk_AllocFontFromObj( } } + /* + * Detect the system font engine going wrong and fail more gracefully. + */ + + if (fontPtr == NULL) { + if (isNew) { + Tcl_DeleteHashEntry(cacheHashPtr); + } + Tcl_AppendResult(interp, "failed to allocate font due to ", + "internal system font engine problem", NULL); + return NULL; + } + fontPtr->resourceRefCount = 1; fontPtr->objRefCount = 1; fontPtr->cacheHashPtr = cacheHashPtr; diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c index 73e091c..b3d5ce4 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.24 2008/03/12 16:35:27 jenglish Exp $ + * RCS: @(#) $Id: tkUnixRFont.c,v 1.24.2.1 2009/09/10 12:47:15 dkf Exp $ */ #include "tkUnixInt.h" @@ -220,7 +220,6 @@ InitFont( set = FcFontSort(0, pattern, FcTrue, NULL, &result); if (!set) { - FcPatternDestroy(pattern); ckfree((char *)fontPtr); return NULL; } @@ -323,6 +322,7 @@ TkpGetNativeFont( fontPtr = InitFont(tkwin, pattern, NULL); if (!fontPtr) { + FcPatternDestroy(pattern); return NULL; } return &fontPtr->font; @@ -388,7 +388,20 @@ TkpGetFontFromAttributes( FinishedWithFont(fontPtr); } fontPtr = InitFont(tkwin, pattern, fontPtr); + + /* + * Hack to work around issues with weird issues with Xft/Xrender + * connection. For details, see comp.lang.tcl thread starting from + * <adcc99ed-c73e-4efc-bb5d-e57a57a051e8@l35g2000pra.googlegroups.com> + */ + if (!fontPtr) { + XftPatternAddBool(pattern, XFT_RENDER, FcFalse); + fontPtr = InitFont(tkwin, pattern, fontPtr); + } + + if (!fontPtr) { + FcPatternDestroy(pattern); return NULL; } return &fontPtr->font; |