From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" 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 19:13:32 +0800 Message-ID: <87frue6omb.fsf@yahoo.com> 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> Reply-To: Po Lu Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7348"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 70989@debbugs.gnu.org, me@rodrigomorales.site To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 19 13:15:25 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 1s8eVg-0001hX-3w for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 19 May 2024 13:15:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s8eVI-000584-1J; Sun, 19 May 2024 07:15:00 -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 1s8eVG-00057Q-Fs for bug-gnu-emacs@gnu.org; Sun, 19 May 2024 07:14:58 -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 1s8eVG-0004ks-89 for bug-gnu-emacs@gnu.org; Sun, 19 May 2024 07:14:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s8eVK-0004Lr-4G for bug-gnu-emacs@gnu.org; Sun, 19 May 2024 07:15:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 19 May 2024 11:15: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.171611725816693 (code B ref 70989); Sun, 19 May 2024 11:15:02 +0000 Original-Received: (at 70989) by debbugs.gnu.org; 19 May 2024 11:14:18 +0000 Original-Received: from localhost ([127.0.0.1]:35961 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s8eUb-0004LA-TL for submit@debbugs.gnu.org; Sun, 19 May 2024 07:14:18 -0400 Original-Received: from sonic308-56.consmr.mail.ne1.yahoo.com ([66.163.187.31]:37782) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s8eUZ-0004L4-TO for 70989@debbugs.gnu.org; Sun, 19 May 2024 07:14:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1716117245; bh=R6GK5Hlvnb7yDIlJ5CMUllhsjUe3yordLuryMPAkmCE=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=t0F6it2lAq9JKrFQ79nQH33WXiFvsIqIfzvSbAXQKNzZt6xCSpY6BRBwN1bWND9Ul3ItRoTWiqb6mIm7fIydX+TsK9LIUCgxPV1G6+ryCI7EIRCa6YnwxzAvwGB5M73S+moyYx/Gji7UVCZsOZ46g9vszcL7/8vLEcUWpxQy5M/IWwMshIGjQWz8wrVnAZNmVZ3KyhnA7YHK7wbc+W1trrFTb6vkaWPOYrLfe1La1QxSN+510xhGM5bpL+YYMmvQa8g+G+vDOtqGbo9BWr0kysoazRnbliqhbLdDnG4WeWhWqPpd/n1z7q+3ggXwY8cSE0XP7hdSES671OhptxGoow== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1716117245; bh=oOQ0dXXNadouvp2kxM2Z8NF49fwr16C7ydHzE9zSg8W=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=rwUFl52gSsdlks3lGarRh+e2idhsOj65IkNO/DhABodHB3qLC1Psr09BJfvkq7jYv/VLOPnDtZm/iIbTQUJoznGhKKsqctowOdUsJybh1MJsJ/S3ZymrxupbqoyBm9EmrGWQ8hZMeHvLbrg3swjeuTHCNyqLOmD8Q96VxLgcrjo6jxUt5XlV2VXuzvIHLPW4s7qHz/xzDsswB1wQxnt5glhJOx/VOGyh6JHZg4j+NyZredXgbU7CeT6DwVKAhMWIE8nLT77JiRUuHreYR6lisCWFC3DISM0nMYqPBjFOhDgZh82WuETXamRYVUVgV52idFPCeqe3bmLkmt03PE2Wuw== X-YMail-OSG: hpwGKwUVM1mj9qoVh25eyn8HYIbXJUfl1khsZLeKd1Y4eqfZU8fpxBDRYyUlDza qloBDzvDP9ojTNjrKWPdEycWiLOXIp.qmYCjSBac8ztN934iKp68l8sWdxmgjaZORf3rWCWRaQ8K xLmwbaFvifzB.eMUHTew9BOIO.cH6HXu2xpN1b26yXGzm8dF2QcxFF61oUnkWJs9UB8A2Wr2FwpQ depGnq.wrOJOY0TKIKVL7xsrDXYZGIRKtUOas7ImwkQwsoZ578ASg4GrWU4QvmU7MtaGuu.HIyag 3vG7rKjJj9SkFpXaIpCftO4bLz1ZgcPv6Mo8TbZfO5bRF27xD6UezImAu0LgctcD_1U3I4QR5e.v CqtJkkdFnSZHX5KiEls9l7JQiLpU5odoGAom3z837JRafh91ZiasMIbXv7CFovjs6Y0yQbq9Llrm wC911bw9w0E.2pDJ2uwRK5p54cMEZfyU9Pyyr8_RsEF.xo6ON18oe.qKEYSjtstnejVyQ0ZGIegW AAs5HD_eWmffBe3dMQcwmlco.didihVt88PHlODfGXgqffCX1kr.tIXXKke4INYQa8ZGT1h0tPY9 mRAQOroHOOTwL4uAJUiQmx.sQ8cttOf7cPtsakUGEd2sd6hAs5Sg91__YRMk4YmskbjI58hMcanu QFpq1j77T4REtu2AEXT66FMnW5wjj_i4ls229o2MJb4S5EEqhTbnfrm5Wrhvi2bE1KMVMh.OHIM4 wsfLWfFy9V1_Jt_raQzhsRisnud3uaUFz.VUT0Il29u4p6rLdXOLsaaXdr2bg0xNMTXlb7kZZVqM Rybzsm6Kr7EQZxpiNFDYi8xIMHwTsYWOJly4i8S0p4 X-Sonic-MF: X-Sonic-ID: ee3ef9da-8b82-4aea-ba33-045a351eb175 Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic308.consmr.mail.ne1.yahoo.com with HTTP; Sun, 19 May 2024 11:14:05 +0000 Original-Received: by hermes--production-sg3-6f9f87bd85-fwdz2 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 8b51ce678ac1df1e3a71dd3262bcd0fa; Sun, 19 May 2024 11:13:58 +0000 (UTC) In-Reply-To: <86o792b5qx.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 19 May 2024 10:49:58 +0300") X-Mailer: WebService/1.1.22356 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo 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:285422 Archived-At: 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. >> 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;