emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Entering emojis


From: Eli Zaretskii
Subject: Re: Entering emojis
Date: Sat, 30 Oct 2021 09:08:45 +0300

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: stefankangas@gmail.com,  emacs-devel@gnu.org
> Date: Fri, 29 Oct 2021 23:21:28 +0200
> 
> Lars Ingebrigtsen <larsi@gnus.org> writes:
> 
> > Should I fix this up and document it?  It's perhaps not an ideal
> > interface...
> 
> To put it mildly.  So here's a new function that has one clear purpose:
> 
> diff --git a/src/font.c b/src/font.c
> index 5e761abc5e..1bde062e87 100644
> --- a/src/font.c
> +++ b/src/font.c
> @@ -4977,6 +4977,21 @@ DEFUN ("query-font", Fquery_font, Squery_font, 1, 1, 0,
>                : Qnil));
>  }
>  
> +DEFUN ("font-has-glyph-p", Ffont_has_glyph_p, Sfont_has_glyph_p, 2, 2, 0,

Please call this font-has-char, since that's what it tests.

> +       doc:
> +       /* Say whether FONT has a glyph for CHAR.  */)

Not FONT, FONT-OBJECT.  They are different beasts.

> +  (Lisp_Object font_object, Lisp_Object character)
> +{
> +  struct font *font = CHECK_FONT_GET_OBJECT (font_object);
> +  CHECK_CHARACTER (character);
> +
> +  int c = XFIXNAT (character);
> +  if (font->driver->encode_char (font, c) == FONT_INVALID_CODE)
> +    return Qnil;
> +  else
> +    return Qt;
> +}

Some font backends have a has_char method, which should be used if
available in preference to encode_char.  So I think a better
implementation for this is to call font_has_char (in which case
FONT-OBJECT could also be a font-entity, something that could be
useful in some cases).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]