From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Sean Whitton Newsgroups: gmane.emacs.bugs Subject: bug#52888: 29.0.50; font_{delete_unmatched,score} do not handle nil FONT_WEIGHT_INDEX Date: Wed, 29 Dec 2021 22:28:37 -0700 Message-ID: <87zgoi8xve.fsf@melete.silentflame.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3196"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Notmuch/0.31.4 (https://notmuchmail.org) Emacs/29.0.50 (x86_64-pc-linux-gnu) To: 52888@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 30 06:29:54 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n2o0e-0000cJ-7x for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 30 Dec 2021 06:29:54 +0100 Original-Received: from localhost ([::1]:43904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n2o0c-0000Ri-J0 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 30 Dec 2021 00:29:50 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:36280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2nzq-0000RZ-LW for bug-gnu-emacs@gnu.org; Thu, 30 Dec 2021 00:29:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39342) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2nzq-000548-Bd for bug-gnu-emacs@gnu.org; Thu, 30 Dec 2021 00:29:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n2nzq-0002Pb-15 for bug-gnu-emacs@gnu.org; Thu, 30 Dec 2021 00:29:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Sean Whitton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 30 Dec 2021 05:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 52888 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16408421259244 (code B ref -1); Thu, 30 Dec 2021 05:29:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 30 Dec 2021 05:28:45 +0000 Original-Received: from localhost ([127.0.0.1]:50888 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2nzZ-0002P1-E5 for submit@debbugs.gnu.org; Thu, 30 Dec 2021 00:28:45 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:45556) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2nzX-0002Ot-GY for submit@debbugs.gnu.org; Thu, 30 Dec 2021 00:28:43 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:36272) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2nzX-0000RE-8i for bug-gnu-emacs@gnu.org; Thu, 30 Dec 2021 00:28:43 -0500 Original-Received: from out2-smtp.messagingengine.com ([66.111.4.26]:43135) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2nzV-000526-7D for bug-gnu-emacs@gnu.org; Thu, 30 Dec 2021 00:28:42 -0500 Original-Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 7D19F5C0292 for ; Thu, 30 Dec 2021 00:28:38 -0500 (EST) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 30 Dec 2021 00:28:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=spwhitton.name; h=from:to:subject:date:message-id:mime-version:content-type; s= fm2; bh=+9KbHcsmVkLsi9UGTI5Yc34+HRb9JCu0ynBMmM+JuEI=; b=sl5cXggn GJ3ZjT7Iykc04cVitCb5CRDRwTv9WSOJD6wiw1mUpDxV+AzE4WkZ+nf/oe5Nfzrs O84sEhlV9t76gs7LT41V4RG1EBKdZzfbeHiBzf+5o5BiQo40fv196RTm6T3wv1Qp IgAOaSbofP0jycyH+EXNWcQ9DBfQNhQ4hOIvwa0z12C68stKQXQlHt1HNTv+9lli j81xzokyGHYNHX1pF+nj1e/lcfTKVmrVjXyC/MvyiAJHWYerVs+4t1E1G+EfITr4 25eLic2Xqs8tEK41kDmOeDqe0DgpPUygiT1hUYR4EWzJ96tMdXbYgeHAfrLIdion Dwvgd8ju1c2vDQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=+9KbHcsmVkLsi9UGTI5Yc34+HRb9J Cu0ynBMmM+JuEI=; b=OFuW5HN6esRQ/gAQwDGAVkIkrTAvigwKzZLF0mzU2WoNG mwXCeT+d6EsYbgDzGanS3ImtXlDx611kdzhjXnyrQU7KDak40ky5AGnxWwDTs05k igaDhXhpJlsWvZOwL1F8cm+WalBx2jqvYOGzUpbgA3g4g+PGgt7WZH1IOvISdeMF Qe9QE4tXJRyz2QL+7seqEynyyguvcLEZPKjSk0pf582foYlzIKWw9rdmRaVkG/9Z n+I9kIYxYmERA+bx5OLard/xIubjzTias6GGt1ccbNEBkqsUPR82bdMJZuZEB4No CfdBcHH/OfaXC3u2FZsY4T+TmdhtEGDK8NFPfMCig== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddruddvvddgkeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufgffkfggtgesmhdttdertd ertdenucfhrhhomhepufgvrghnucghhhhithhtohhnuceoshhpfihhihhtthhonhesshhp fihhihhtthhonhdrnhgrmhgvqeenucggtffrrghtthgvrhhnpefhuefhteetieefjeejud dtueeiteffjeffkeektdeltdeuffehteejleelkefhgeenucffohhmrghinhepghhithhh uhgsrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepshhpfihhihhtthhonhesshhpfihhihhtthhonhdrnhgrmhgv X-ME-Proxy: Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Thu, 30 Dec 2021 00:28:38 -0500 (EST) Original-Received: by melete.silentflame.com (Postfix, from userid 1000) id 314597F89D9; Wed, 29 Dec 2021 22:28:37 -0700 (MST) Received-SPF: pass client-ip=66.111.4.26; envelope-from=spwhitton@spwhitton.name; helo=out2-smtp.messagingengine.com X-Spam_score_int: -8 X-Spam_score: -0.9 X-Spam_bar: / X-Spam_report: (-0.9 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:223410 Archived-At: --=-=-= Content-Type: text/plain Hello, On my system I have a variable weight .ttf font[1] installed somewhere. When I build with --enable-check-lisp-object-type, the line int candidate = XFIXNUM (AREF (entity, prop)) >> 8; in font_delete_unmatched and the expression EMACS_INT diff = ((XFIXNUM (AREF (entity, i)) >> 8) - (XFIXNUM (spec_prop[i]) >> 8)); in font_score have failed assertions because the FONT_WEIGHT_INDEX for this .ttf file is nil: # I don't believe Emacs really knows how to handle these multi-weight .ttf files? Thus I propose the attached patch, to handle the value. [1] https://github.com/googlefonts/Inconsolata/tree/main/fonts/variable -- Sean Whitton --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Handle-nil-FONT_WEIGHT_INDEX.patch >From b7eff2c3e1d09f44b1d5790275fc92c11e9be88f Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 29 Dec 2021 21:18:07 -0700 Subject: [PATCH] Handle nil FONT_WEIGHT_INDEX * src/font.c (font_delete_unmatched, font_score): Handle nil entity property. In particular, FONT_WEIGHT_INDEX is nil for some variable weight fonts. --- src/font.c | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/src/font.c b/src/font.c index fa831f2861..cb057abca6 100644 --- a/src/font.c +++ b/src/font.c @@ -2183,7 +2183,8 @@ font_score (Lisp_Object entity, Lisp_Object *spec_prop) /* Score three style numeric fields. Maximum difference is 127. */ for (i = FONT_WEIGHT_INDEX; i <= FONT_WIDTH_INDEX; i++) - if (! NILP (spec_prop[i]) && ! EQ (AREF (entity, i), spec_prop[i])) + if (! NILP (spec_prop[i]) && ! NILP (AREF (entity, i)) + && ! EQ (AREF (entity, i), spec_prop[i])) { EMACS_INT diff = ((XFIXNUM (AREF (entity, i)) >> 8) - (XFIXNUM (spec_prop[i]) >> 8)); @@ -2764,26 +2765,31 @@ font_delete_unmatched (Lisp_Object vec, Lisp_Object spec, int size) { if (FIXNUMP (AREF (spec, prop))) { - int required = XFIXNUM (AREF (spec, prop)) >> 8; - int candidate = XFIXNUM (AREF (entity, prop)) >> 8; + if (NILP (AREF (entity, prop))) + prop = FONT_SPEC_MAX; + else { + int required = XFIXNUM (AREF (spec, prop)) >> 8; + int candidate = XFIXNUM (AREF (entity, prop)) >> 8; - if (candidate != required + if (candidate != required #ifdef HAVE_NTGUI - /* A kludge for w32 font search, where listing a - family returns only 4 standard weights: regular, - italic, bold, bold-italic. For other values one - must specify the font, not just the family in the - :family attribute of the face. But specifying - :family in the face attributes looks for regular - weight, so if we require exact match, the - non-regular font will be rejected. So we relax - the accuracy of the match here, and let - font_sort_entities find the best match. */ - && (prop != FONT_WEIGHT_INDEX - || eabs (candidate - required) > 100) + /* A kludge for w32 font search, where listing a + family returns only 4 standard weights: + regular, italic, bold, bold-italic. For other + values one must specify the font, not just the + family in the :family attribute of the face. + But specifying :family in the face attributes + looks for regular weight, so if we require + exact match, the non-regular font will be + rejected. So we relax the accuracy of the + match here, and let font_sort_entities find the + best match. */ + && (prop != FONT_WEIGHT_INDEX + || eabs (candidate - required) > 100) #endif - ) - prop = FONT_SPEC_MAX; + ) + prop = FONT_SPEC_MAX; + } } } if (prop < FONT_SPEC_MAX -- 2.30.2 --=-=-=--