From 91c0328c5184429b33265fe3b55b60d05603c00c Mon Sep 17 00:00:00 2001 From: stanton Date: Wed, 25 Nov 1998 01:48:53 +0000 Subject: Fixed font display bug (#846) --- ChangeLog | 7 +++++++ unix/tkUnixFont.c | 31 ++++++++++++++++++++++++++++++- win/makefile.bc | 4 ++-- 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 ChangeLog diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..7d4500d --- /dev/null +++ b/ChangeLog @@ -0,0 +1,7 @@ +1998-11-24 + + * unix/tkUnixFont.c (TkpGetNativeFont): On some X servers, + XQueryLoadFont will always return a font, even if the name is + meaningless. This prevents Tk from parsing the font name, so now + we perform a quick sanity check on the name before letting X have + it. [Bug: 846] diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c index ff2a705..1428b79 100644 --- a/unix/tkUnixFont.c +++ b/unix/tkUnixFont.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUnixFont.c,v 1.3 1998/09/14 18:23:57 stanton Exp $ + * RCS: @(#) $Id: tkUnixFont.c,v 1.4 1998/11/25 01:48:54 stanton Exp $ */ #include "tkPort.h" @@ -127,6 +127,35 @@ TkpGetNativeFont(tkwin, name) CONST char *name; /* Platform-specific font name. */ { XFontStruct *fontStructPtr; + char *p; + int hasSpace, dashes, hasWild; + + /* + * The behavior of X when given a name that isn't an XLFD is unspecified. + * For example, Exceed 6 returns a valid font for any random string. This + * is awkward since system names have higher priority than the other Tk + * font syntaxes. So, we need to perform a quick sanity check on the + * name and fail if it looks suspicious. We fail if the name: + * - contains a space immediately before a dash + * - contains a space, but no '*' characters and fewer than 14 dashes + */ + + hasSpace = dashes = hasWild = 0; + for (p = name; *p != '\0'; p++) { + if (*p == ' ') { + if (p[1] == '-') { + return NULL; + } + hasSpace = 1; + } else if (*p == '-') { + dashes++; + } else if (*p == '*') { + hasWild = 1; + } + } + if ((dashes < 14) && !hasWild && hasSpace) { + return NULL; + } fontStructPtr = XLoadQueryFont(Tk_Display(tkwin), name); if (fontStructPtr == NULL) { diff --git a/win/makefile.bc b/win/makefile.bc index 4ecdd05..525748e 100644 --- a/win/makefile.bc +++ b/win/makefile.bc @@ -5,7 +5,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: makefile.bc,v 1.6 1998/09/14 18:23:58 stanton Exp $ +# RCS: @(#) $Id: makefile.bc,v 1.7 1998/11/25 01:48:54 stanton Exp $ # @@ -19,7 +19,7 @@ ROOT = .. TMPDIR = . TOOLS = c:\bc45 -TCLDIR = ..\..\tcl8.0.3 +TCLDIR = ..\..\tcl8.0.4 # uncomment the following line to compile with symbols #DEBUG=1 -- cgit v0.12