From eb7f9e1b5da5a265d7c9ae88e3c028089c1c6f3a Mon Sep 17 00:00:00 2001 From: hobbs Date: Fri, 7 Apr 2000 20:57:07 +0000 Subject: * win/tkWinFont.c (GetScreenFont): corrected adjustment against LC_FACESIZE limitation for NT. [Bug: 4931] --- ChangeLog | 5 +++++ win/tkWinFont.c | 22 ++++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index fbe7e04..659ab82 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2000-04-07 Jeff Hobbs + + * win/tkWinFont.c (GetScreenFont): corrected adjustment against + LC_FACESIZE limitation for NT. [Bug: 4931] + 2000-04-03 Jeff Hobbs * generic/tkTest.c: fixed incorrect platform inclusion for 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); } -- cgit v0.12