unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Po Lu <luangruo@yahoo.com>
Cc: 70989@debbugs.gnu.org, me@rodrigomorales.site
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	[thread overview]
Message-ID: <86bk52auyl.fsf@gnu.org> (raw)
In-Reply-To: <87frue6omb.fsf@yahoo.com> (message from Po Lu on Sun, 19 May 2024 19:13:32 +0800)

> From: Po Lu <luangruo@yahoo.com>
> Cc: me@rodrigomorales.site,  70989@debbugs.gnu.org
> Date: Sun, 19 May 2024 19:13:32 +0800
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> >> From: Po Lu <luangruo@yahoo.com>
> >> Cc: me@rodrigomorales.site,  70989@debbugs.gnu.org
> >> Date: Sun, 19 May 2024 15:37:09 +0800
> >> 
> >> Eli Zaretskii <eliz@gnu.org> 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.





  reply	other threads:[~2024-05-19 11:42 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-16 18:39 bug#70989: 29.3; Calling isearch-forward when using Unifont throws error "Invalid font name" Rodrigo Morales
2024-05-16 19:31 ` Eli Zaretskii
2024-05-16 20:09   ` Rodrigo Morales
2024-05-17  6:13     ` Eli Zaretskii
2024-05-17 11:03       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-17 15:14         ` Rodrigo Morales
2024-05-18 12:25           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-18 15:34             ` Eli Zaretskii
2024-05-19  0:15               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-19  6:05                 ` Eli Zaretskii
2024-05-19  7:37                   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-19  7:49                     ` Eli Zaretskii
2024-05-19 11:13                       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-19 11:42                         ` Eli Zaretskii [this message]
2024-05-19 13:00                           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-19 13:19                             ` Eli Zaretskii
2024-05-20 13:03                               ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86bk52auyl.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=70989@debbugs.gnu.org \
    --cc=luangruo@yahoo.com \
    --cc=me@rodrigomorales.site \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).