summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
Diffstat (limited to 'win')
-rw-r--r--win/tkWinFont.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/win/tkWinFont.c b/win/tkWinFont.c
index 1c35fc7..84867ad 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.9 2000/03/31 09:24:27 hobbs Exp $
+ * RCS: @(#) $Id: tkWinFont.c,v 1.10 2000/04/07 20:57:10 hobbs Exp $
*/
#include "tkWinInt.h"
@@ -1947,15 +1947,15 @@ GetScreenFont(
Tcl_UtfToExternalDString(systemEncoding, faceName, -1, &ds);
- /*
- * We can only store up to LF_FACESIZE characters
- */
- if (Tcl_DStringLength(&ds) >= LF_FACESIZE) {
- Tcl_DStringSetLength(&ds, LF_FACESIZE);
- }
-
if (TkWinGetPlatformId() == VER_PLATFORM_WIN32_NT) {
Tcl_UniChar *src, *dst;
+
+ /*
+ * We can only store up to LF_FACESIZE wide characters
+ */
+ if (Tcl_DStringLength(&ds) >= (LF_FACESIZE * sizeof(WCHAR))) {
+ Tcl_DStringSetLength(&ds, LF_FACESIZE);
+ }
src = (Tcl_UniChar *) Tcl_DStringValue(&ds);
dst = (Tcl_UniChar *) lf.lfFaceName;
while (*src != '\0') {
@@ -1964,6 +1964,12 @@ GetScreenFont(
*dst = '\0';
hFont = CreateFontIndirectW(&lf);
} else {
+ /*
+ * We can only store up to LF_FACESIZE characters
+ */
+ if (Tcl_DStringLength(&ds) >= LF_FACESIZE) {
+ Tcl_DStringSetLength(&ds, LF_FACESIZE);
+ }
strcpy((char *) lf.lfFaceName, Tcl_DStringValue(&ds));
hFont = CreateFontIndirectA((LOGFONTA *) &lf);
}