| Description: |
What on earth is going on inside the NT branch inside
win/tkWinFont.c:GetScreenFont()
Does LF_FACESIZE refer to the number of bytes or the
number of characters (and is that including or
excluding the U+0000 at the end) and why are we copying
bytewise when we know the length of the string
(Tcl_DStringLength will tell us)? Surely we can just
use memcpy() (and add the trailing U+0000, of course)
like this:
Tcl_UniChar *dst = (Tcl_UniChar *) lf.lfFaceName;
memcpy(dst, Tcl_DStringValue(&ds),
Tcl_DStringLength(&ds));
dst[Tcl_DStringLength(&ds)/sizeof(Tcl_UniChar)] = 0;
Who knows, perhaps this will be both faster and less
buggy; see the recent thread on c.l.t for the reason
for this bug report:
http://groups.google.com/groups?dq=&hl=en&lr=&ie=UTF-8&threadm=2e3f283.0312181501.38f68864%40posting.google.com&prev=/groups%3Fgroup%3Dcomp.lang.tcl%26hl%3Den
I'm not entirely convinced that the non-NT branch is
right either when things truncate (and why strcpy()
when we know the length?) but I'll let the area
maintainer deal with that.
|
| User Comments: |
hobbs added on 2004-05-04 05:56:54:
Logged In: YES
user_id=72656
From MSDN:
lfFaceName
A null-terminated string that specifies the typeface
name of the font. The length of this string must not exceed
32 characters, including the null terminator. The
EnumFontFamiliesEx function can be used to enumerate the
typeface names of all currently available fonts. If
lfFaceName is an empty string, GDI uses the first font that
matches the other specified attributes.
|