diff options
author | stanton <stanton> | 1998-11-25 01:48:53 (GMT) |
---|---|---|
committer | stanton <stanton> | 1998-11-25 01:48:53 (GMT) |
commit | 91c0328c5184429b33265fe3b55b60d05603c00c (patch) | |
tree | 22957db4a307b0356a2668de35e1dbbbf0bbfef4 | |
parent | d6d454eb95123bbc72b2b817b3e5738c255b7ddd (diff) | |
download | tk-91c0328c5184429b33265fe3b55b60d05603c00c.zip tk-91c0328c5184429b33265fe3b55b60d05603c00c.tar.gz tk-91c0328c5184429b33265fe3b55b60d05603c00c.tar.bz2 |
Fixed font display bug (#846)
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | unix/tkUnixFont.c | 31 | ||||
-rw-r--r-- | win/makefile.bc | 4 |
3 files changed, 39 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..7d4500d --- /dev/null +++ b/ChangeLog @@ -0,0 +1,7 @@ +1998-11-24 <stanton@GASPODE> + + * 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 |