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: Tue, 04 Jan 2022 19:10:46 -0700 Message-ID: <87bl0raq55.fsf@melete.silentflame.com> References: <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="20324"; mail-complaints-to="usenet@ciao.gmane.io" To: Eli Zaretskii , 52888@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jan 05 03:16:05 2022 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 1n4vqO-00056L-7Z for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 05 Jan 2022 03:16:05 +0100 Original-Received: from localhost ([::1]:37362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n4vqN-0008OQ-0a for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 04 Jan 2022 21:16:03 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:50396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n4vlW-0004yN-Hs for bug-gnu-emacs@gnu.org; Tue, 04 Jan 2022 21:11:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55982) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n4vlW-00035o-7I for bug-gnu-emacs@gnu.org; Tue, 04 Jan 2022 21:11:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n4vlW-0004sE-0K for bug-gnu-emacs@gnu.org; Tue, 04 Jan 2022 21:11: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: Wed, 05 Jan 2022 02:11:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52888 X-GNU-PR-Package: emacs Original-Received: via spool by 52888-submit@debbugs.gnu.org id=B52888.164134865918725 (code B ref 52888); Wed, 05 Jan 2022 02:11:01 +0000 Original-Received: (at 52888) by debbugs.gnu.org; 5 Jan 2022 02:10:59 +0000 Original-Received: from localhost ([127.0.0.1]:39295 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n4vlS-0004rw-Sw for submit@debbugs.gnu.org; Tue, 04 Jan 2022 21:10:59 -0500 Original-Received: from out5-smtp.messagingengine.com ([66.111.4.29]:48101) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n4vlN-0004rg-Se for 52888@debbugs.gnu.org; Tue, 04 Jan 2022 21:10:57 -0500 Original-Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 773AE5C0189; Tue, 4 Jan 2022 21:10:48 -0500 (EST) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Tue, 04 Jan 2022 21:10:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=spwhitton.name; h=from:to:subject:in-reply-to:date:message-id:mime-version :content-type; s=fm2; bh=gAtwIwo8yLu9F30anvlu0ZXsj49jy8MNtj264yl U8yU=; b=cI1vo2IlOT8Ffh4c0c7AxRQU4fqU66JQO1tu8vOrTxZQvpsEukq0APB ty7SEaz/239e54kXIsXh78rEVRjHJXzSyt9plhqpS8//6GQsQYI2Kv9bYr7tG94v 5flgqiiUG3YS65Byx9nOzOheEbIwAJcuo1biIUYswjLpepbEOrHjpy9OzMGf8NSo Kh6ubNOZxzvuQPSmUimVvShyjHDo+ZNPbbU2Ss8lr1mG5C0Z0dz3vuGYRdvckLGB n44LdS3EYgQZ6yIUKb9Yu8mqxhrBSeaHjh/Vf5vQvWeB/P8sjW2YHWfcJrF4co7G HCkKq/O0a7aKRk0BWZzFCKG99IEZ/LA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=gAtwIwo8yLu9F30an vlu0ZXsj49jy8MNtj264ylU8yU=; b=OL5MGNYh6KYhSUTPu5GI+/QR7Y7lzl0WP H2XAleP84Jk4POfS/LK5SE5m72SM7RTOx07asUSijRQNsJ9sSWD7qVokjcaqRhdL q+OGPCAn+6No/mETF9H9CjkwV4tm2eFBjmIObO32bxQ6VqYzR67mZCxbbV0Vc4tj tyJbzRubz50It0f4IKLkIaXoSzB9433Rq2QjAec/MwXBoGx97DozzWftBjQ7ZRt/ 37B598GKhEriBZRXV8rfhp6EsXjHzXvuiCMcTZ52pWdmBHe12d61Y0alGmqOV84x aWGGHHu/lfMc7UlzGS7MAFAtHu4tpq/AogICPEYv48mv9lwPaaYcw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrudefgedggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufgjfffkgggtsehmtddtredttddtnecuhfhrohhmpefuvggrnhcuhghh ihhtthhonhcuoehsphifhhhithhtohhnsehsphifhhhithhtohhnrdhnrghmvgeqnecugg ftrfgrthhtvghrnhepleefffdvvefhgfehudeugefggfeffedvvdffuedvvdelgffghfff leehheetffehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepshhpfihhihhtthhonhesshhpfihhihhtthhonhdrnhgrmhgv X-ME-Proxy: Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 4 Jan 2022 21:10:48 -0500 (EST) Original-Received: by melete.silentflame.com (Postfix, from userid 1000) id 70D527F7ABB; Tue, 4 Jan 2022 19:10:46 -0700 (MST) In-Reply-To: <83sfu8exkp.fsf@gnu.org> 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:223678 Archived-At: --=-=-= Content-Type: text/plain Hello, On Sat 01 Jan 2022 at 09:15AM +02, Eli Zaretskii wrote: > However, the question that I think we should ask ourselves at this > point is whether there's a reasonable way to process these fonts into > a font spec that Emacs expects. So if FcPatternGetInteger and > FcPatternGetDouble don't do the job, perhaps there's another > fontconfig function that does, or maybe these fonts need to be > processed in some slightly different ways (like in a loop, for > example) to produce the weight matches from them? I received a helpful reply from Akira TAGOH on the fontconfig list. The problematic entries are not in fact additional font weights available to Emacs, but meta or virtual entries from which applications can extract information about the range of weights provided by the variable weight .ttf file. As we do not need to know the range of weights explicitly, the virtual entries are no use to us. We can just skip over them and process the non-virtual FcPattern entries we get for each weight. I'm attaching a patch which detects these virtual entries and skips over them. Maybe we could revert and replace the temporary fix with my patch? As a test, I tried calling FcPatternGetRange on the virtual entry for Inconsolata-VariableFont_wdth,wght.ttf and I got a range of 40 to 210. I confirmed that the weights of all the non-virtual entries fall within this range, inclusive. -- Sean Whitton --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Skip-virtual-FcPattern-entries-for-variable-weight-f.patch >From 4747fe3072c6fca0385203cef9b6e2661badaaba Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Tue, 4 Jan 2022 19:07:29 -0700 Subject: [PATCH] Skip virtual FcPattern entries for variable weight fonts * src/ftfont.c (ftfont_list): Pass FC_VARIABLE to FcObjectSetBuild. * src/ftfont.c (ftfont_pattern_entity): Skip meta/virtual FcPattern entries for variable weight fonts (Bug#52888). --- src/ftfont.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/ftfont.c b/src/ftfont.c index cf592759ab..73276fdc86 100644 --- a/src/ftfont.c +++ b/src/ftfont.c @@ -184,11 +184,22 @@ ftfont_pattern_entity (FcPattern *p, Lisp_Object extra) int numeric; double dbl; FcBool b; + FcRange *range; if (FcPatternGetString (p, FC_FILE, 0, &str) != FcResultMatch) return Qnil; if (FcPatternGetInteger (p, FC_INDEX, 0, &idx) != FcResultMatch) return Qnil; + if (FcPatternGetRange (p, FC_WEIGHT, 0, &range) == FcResultMatch + && FcPatternGetBool (p, FC_VARIABLE, 0, &b) == FcResultMatch + && b == FcTrue) + /* This is a virtual/meta FcPattern for a variable weight font, + from which it is possible to extract an FcRange value + specifying the minimum and maximum weights available in this + file. We don't need to know that information explicitly, so + skip it. We will be called with an FcPattern for each actually + available, non-virtual weight. */ + return Qnil; file = (char *) str; key = Fcons (build_unibyte_string (file), make_fixnum (idx)); @@ -853,7 +864,7 @@ ftfont_list (struct frame *f, Lisp_Object spec) adstyle = Qnil; objset = FcObjectSetBuild (FC_FOUNDRY, FC_FAMILY, FC_WEIGHT, FC_SLANT, FC_WIDTH, FC_PIXEL_SIZE, FC_SPACING, FC_SCALABLE, - FC_STYLE, FC_FILE, FC_INDEX, + FC_STYLE, FC_FILE, FC_INDEX, FC_VARIABLE, #ifdef FC_CAPABILITY FC_CAPABILITY, #endif /* FC_CAPABILITY */ -- 2.30.2 --=-=-=--