summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcc_benny <cc_benny>2009-12-06 17:15:24 (GMT)
committercc_benny <cc_benny>2009-12-06 17:15:24 (GMT)
commited9cba261d753fabd85836e5aaf6e6bf15e6d9bc (patch)
treeeca845d697cc3b078f0f24e54d92356a85a40fe1
parent4f22e4e2865a8ef6917cc8a16c3a4041ab2e3b5a (diff)
downloadtk-ed9cba261d753fabd85836e5aaf6e6bf15e6d9bc.zip
tk-ed9cba261d753fabd85836e5aaf6e6bf15e6d9bc.tar.gz
tk-ed9cba261d753fabd85836e5aaf6e6bf15e6d9bc.tar.bz2
* macosx/tkMacOSXFont.c (GetFontFamilyName): [Bug #2548661]
Merge fix from HEAD (1.44).
-rw-r--r--ChangeLog5
-rw-r--r--macosx/tkMacOSXFont.c18
2 files changed, 19 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index f5c1772..2aa4465 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-12-06 Benjamin Riefenstahl <b.riefenstahl@turtle-trading.net>
+
+ * macosx/tkMacOSXFont.c (GetFontFamilyName): [Bug #2548661] Merge fix
+ from HEAD (1.44).
+
2009-12-03 Pat Thoyts <patthoyts@users.sourceforge.net>
* library/ttk/xpTheme.tcl: Fix selection of treeview rows on
diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c
index 7a7cfc8..09d8782 100644
--- a/macosx/tkMacOSXFont.c
+++ b/macosx/tkMacOSXFont.c
@@ -35,7 +35,7 @@
* that such fonts can not be used for controls, because controls
* definitely require a family id (this assertion needs testing).
*
- * RCS: @(#) $Id: tkMacOSXFont.c,v 1.37.2.3 2008/08/19 00:19:10 das Exp $
+ * RCS: @(#) $Id: tkMacOSXFont.c,v 1.37.2.4 2009/12/06 17:15:25 cc_benny Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -2128,7 +2128,9 @@ GetFontFamilyName(
/*
* QuickDraw font names are encoded with the script that the font uses.
- * So we determine that encoding and than we reencode the name.
+ * So we determine that encoding and than we reencode the name. We
+ * pre-set the encoding with the default value, so we do not need to
+ * check result codes here.
*/
encoding = kTextEncodingMacRoman;
@@ -2145,12 +2147,20 @@ GetFontFamilyName(
* have seen CFStringGetCString() crash with invalid encoding ids. But
* than if that happens it would be a bug in
* FMGetFontFamilyTextEncoding() or RevertTextEncodingToScriptInfo().
+ * Another problem is that users have seen CFStringCreate return null
+ * (Bug #2548661). This is due to font names with a bad encoding.
*/
cfString = CFStringCreateWithPascalStringNoCopy(
NULL, nativeName, nameencoding, kCFAllocatorNull);
- CFStringGetCString(
- cfString, name, numBytes, kCFStringEncodingUTF8);
+ if (cfString == NULL) {
+ TkMacOSXDbgMsg("CFStringCreate: "
+ "'%.*s' could not be decoded with encoding %d",
+ nativeName[0], nativeName+1, (int) nameencoding);
+ return kTextMalformedInputErr;
+ }
+
+ CFStringGetCString(cfString, name, numBytes, kCFStringEncodingUTF8);
CFRelease(cfString);
return noErr;