aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Ingebrigtsen2021-10-31 16:58:16 +0100
committerLars Ingebrigtsen2021-10-31 16:58:16 +0100
commitb75e79138cbafd804f83bcea96c0754f468a8075 (patch)
treeff4b526b4681fc3d008452caed7ad240227580eb /src
parent788932d9e4c015d1f3b1384a310f6001223d6e9b (diff)
downloademacs-b75e79138cbafd804f83bcea96c0754f468a8075.tar.gz
emacs-b75e79138cbafd804f83bcea96c0754f468a8075.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/font.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/font.c b/src/font.c
index 5e761abc5e6..089622c172b 100644
--- a/src/font.c
+++ b/src/font.c
@@ -4977,6 +4977,30 @@ If the font is not OpenType font, CAPABILITY is nil. */)
4977 : Qnil)); 4977 : Qnil));
4978} 4978}
4979 4979
4980DEFUN ("font-has-char-p", Ffont_has_char_p, Sfont_has_char_p, 2, 3, 0,
4981 doc:
4982 /* Say whether FONT-OBJECT has a glyph for CHAR.
4983If the optional FRAME parameter is nil, the selected frame is used. */)
4984 (Lisp_Object font_object, Lisp_Object character, Lisp_Object frame)
4985{
4986 struct frame* f;
4987 CHECK_FONT (font_object);
4988 CHECK_CHARACTER (character);
4989
4990 if (NILP (frame))
4991 f = XFRAME (selected_frame);
4992 else
4993 {
4994 CHECK_FRAME (frame);
4995 f = XFRAME (frame);
4996 }
4997
4998 if (font_has_char (f, font_object, XFIXNAT (character)) <= 0)
4999 return Qnil;
5000 else
5001 return Qt;
5002}
5003
4980DEFUN ("font-get-glyphs", Ffont_get_glyphs, Sfont_get_glyphs, 3, 4, 0, 5004DEFUN ("font-get-glyphs", Ffont_get_glyphs, Sfont_get_glyphs, 3, 4, 0,
4981 doc: 5005 doc:
4982 /* Return a vector of FONT-OBJECT's glyphs for the specified characters. 5006 /* Return a vector of FONT-OBJECT's glyphs for the specified characters.
@@ -4995,8 +5019,13 @@ where
4995 CODE is the glyph-code of C in FONT-OBJECT. 5019 CODE is the glyph-code of C in FONT-OBJECT.
4996 WIDTH thru DESCENT are the metrics (in pixels) of the glyph. 5020 WIDTH thru DESCENT are the metrics (in pixels) of the glyph.
4997 ADJUSTMENT is always nil. 5021 ADJUSTMENT is always nil.
4998If FONT-OBJECT doesn't have a glyph for a character, 5022
4999the corresponding element is nil. */) 5023If FONT-OBJECT doesn't have a glyph for a character, the corresponding
5024element is nil.
5025
5026Also see `font-has-char-p', which is more efficient than this function
5027if you just want to check whether FONT-OBJECT has a glyph for a
5028character. */)
5000 (Lisp_Object font_object, Lisp_Object from, Lisp_Object to, 5029 (Lisp_Object font_object, Lisp_Object from, Lisp_Object to,
5001 Lisp_Object object) 5030 Lisp_Object object)
5002{ 5031{
@@ -5548,6 +5577,7 @@ syms_of_font (void)
5548 defsubr (&Sclose_font); 5577 defsubr (&Sclose_font);
5549 defsubr (&Squery_font); 5578 defsubr (&Squery_font);
5550 defsubr (&Sfont_get_glyphs); 5579 defsubr (&Sfont_get_glyphs);
5580 defsubr (&Sfont_has_char_p);
5551 defsubr (&Sfont_match_p); 5581 defsubr (&Sfont_match_p);
5552 defsubr (&Sfont_at); 5582 defsubr (&Sfont_at);
5553#if 0 5583#if 0