From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thomas Kappler Newsgroups: gmane.emacs.bugs Subject: bug#11541: Possible fix Date: Tue, 6 Nov 2012 12:01:00 +0100 Message-ID: References: <4fbb6a82.d491cc0a.42d6.3965@mx.google.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7b6041a06eef0704cdd184a2 X-Trace: ger.gmane.org 1352199727 4994 80.91.229.3 (6 Nov 2012 11:02:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 6 Nov 2012 11:02:07 +0000 (UTC) To: 11541@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Nov 06 12:02:16 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TVgvA-00085Q-40 for geb-bug-gnu-emacs@m.gmane.org; Tue, 06 Nov 2012 12:02:16 +0100 Original-Received: from localhost ([::1]:45608 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TVgv1-0005er-9B for geb-bug-gnu-emacs@m.gmane.org; Tue, 06 Nov 2012 06:02:07 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:45939) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TVgut-0005N4-Ap for bug-gnu-emacs@gnu.org; Tue, 06 Nov 2012 06:02:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TVgun-0006di-8p for bug-gnu-emacs@gnu.org; Tue, 06 Nov 2012 06:01:59 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41318) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TVgun-0006db-5N for bug-gnu-emacs@gnu.org; Tue, 06 Nov 2012 06:01:53 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TVgxp-0007aQ-Ib for bug-gnu-emacs@gnu.org; Tue, 06 Nov 2012 06:05:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <4fbb6a82.d491cc0a.42d6.3965@mx.google.com> Resent-From: Thomas Kappler Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 06 Nov 2012 11:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11541 X-GNU-PR-Package: emacs,ns X-GNU-PR-Keywords: Original-Received: via spool by 11541-submit@debbugs.gnu.org id=B11541.135219985629110 (code B ref 11541); Tue, 06 Nov 2012 11:05:01 +0000 Original-Received: (at 11541) by debbugs.gnu.org; 6 Nov 2012 11:04:16 +0000 Original-Received: from localhost ([127.0.0.1]:51569 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TVgx5-0007ZR-5J for submit@debbugs.gnu.org; Tue, 06 Nov 2012 06:04:15 -0500 Original-Received: from mail-ea0-f172.google.com ([209.85.215.172]:63761) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TVgx1-0007ZI-N0 for 11541@debbugs.gnu.org; Tue, 06 Nov 2012 06:04:13 -0500 Original-Received: by mail-ea0-f172.google.com with SMTP id k13so134277eaa.3 for <11541@debbugs.gnu.org>; Tue, 06 Nov 2012 03:01:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=vRVAERevHElHqoKmwgdknVwY+dd9JgAksHnAaXkf0ZI=; b=EwcNWiyu3x9pUp04Em+6LE1AalDbe8kjE1UsHcwASnQC0ZbHb/mZtmSPzbH+FIwYlF dLc/g0LOzJJRURUKGM6exrVxL+RTU0uWHxYgNMzrMfnCgrpHANyu/dI3w2OhVrMn0LQJ iuJrzmsQEXvXLCW1QT1MJXN9YMEBUcyJXwgPnkpIMElKo5Nn0rhMS6l4pX37MJDBn+5N 7r/3yXXkv80lJk9BV0tsamvURdtuTfUwLNB4jHDFgQNVPcornrxNQA0q9zfsxdPUnvo1 vVKT96wDCfmzMfs8Qc/TmUIfOtuHv6jIGbRzKP8pouyzNHJZOVoBtfEUAdolEjLEHG6O 8WjQ== Original-Received: by 10.14.219.2 with SMTP id l2mr2542135eep.3.1352199660564; Tue, 06 Nov 2012 03:01:00 -0800 (PST) Original-Received: by 10.223.96.69 with HTTP; Tue, 6 Nov 2012 03:01:00 -0800 (PST) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:66525 Archived-At: --047d7b6041a06eef0704cdd184a2 Content-Type: text/plain; charset=UTF-8 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 #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]); --047d7b6041a06eef0704cdd184a2 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I investigated this a bit further and have a patch that fixes the right-arr= ow 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. (W= hy, I have no idea.) This crashes "[fdesc matchingFontDescriptorsWithM= andatoryKeys: 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

=3D=3D=3D modified file = 'src/nsfont.m'
--- src/nsfont.m=C2=A0=C2=A0=C2=A0 2012-10-21 18:= 48:11 +0000
+++ src/nsfont.m=C2=A0=C2=A0=C2=A0 2012-11-06 10:55:25 +0000=
@@ -43,7 +43,7 @@
=C2=A0#import <AppKit/NSFontDescriptor.h> =C2=A0#endif
=C2=A0
-#define NSFONT_TRACE 0
+#define NSFONT_TRACE = 1
=C2=A0
=C2=A0extern Lisp_Object Qns;
=C2=A0extern Lisp_Object Qn= ormal, Qbold, Qitalic, Qcondensed, Qexpanded;
@@ -556,10 +556,17 @@
= =C2=A0
=C2=A0=C2=A0=C2=A0=C2=A0 fdesc =3D ns_spec_to_descriptor (font_sp= ec);
=C2=A0=C2=A0=C2=A0=C2=A0 fkeys =3D [NSMutableSet setWithArray: [[fdesc font= Attributes] allKeys]];
+=C2=A0=C2=A0=C2=A0 if (NSFONT_TRACE)
+=C2=A0= =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 NSLog(@"Got %d fkeys: %@ ", [fkey= s count], fkeys);
+=C2=A0=C2=A0=C2=A0
=C2=A0=C2=A0=C2=A0=C2=A0 if (i= sMatch)
=C2=A0=C2=A0=C2=A0=C2=A0 [fkeys removeObject: NSFontFamilyAttrib= ute];
=C2=A0
-=C2=A0=C2=A0=C2=A0 matchingDescs =3D [fdesc matchingFontDescript= orsWithMandatoryKeys: fkeys];
+=C2=A0=C2=A0=C2=A0 if ([fkeys count] >= 0) {
+=C2=A0=C2=A0=C2=A0 matchingDescs =3D [fdesc matchingFontDescripto= rsWithMandatoryKeys: fkeys];
+=C2=A0=C2=A0=C2=A0 } else {
+=C2=A0=C2= =A0=C2=A0 matchingDescs =3D [NSMutableArray array];
+=C2=A0=C2=A0=C2=A0 }
=C2=A0=C2=A0=C2=A0=C2=A0 if (NSFONT_TRACE)
=C2= =A0=C2=A0=C2=A0=C2=A0 NSLog(@"Got desc %@ and found %d matching fonts = from it: ", fdesc,
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 [matchingDescs count]);

--047d7b6041a06eef0704cdd184a2--