The representation of a font in an app.
- macOS 10.0+
NSFont objects represent fonts to an application, providing access to characteristics of the font and assistance in laying out glyphs relative to one another. Font objects are also used to establish the current font for drawing text directly into a graphics context, using the
You don’t create
NSFont objects using the
init methods. Instead, you use either
init(name: to look up an available font and alter its size or matrix to your needs. These methods check for an existing font object with the specified characteristics, returning it if there is one. Otherwise, they look up the font data requested and create the appropriate object.
NSFont also defines a number of methods for getting standard system fonts, such as
message. To request the default size for these standard fonts, pass a negative number or
0 as the font size. See macOS Human Interface Guidelines for more information about system fonts.