[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master b75e791: Add new function 'font-has-char-p'
From: |
Lars Ingebrigtsen |
Subject: |
master b75e791: Add new function 'font-has-char-p' |
Date: |
Sun, 31 Oct 2021 11:58:25 -0400 (EDT) |
branch: master
commit b75e79138cbafd804f83bcea96c0754f468a8075
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Add new function 'font-has-char-p'
* src/font.c (Ffont_has_char_p): New function.
(Ffont_get_glyphs): Link to the new function from the doc string.
---
etc/NEWS | 5 +++++
src/font.c | 34 ++++++++++++++++++++++++++++++++--
2 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 3e26a01..546f8d1 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -341,6 +341,11 @@ Use 'exif-parse-file' and 'exif-field' instead.
* Lisp Changes in Emacs 29.1
+---
+*** New function 'font-has-char-p'.
+This can be used to check whether a specific font has a glyph for a
+character.
+
** XDG support
*** New function 'xdg-state-home' returns $XDG_STATE_HOME.
diff --git a/src/font.c b/src/font.c
index 5e761ab..089622c 100644
--- a/src/font.c
+++ b/src/font.c
@@ -4977,6 +4977,30 @@ If the font is not OpenType font, CAPABILITY is nil. */)
: Qnil));
}
+DEFUN ("font-has-char-p", Ffont_has_char_p, Sfont_has_char_p, 2, 3, 0,
+ doc:
+ /* Say whether FONT-OBJECT has a glyph for CHAR.
+If the optional FRAME parameter is nil, the selected frame is used. */)
+ (Lisp_Object font_object, Lisp_Object character, Lisp_Object frame)
+{
+ struct frame* f;
+ CHECK_FONT (font_object);
+ CHECK_CHARACTER (character);
+
+ if (NILP (frame))
+ f = XFRAME (selected_frame);
+ else
+ {
+ CHECK_FRAME (frame);
+ f = XFRAME (frame);
+ }
+
+ if (font_has_char (f, font_object, XFIXNAT (character)) <= 0)
+ return Qnil;
+ else
+ return Qt;
+}
+
DEFUN ("font-get-glyphs", Ffont_get_glyphs, Sfont_get_glyphs, 3, 4, 0,
doc:
/* Return a vector of FONT-OBJECT's glyphs for the specified characters.
@@ -4995,8 +5019,13 @@ where
CODE is the glyph-code of C in FONT-OBJECT.
WIDTH thru DESCENT are the metrics (in pixels) of the glyph.
ADJUSTMENT is always nil.
-If FONT-OBJECT doesn't have a glyph for a character,
-the corresponding element is nil. */)
+
+If FONT-OBJECT doesn't have a glyph for a character, the corresponding
+element is nil.
+
+Also see `font-has-char-p', which is more efficient than this function
+if you just want to check whether FONT-OBJECT has a glyph for a
+character. */)
(Lisp_Object font_object, Lisp_Object from, Lisp_Object to,
Lisp_Object object)
{
@@ -5548,6 +5577,7 @@ syms_of_font (void)
defsubr (&Sclose_font);
defsubr (&Squery_font);
defsubr (&Sfont_get_glyphs);
+ defsubr (&Sfont_has_char_p);
defsubr (&Sfont_match_p);
defsubr (&Sfont_at);
#if 0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master b75e791: Add new function 'font-has-char-p',
Lars Ingebrigtsen <=