Function: display-supports-face-attributes-p
display-supports-face-attributes-p is a function defined in xfaces.c.
Signature
(display-supports-face-attributes-p ATTRIBUTES &optional DISPLAY)
Documentation
Return non-nil if all the face attributes in ATTRIBUTES are supported.
The optional argument DISPLAY can be a display name, a frame, or nil (meaning the selected frame's display).
For instance, to check whether the display supports underlining:
(display-supports-face-attributes-p '(:underline t))
The definition of supported is somewhat heuristic, but basically means
that a face containing all the attributes in ATTRIBUTES, when merged
with the default face for display, can be represented in a way that's
(1) different in appearance from the default face, and
(2) close in spirit to what the attributes specify, if not exact.
Point (2) implies that a :weight black attribute will be satisfied by
any display that can display bold, and a :foreground "yellow" as long
as it can display a yellowish color, but :slant italic will _not_ be
satisfied by the tty display code's automatic substitution of a dim
face for italic.
Probably introduced at or before Emacs version 22.1.
Source Code
// Defined in /usr/src/emacs/src/xfaces.c
{
bool supports = false;
int i;
Lisp_Object frame;
struct frame *f;
struct face *def_face;
Lisp_Object attrs[LFACE_VECTOR_SIZE];
if (noninteractive || !initialized)
/* We may not be able to access low-level face information in batch
mode, or before being dumped, and this function is not going to
be very useful in those cases anyway, so just give up. */
return Qnil;
if (NILP (display))
frame = selected_frame;
else if (FRAMEP (display))
frame = display;
else
{
/* Find any frame on DISPLAY. */
Lisp_Object tail;
frame = Qnil;
FOR_EACH_FRAME (tail, frame)
if (!NILP (Fequal (Fcdr (Fassq (Qdisplay,
XFRAME (frame)->param_alist)),
display)))
break;
}
CHECK_LIVE_FRAME (frame);
f = XFRAME (frame);
for (i = 0; i < LFACE_VECTOR_SIZE; i++)
attrs[i] = Qunspecified;
merge_face_ref (NULL, f, attributes, attrs, true, NULL, 0);
def_face = FACE_FROM_ID_OR_NULL (f, DEFAULT_FACE_ID);
if (def_face == NULL)
{
if (! realize_basic_faces (f))
error ("Cannot realize default face");
def_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
}
/* Dispatch to the appropriate handler. */
if (FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f))
supports = tty_supports_face_attributes_p (f, attrs, def_face);
#ifdef HAVE_WINDOW_SYSTEM
else
supports = gui_supports_face_attributes_p (f, attrs, def_face);
#endif
return supports ? Qt : Qnil;
}