fontmetrics

The class of fontmetrics objects.
Some functions that return attributes of fonts may be passed the font
object directly, but most of them must instead be passed a fontmetrics
object that reflects the font as it is used on a particular graphical
stream.

A fontmetrics is created by calling either make-fontmetrics or fontmetrics, and is
returned by each of those functions as well as by nfontmetrics. Once a fontmetrics
object is returned by a call to either fontmetrics or nfontmetrics, it holds the values
of various attributes of the current font of the window. Various
accessor functions such as font-leading and font-fixed-width-p can then be
called on the fontmetrics object to obtain information about the font
as used on that stream.

Most of the fontmetrics accessors return the size (in pixels) of
various parts of a character cell, such as font-descent to return the part of
each character cell that is reserved for the parts of characters that
descend below the baseline. These values may be different on
different streams, even for a font of a particular declared pixel size
(see font-size
and make-font-ex). This might even be
true among different kinds of windows on a single screen at a
particular resolution. Therefore, these accessor functions do not
work on a font object by itself, and must instead by passed a
fontmetrics object that reflects the current font of a particular
stream on which it may be used.

Example

In this example, the form will return the internal font leading of the
specified font when it is used on the window "my-window".

Here is an example function that collects all of the attributes of a
font and returns them as a plist. It allows you to pass in the stream
where the font might be used, in case any measurements may differ
based on the stream, and otherwise uses the screen for measurements.
The function illustrates how some font attribute functions must be
passed a fontmetrics object, while others take the font itself.