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, 05 Jan 2022 22:41:55 -0700 Message-ID: <87czl55skc.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="39228"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 52888@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 06 06:50:49 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 1n5Lfk-000A45-7K for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 06 Jan 2022 06:50:49 +0100 Original-Received: from localhost ([::1]:39940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5Lfj-0001r3-6r for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 06 Jan 2022 00:50:47 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:34070) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5LYE-00053z-Fk for bug-gnu-emacs@gnu.org; Thu, 06 Jan 2022 00:43:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46561) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n5LYE-0000n7-5Z for bug-gnu-emacs@gnu.org; Thu, 06 Jan 2022 00:43:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n5LYD-0003ff-Uz for bug-gnu-emacs@gnu.org; Thu, 06 Jan 2022 00:43:01 -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, 06 Jan 2022 05:43: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.164144772414038 (code B ref 52888); Thu, 06 Jan 2022 05:43:01 +0000 Original-Received: (at 52888) by debbugs.gnu.org; 6 Jan 2022 05:42:04 +0000 Original-Received: from localhost ([127.0.0.1]:39464 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n5LXI-0003eM-Bc for submit@debbugs.gnu.org; Thu, 06 Jan 2022 00:42:04 -0500 Original-Received: from out2-smtp.messagingengine.com ([66.111.4.26]:35067) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n5LXG-0003do-3B for 52888@debbugs.gnu.org; Thu, 06 Jan 2022 00:42:02 -0500 Original-Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id E56C75C009A; Thu, 6 Jan 2022 00:41:56 -0500 (EST) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Thu, 06 Jan 2022 00:41:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=spwhitton.name; h=from:to:cc:subject:in-reply-to:date:message-id:mime-version :content-type; s=fm2; bh=RCmNQxUuigenCQtkpJYO0hLIiM70dRTkv4H58k+ Tu6Q=; b=beHu+wPdNMgR7m2Wx6ygwOGXvZQaZOiVm4fPO0EmTq0Mo6/1NTbwXyA 1U3h0YGDoRRDD/HGOdIMow0M0aiK6/AT2CMnYBIzbQ64OavNz+VfvDauwDi+0H0S fpC7MWlpDjLfDlRUir7bKqNmRK65YUV1LZpD6XDpObeRtyVRMiQXUYvKG3V5NQlC pr2R02SB43Z6S6T3f/i1Muo+pqh1T6r3/oM+qOTcBTEDmpz0j3RYXSwwr2lvoTMm nKRu/NFhBRaoMtHUlA8nr3Vq/IMMyh0GDPp2WUBaItm0CR1vExNIbIboIMLsdfb9 DklNBpsQyVao34aKCd3Ny9cpwnQ5wGg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=RCmNQxUuigenCQtkp JYO0hLIiM70dRTkv4H58k+Tu6Q=; b=e9FQfXvWFReu1obaqOxL05K2ktNYd/6L/ lb+dpjC3MJ+uZ6aW9EX5DUsQ1H1zC3nxdFLhNVlC7DuI6pW1XRBnSvFHlZb3E5q7 JlZXf2Lx5+lRrXuKmcqLuMS6MIBanLuoneZpDtS6GQq51kKkvnUI/nFf3HBuikMf l5xIp9i5SuUe+RdVjVjBT1SYhtDfpoprpnJe3ZCXDEQ/XG0d7qxTrUHJYvinUDpb iFc1rzhiuhhs9Dqbhgx5QBW+DItmftIAHtaGEujwS2fNlhFleDU/hdLXX1s7dgqb a3EEeJ48I0LPUX4kVrhqCtbCsJ4T866TaF6TP6kyIoI3AuiRaRI0w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrudefkedgtdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufgjfffkgggtsehmtddtredttddtnecuhfhrohhmpefuvggrnhcuhghh ihhtthhonhcuoehsphifhhhithhtohhnsehsphifhhhithhtohhnrdhnrghmvgeqnecugg ftrfgrthhtvghrnhepieehffeuheegkeffvdelheegteeutdetgfekhfelleffjeffffek hedvuddtgfetnecuffhomhgrihhnpegtohhnfhhighhurhgvrdgrtgenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehsphifhhhithhtohhnsehs phifhhhithhtohhnrdhnrghmvg X-ME-Proxy: Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 6 Jan 2022 00:41:56 -0500 (EST) Original-Received: by melete.silentflame.com (Postfix, from userid 1000) id 7B3EA7F952E; Wed, 5 Jan 2022 22:41:55 -0700 (MST) In-Reply-To: <83tuei9x3v.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:223721 Archived-At: --=-=-= Content-Type: text/plain Hello, On Wed 05 Jan 2022 at 02:37PM +02, Eli Zaretskii wrote: > According to what I see in the documentation, FcPatternGetRange exists > only since version 2.11.91 of Fontconfig, whereas we support 2.2.0 and > up. Ah, right. Is this version bound written down anywhere other than the conditionals in configure.ac? Sorry I didn't think to look there. > So we cannot unconditionally use that API, and some part of the > temporary solution will have to be left in the source. I'd need to > see the final patch with that in mind, before I can decide whether it > is simple/safe enough for the release branch. My patch requires FC_VARIABLE which was not added until 2.12.91, so in the attached revision I've set up preprocessor conditionals based on FC_VARIABLE. Checking that FC_VARIABLE is true is how we know it's one of the virtual entries. It looks like fontconfig commit 83b41611 introduced the meta patterns under discussion. The first tagged release including that commit is 2.12.91. So AFAICT nothing of the old fix need remain. > I'm far from being an expert on Fontconfig programming, but the above > use of 'range' looks strange: it's a pointer that starts pointing to > some random (potentially invalid) address, and you pass its address to > FcPatternGetRange, which presumably assigns to it a valid point. But > doesn't that valid pointer need to be released somehow after we use > it? Or does it point to static area(s)? I cannot find anything in > the Fontconfig documentation about the memory-management protocols for > FcValue objects, but maybe we should call FcValueDestroy on it after > we are done with it? Or maybe this is not needed, as this passage > from the docs says near the end: Yes, I was surprised too, but as has been mentioned, the FcPatternGet* functions are documented as supplying pointers to storage which must not be freed. -- Sean Whitton --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=v2-0001-Skip-virtual-FcPattern-entries-for-variable-weigh.patch >From d88f23882b66243b42d79e0fe897f99f8125c7c4 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Tue, 4 Jan 2022 19:07:29 -0700 Subject: [PATCH v2] 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 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/ftfont.c b/src/ftfont.c index 2bdcce306b..6bfbc50ffa 100644 --- a/src/ftfont.c +++ b/src/ftfont.c @@ -189,6 +189,19 @@ ftfont_pattern_entity (FcPattern *p, Lisp_Object extra) return Qnil; if (FcPatternGetInteger (p, FC_INDEX, 0, &idx) != FcResultMatch) return Qnil; +#ifdef FC_VARIABLE + FcRange *range; + 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; +#endif /* FC_VARIABLE */ file = (char *) str; key = Fcons (build_unibyte_string (file), make_fixnum (idx)); @@ -863,6 +876,9 @@ ftfont_list (struct frame *f, Lisp_Object spec) #if defined HAVE_XFT && defined FC_COLOR FC_COLOR, #endif +#ifdef FC_VARIABLE + FC_VARIABLE, +#endif /* FC_VARIABLE */ NULL); if (! objset) goto err; -- 2.30.2 --=-=-=--