From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#70989: 29.3; Calling isearch-forward when using Unifont throws error "Invalid font name" Date: Sun, 19 May 2024 14:42:58 +0300 Message-ID: <86bk52auyl.fsf@gnu.org> References: <3df5d89f24d568fa565913cec6902fb0@rodrigomorales.site> <86pltlh7ua.fsf@gnu.org> <87eda1ldsl.fsf@rodrigomorales.site> <86cyplge4o.fsf@gnu.org> <87wmnsya2h.fsf@yahoo.com> <87r0e0pj2c.fsf@rodrigomorales.site> <87ttiv71el.fsf@yahoo.com> <86seyfcewy.fsf@gnu.org> <86wmnqbala.fsf@gnu.org> <87jzjq6ymy.fsf@yahoo.com> <86o792b5qx.fsf@gnu.org> <87frue6omb.fsf@yahoo.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3840"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 70989@debbugs.gnu.org, me@rodrigomorales.site To: Po Lu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 19 13:46:21 2024 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 1s8ezc-0000of-Dv for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 19 May 2024 13:46:20 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s8ezK-0004UY-1G; Sun, 19 May 2024 07:46:02 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s8ezI-0004U2-2C for bug-gnu-emacs@gnu.org; Sun, 19 May 2024 07:46:00 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s8ezG-0002Vg-Qk for bug-gnu-emacs@gnu.org; Sun, 19 May 2024 07:45:59 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s8ezK-0007Uq-Ia for bug-gnu-emacs@gnu.org; Sun, 19 May 2024 07:46:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 19 May 2024 11:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70989 X-GNU-PR-Package: emacs Original-Received: via spool by 70989-submit@debbugs.gnu.org id=B70989.171611912528781 (code B ref 70989); Sun, 19 May 2024 11:46:02 +0000 Original-Received: (at 70989) by debbugs.gnu.org; 19 May 2024 11:45:25 +0000 Original-Received: from localhost ([127.0.0.1]:35974 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s8eyj-0007U9-Aj for submit@debbugs.gnu.org; Sun, 19 May 2024 07:45:25 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:48866) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s8eyg-0007Tz-Ap for 70989@debbugs.gnu.org; Sun, 19 May 2024 07:45:23 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s8ewP-0001s3-Eg; Sun, 19 May 2024 07:43:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=2X6+2uQ9JFdCuI23SPDclRDjb+V8jGLYBZoL3a5SnR8=; b=f0LMZZH/dGL5 9lNE4XkVWxTeD1gjDMfhXXN4eCPiC/gNjI5u489qf1BTpadAdNluG0szXeVz4pP9ttmW2uOsD/09k 8BPkIOY0r62o/zlROPUfkMs/ZH6wTEySQ5/wwEbxSjYAMhhZjJQQnKoLpI71s3Ep2tRwCCetqE8bT zm7GI3+s0xnJrHKO88i0KpgqNsDvQKvMLxxptmyGAH8KxmGBXwrO43Y67PUztA3cjNTR2vSQOWuZ5 NNTo9XX4uJZ17IyTgPwxmosb3XBnbdQB7aGL6SKa098Uh1zwf/jcj2cnF2P2/DIcbTOhJAvT7GNDV 0YAgV95//bQy1modqUbjUw==; In-Reply-To: <87frue6omb.fsf@yahoo.com> (message from Po Lu on Sun, 19 May 2024 19:13:32 +0800) 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:285424 Archived-At: > From: Po Lu > Cc: me@rodrigomorales.site, 70989@debbugs.gnu.org > Date: Sun, 19 May 2024 19:13:32 +0800 > > Eli Zaretskii writes: > > >> From: Po Lu > >> Cc: me@rodrigomorales.site, 70989@debbugs.gnu.org > >> Date: Sun, 19 May 2024 15:37:09 +0800 > >> > >> Eli Zaretskii writes: > >> > >> > What I see there is the call to fond_intern_prop, and if the result is > >> > accepted by font_style_to_value as a valid value of FONT_WIDTH_INDEX, > >> > it is returned. But "Sans-Serif" is not supposed to be a valid width > >> > of a font, so I'm confused. > >> > >> Where does FONT_WIDTH_INDEX come into play? > > > > Inside get_adstyle_property: > > > > adstyle = font_intern_prop (str, end - str, 1); > > if (font_style_to_value (FONT_WIDTH_INDEX, adstyle, 0) >= 0) > > return Qnil; > > return adstyle; > > This tests whether the adstyle duplicates information that the pattern > might provide as the font width, since if so, the adstyle is entirely > redundant. You'll observe that font_style_to_value returning >= 0 > indicates that the adstyle is a valid width, and therefore the function > rejects, and does not validate, width values. Thanks. > >> The attribute responsible is FONT_ADSTYLE_INDEX, which is set to > >> "Sans-Serif" by: > >> > >> font. */ > >> FT_Face ft_face; > >> > >> ASET (entity, FONT_ADSTYLE_INDEX, get_adstyle_property (p)); > >> if ((ft_library || FT_Init_FreeType (&ft_library) == 0) > >> > >> in ftfont_pattern_entity. The XLFD generated from a font with such an > >> adstyle is not parsable, the character `-' being the field separator in > >> XLFDs, and gives rise to parser errors such as Rodrigo encountered when > >> I-search, by proxy, attempted to deconstruct the XLFD back into a font > >> spec. > > > > Yes, I understand all that. That was not my question. > > > > So what is the patch you'd propose. > > diff --git a/src/ftfont.c b/src/ftfont.c > index 2e37b62ea35..efb6bf668bb 100644 > --- a/src/ftfont.c > +++ b/src/ftfont.c > @@ -149,7 +149,8 @@ matching_prefix (char const *str, ptrdiff_t len, char const *pat) > get_adstyle_property (FcPattern *p) > { > FcChar8 *fcstr; > - char *str, *end; > + char *str, *end, *tmp; > + size_t i; > Lisp_Object adstyle; > > #ifdef FC_FONTFORMAT > @@ -168,7 +169,18 @@ get_adstyle_property (FcPattern *p) > || matching_prefix (str, end - str, "Oblique") > || matching_prefix (str, end - str, "Italic")) > return Qnil; > - adstyle = font_intern_prop (str, end - str, 1); > + /* The characters `-', `?', `*', and `"' are not representable in XLFDs > + and therefore must be replaced by substitutes. (bug#70989) */ > + USE_SAFE_ALLOCA; > + tmp = SAFE_ALLOCA (end - str); > + for (i = 0; i < end - str; ++i) > + tmp[i] = (str[i] == '-' > + ? '_' : ((str[i] != '?' > + && str[i] != '*' > + && str[i] != '"') > + ? str[i] : ' ')); > + adstyle = font_intern_prop (tmp, end - str, 1); > + SAFE_FREE (); > if (font_style_to_value (FONT_WIDTH_INDEX, adstyle, 0) >= 0) > return Qnil; > return adstyle; Thanks, but why not replace all of those with a SPC? It's simpler, I think.