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.
This commit is contained in:
parent
788932d9e4
commit
b75e79138c
2 changed files with 37 additions and 2 deletions
5
etc/NEWS
5
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.
|
||||
|
|
34
src/font.c
34
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
|
||||
|
|
Loading…
Add table
Reference in a new issue