summaryrefslogtreecommitdiffstats
path: root/win/tkWinFont.c
diff options
context:
space:
mode:
authorpatthoyts <patthoyts@users.sourceforge.net>2007-12-10 12:10:09 (GMT)
committerpatthoyts <patthoyts@users.sourceforge.net>2007-12-10 12:10:09 (GMT)
commit7286a3c852accb1dab02058ed762a80d970ec7d7 (patch)
tree71460b05c6e05a94a7d8fcfcde08dee0d8ff0576 /win/tkWinFont.c
parent07d529beffc9cd3f7e50d532f77dd47ca2bd6234 (diff)
downloadtk-7286a3c852accb1dab02058ed762a80d970ec7d7.zip
tk-7286a3c852accb1dab02058ed762a80d970ec7d7.tar.gz
tk-7286a3c852accb1dab02058ed762a80d970ec7d7.tar.bz2
We must specify the lowest Windows version we
intend to support. In particular the SystemParametersInfo API doesn't like to receive structures that are larger than it expects which affects the font assignements. Set to Win98 support. Handle failure to read the system parameters. This causes ttk/fonts.tcl to set any missing named fonts.
Diffstat (limited to 'win/tkWinFont.c')
-rw-r--r--win/tkWinFont.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/win/tkWinFont.c b/win/tkWinFont.c
index aae69a8..383cdf3 100644
--- a/win/tkWinFont.c
+++ b/win/tkWinFont.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinFont.c,v 1.36 2007/11/17 21:55:09 patthoyts Exp $
+ * RCS: @(#) $Id: tkWinFont.c,v 1.37 2007/12/10 12:10:10 patthoyts Exp $
*/
#include "tkWinInt.h"
@@ -336,7 +336,7 @@ CreateNamedSystemLogFont(
Tcl_Interp *interp,
Tk_Window tkwin,
CONST char* name,
- LOGFONT* logFontPtr)
+ LOGFONTA* logFontPtr)
{
HFONT hFont;
int r;
@@ -406,30 +406,39 @@ TkWinSetupSystemFonts(TkMainInfo *mainPtr)
((TkWindow *) tkwin)->mainPtr = mainPtr;
}
- ncMetrics.cbSize = sizeof(ncMetrics);
- SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncMetrics),
- &ncMetrics, 0);
+ /*
+ * If this API call fails then we will fallback to setting these
+ * named fonts from script in ttk/fonts.tcl. So far I've only
+ * seen it fail when WINVER has been defined for a higher platform than
+ * we are running on. (ie: WINVER=0x0600 and running on XP).
+ */
- CreateNamedSystemLogFont(interp, tkwin, "TkDefaultFont",
+ ZeroMemory(&ncMetrics, sizeof(ncMetrics));
+ ncMetrics.cbSize = sizeof(ncMetrics);
+ if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
+ sizeof(ncMetrics), &ncMetrics, 0)) {
+ CreateNamedSystemLogFont(interp, tkwin, "TkDefaultFont",
&ncMetrics.lfMessageFont);
- CreateNamedSystemLogFont(interp, tkwin, "TkHeadingFont",
+ CreateNamedSystemLogFont(interp, tkwin, "TkHeadingFont",
&ncMetrics.lfMessageFont);
- CreateNamedSystemLogFont(interp, tkwin, "TkTextFont",
+ CreateNamedSystemLogFont(interp, tkwin, "TkTextFont",
&ncMetrics.lfMessageFont);
- CreateNamedSystemLogFont(interp, tkwin, "TkMenuFont",
+ CreateNamedSystemLogFont(interp, tkwin, "TkMenuFont",
&ncMetrics.lfMenuFont);
- CreateNamedSystemLogFont(interp, tkwin, "TkTooltipFont",
+ CreateNamedSystemLogFont(interp, tkwin, "TkTooltipFont",
&ncMetrics.lfStatusFont);
- CreateNamedSystemLogFont(interp, tkwin, "TkCaptionFont",
+ CreateNamedSystemLogFont(interp, tkwin, "TkCaptionFont",
&ncMetrics.lfCaptionFont);
- CreateNamedSystemLogFont(interp, tkwin, "TkSmallCaptionFont",
+ CreateNamedSystemLogFont(interp, tkwin, "TkSmallCaptionFont",
&ncMetrics.lfSmCaptionFont);
+ }
iconMetrics.cbSize = sizeof(iconMetrics);
- SystemParametersInfo(SPI_GETICONMETRICS, sizeof(iconMetrics),
- &iconMetrics, 0);
- CreateNamedSystemLogFont(interp, tkwin, "TkIconFont",
+ if (SystemParametersInfo(SPI_GETICONMETRICS, sizeof(iconMetrics),
+ &iconMetrics, 0)) {
+ CreateNamedSystemLogFont(interp, tkwin, "TkIconFont",
&iconMetrics.lfFont);
+ }
hFont = (HFONT)GetStockObject(ANSI_FIXED_FONT);
CreateNamedSystemFont(interp, tkwin, "TkFixedFont", hFont);