summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXFont.c18
1 files changed, 14 insertions, 4 deletions
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;