From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Adrian Robert Newsgroups: gmane.emacs.devel Subject: trunk patch: font.c: font_matching_entity() Date: Mon, 29 Sep 2008 20:54:01 -0400 Message-ID: <717CC6DC-7294-4815-9B61-748AEF59D0FB@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v926) Content-Type: multipart/mixed; boundary=Apple-Mail-29--384294040 X-Trace: ger.gmane.org 1222736170 12939 80.91.229.12 (30 Sep 2008 00:56:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 30 Sep 2008 00:56:10 +0000 (UTC) To: Emacs-Devel devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 30 02:57:08 2008 connect(): Connection refused Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KkTY3-0002nO-Js for ged-emacs-devel@m.gmane.org; Tue, 30 Sep 2008 02:57:08 +0200 Original-Received: from localhost ([127.0.0.1]:51274 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KkTX0-0001Nz-SM for ged-emacs-devel@m.gmane.org; Mon, 29 Sep 2008 20:56:02 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KkTVe-0000jf-T7 for emacs-devel@gnu.org; Mon, 29 Sep 2008 20:54:38 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KkTVe-0000in-10 for emacs-devel@gnu.org; Mon, 29 Sep 2008 20:54:38 -0400 Original-Received: from [199.232.76.173] (port=59298 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KkTVd-0000ia-Qa for emacs-devel@gnu.org; Mon, 29 Sep 2008 20:54:37 -0400 Original-Received: from mail-gx0-f12.google.com ([209.85.217.12]:62263) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KkTVd-0007UV-JC for emacs-devel@gnu.org; Mon, 29 Sep 2008 20:54:37 -0400 Original-Received: by gxk5 with SMTP id 5so11531049gxk.18 for ; Mon, 29 Sep 2008 17:54:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:to:content-type :mime-version:subject:date:x-mailer:from; bh=HpewS1lvm6bI0IEFm7NODa6iEhm7KEep15zLqgUFjoc=; b=ouIGsqRkGk0VNuIBvJmPnfptn5h0FF8Zmf0AZxXcEK18WV++pJZV4wrOax9/QF00+4 W7xCfUxiVLKjA0koFiOiImV4EpRCJ1cDT9dcM2r7FQE7OFc4ahq2Jn2DHXlH32b59KR2 YX5PdwU3MJJs5aj5il2xsRNh7BdzAILIxOHw8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:to:content-type:mime-version:subject:date:x-mailer:from; b=YS9KPoBBxpjc0QiGo08mA574qCesLJtU9Iseuj0vbjDv1wtRQvKn5W3qQmKe+MxY8Y ZnwtNh7G3dDR62S6mKDdvw3NkFCYWt3LGCzpZpCJnm/KSqjySscBoarKc3HYiEnfn434 XItr0+9QyJLJgUSrlF+TAmU1AqOgf/kRzDWWE= Original-Received: by 10.90.101.7 with SMTP id y7mr6494088agb.13.1222736076265; Mon, 29 Sep 2008 17:54:36 -0700 (PDT) Original-Received: from ?10.0.1.199? ([72.169.150.82]) by mx.google.com with ESMTPS id c44sm839510hsc.12.2008.09.29.17.54.25 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 29 Sep 2008 17:54:35 -0700 (PDT) X-Mailer: Apple Mail (2.926) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:104239 Archived-At: --Apple-Mail-29--384294040 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Hi, The function font_matching_entity() in font.c ignores its ATTRS argument. If, in the sequence xfaces.c: realize_x_face() -> font.c: font_load_for_lface() -> font.c: font_find_for_lface the last call fails to find anything, font_matching_entity() will be called, and, as far as I can tell, returns incorrect results. The attached patch causes ATTRS to be used in both the cache check and the call to driver->match(), and allows a better-matching font to be found in the above use case. (The patch also makes a case-insensitive family name comparison in font_find_for_lface() case-sensitive when compiling under HAVE_NS.) -Adrian --Apple-Mail-29--384294040 Content-Disposition: attachment; filename=fontMatch_20080929.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="fontMatch_20080929.patch" Content-Transfer-Encoding: 7bit Index: font.c =================================================================== RCS file: /sources/emacs/emacs/src/font.c,v retrieving revision 1.83 diff -u -p -r1.83 font.c --- font.c 10 Sep 2008 05:54:09 -0000 1.83 +++ font.c 30 Sep 2008 00:51:43 -0000 @@ -2765,12 +2765,18 @@ font_matching_entity (f, attrs, spec) struct font_driver_list *driver_list = f->font_driver_list; Lisp_Object ftype, size, entity; Lisp_Object frame; + Lisp_Object work = Fcopy_font_spec (spec); XSETFRAME (frame, f); ftype = AREF (spec, FONT_TYPE_INDEX); size = AREF (spec, FONT_SIZE_INDEX); if (FLOATP (size)) ASET (spec, FONT_SIZE_INDEX, make_number (font_pixel_size (f, spec))); + + FONT_SET_STYLE (work, FONT_WEIGHT_INDEX, attrs[LFACE_WEIGHT_INDEX]); + FONT_SET_STYLE (work, FONT_SLANT_INDEX, attrs[LFACE_SLANT_INDEX]); + FONT_SET_STYLE (work, FONT_WIDTH_INDEX, attrs[LFACE_SWIDTH_INDEX]); + entity = Qnil; for (; driver_list; driver_list = driver_list->next) if (driver_list->on @@ -2779,14 +2785,14 @@ font_matching_entity (f, attrs, spec) Lisp_Object cache = font_get_cache (f, driver_list->driver); Lisp_Object copy; - ASET (spec, FONT_TYPE_INDEX, driver_list->driver->type); - entity = assoc_no_quit (spec, XCDR (cache)); + ASET (work, FONT_TYPE_INDEX, driver_list->driver->type); + entity = assoc_no_quit (work, XCDR (cache)); if (CONSP (entity)) entity = XCDR (entity); else { - entity = driver_list->driver->match (frame, spec); - copy = Fcopy_font_spec (spec); + entity = driver_list->driver->match (frame, work); + copy = Fcopy_font_spec (work); ASET (copy, FONT_TYPE_INDEX, driver_list->driver->type); XSETCDR (cache, Fcons (Fcons (copy, entity), XCDR (cache))); } @@ -2795,7 +2801,7 @@ font_matching_entity (f, attrs, spec) } ASET (spec, FONT_TYPE_INDEX, ftype); ASET (spec, FONT_SIZE_INDEX, size); - font_add_log ("match", spec, entity); + font_add_log ("match", work, entity); return entity; } @@ -3166,7 +3172,12 @@ font_find_for_lface (f, attrs, spec, c) else { Lisp_Object alters - = Fassoc_string (val, Vface_alternative_font_family_alist, Qt); + = Fassoc_string (val, Vface_alternative_font_family_alist, +#ifndef HAVE_NS + Qt); +#else + Qnil); +#endif if (! NILP (alters)) { --Apple-Mail-29--384294040 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit --Apple-Mail-29--384294040--