Subject: Possible fix

From: Thomas Kappler <[email-masked]>
Date: Tue, 6 Nov 2012 12:01:00 +0100

I investigated this a bit further and have a patch that fixes the
right-arrow test file for me, I can open it and the arrow displays without
problems.

Note that this is my very first foray into the Emacs source as well as into
Objective-C.

The problem is that ns_findfonts is being passed an empty font_spec. (Why,
I have no idea.) This crashes "[fdesc
matchingFontDescriptorsWithMandatoryKeys: fkeys]". The fix is to check for
this case and, if there are no keys in the font_spec, simply initialize
matchingDescs to an empty array.

Cheers,
Thomas

$ bzr diff

=== modified file 'src/nsfont.m'
--- src/nsfont.m    2012-10-21 18:48:11 +0000
+++ src/nsfont.m    2012-11-06 10:55:25 +0000
@@ -43,7 +43,7 @@
 #import <AppKit/NSFontDescriptor.h>
 #endif

-#define NSFONT_TRACE 0
+#define NSFONT_TRACE 1

 extern Lisp_Object Qns;
 extern Lisp_Object Qnormal, Qbold, Qitalic, Qcondensed, Qexpanded;
@@ -556,10 +556,17 @@

     fdesc = ns_spec_to_descriptor (font_spec);
     fkeys = [NSMutableSet setWithArray: [[fdesc fontAttributes] allKeys]];
+    if (NSFONT_TRACE)
+        NSLog(@"Got %d fkeys: %@ ", [fkeys count], fkeys);
+
     if (isMatch)
     [fkeys removeObject: NSFontFamilyAttribute];

-    matchingDescs = [fdesc matchingFontDescriptorsWithMandatoryKeys:
fkeys];
+    if ([fkeys count] > 0) {
+    matchingDescs = [fdesc matchingFontDescriptorsWithMandatoryKeys:
fkeys];
+    } else {
+    matchingDescs = [NSMutableArray array];
+    }
     if (NSFONT_TRACE)
     NSLog(@"Got desc %@ and found %d matching fonts from it: ", fdesc,
           [matchingDescs count]);