elisp: Font Lookup
37.12.10 Looking Up Fonts
-------------------------
-- Function: x-list-fonts name &optional reference-face frame maximum
width
This function returns a list of available font names that match
NAME. NAME should be a string containing a font name in either the
Fontconfig, GTK, or XLFD format ((emacs)Fonts). Within an
XLFD string, wildcard characters may be used: the ‘*’ character
matches any substring, and the ‘?’ character matches any single
character. Case is ignored when matching font names.
If the optional arguments REFERENCE-FACE and FRAME are specified,
the returned list includes only fonts that are the same size as
REFERENCE-FACE (a face name) currently is on the frame FRAME.
The optional argument MAXIMUM sets a limit on how many fonts to
return. If it is non-‘nil’, then the return value is truncated
after the first MAXIMUM matching fonts. Specifying a small value
for MAXIMUM can make this function much faster, in cases where many
fonts match the pattern.
The optional argument WIDTH specifies a desired font width. If it
is non-‘nil’, the function only returns those fonts whose
characters are (on average) WIDTH times as wide as REFERENCE-FACE.
-- Function: x-family-fonts &optional family frame
This function returns a list describing the available fonts for
family FAMILY on FRAME. If FAMILY is omitted or ‘nil’, this list
applies to all families, and therefore, it contains all available
fonts. Otherwise, FAMILY must be a string; it may contain the
wildcards ‘?’ and ‘*’.
The list describes the display that FRAME is on; if FRAME is
omitted or ‘nil’, it applies to the selected frame’s display (
Input Focus).
Each element in the list is a vector of the following form:
[FAMILY WIDTH POINT-SIZE WEIGHT SLANT
FIXED-P FULL REGISTRY-AND-ENCODING]
The first five elements correspond to face attributes; if you
specify these attributes for a face, it will use this font.
The last three elements give additional information about the font.
FIXED-P is non-‘nil’ if the font is fixed-pitch. FULL is the full
name of the font, and REGISTRY-AND-ENCODING is a string giving the
registry and encoding of the font.