Contents

NSFont

The representation of a font in an app.

Declaration

class NSFont

Overview

NSFont objects represent fonts to an app, 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 set() method.

You don’t create NSFont objects using the alloc and init methods. Instead, you use either init(descriptor:size:) or init(name:size:) 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 systemFont(ofSize:), userFont(ofSize:), and messageFont(ofSize:). To request the default size for these standard fonts, pass a negative number or 0 as the font size. For more information on system fonts, see Human Interface Guidelines > Typography.

Topics

Creating Arbitrary Fonts

Creating User Fonts

Creating System Fonts

Creating UI Element Fonts

Using a Font to Draw

Getting Font Metrics and Information

Getting Information About Glyphs

Getting Font Names

Setting User Fonts

Vertical Fonts

Responding to Font-Related Notifications

Deprecated

Type Aliases

Instance Properties

Instance Methods

Type Methods

Initializers

See Also

Font Data