Class

NSFontDescriptor

A dictionary of attributes that describe a font.

Declaration

@interface NSFontDescriptor : NSObject

Overview

A font descriptor can be used to create or modify an NSFont object. The system provides a font matching capability, so that you can partially describe a font by creating a font descriptor with, for example, just a family name. You can then find all the available fonts on the system with a matching family name using matchingFontDescriptorsWithMandatoryKeys:.

There are several ways to create a new NSFontDescriptor object. You can use alloc and initWithFontAttributes:, fontDescriptorWithFontAttributes:, fontDescriptorWithName:matrix:, or fontDescriptorWithName:size:. to create a font descriptor based on either your custom attributes dictionary or on a specific font’s name and size. Alternatively you can use one of the fontDescriptor… instance methods (such as fontDescriptorWithFace:) to create a modified version of an existing descriptor. The latter methods are useful if you have an existing descriptor and simply want to change one aspect.

All attributes in the attributes dictionary are optional.

Topics

Creating a Font Descriptor

+ fontDescriptorWithFontAttributes:

Returns a font descriptor with a dictionary of attributes.

+ fontDescriptorWithName:matrix:

Returns a font descriptor with the name and matrix attributes set to the given values.

+ fontDescriptorWithName:size:

Returns a font descriptor with the name and size attributes set to the given values.

- initWithFontAttributes:

Initializes and returns a new font descriptor with the specified attributes.

Modifying an Existing Font Descriptor

- fontDescriptorByAddingAttributes:

Returns a new font descriptor based on the current object, but with the specified attributes taking precedence over the existing ones.

- fontDescriptorWithFace:

Returns a new font descriptor based on the current object, but with the specified face.

- fontDescriptorWithFamily:

Returns a new font descriptor based on the current object, but with the specified font family.

- fontDescriptorWithMatrix:

Returns a new font descriptor based on the current object, but with the specified font matrix.

- fontDescriptorWithSize:

Returns a new font descriptor based on the current object, but with the specified point size.

- fontDescriptorWithSymbolicTraits:

Returns a new font descriptor based on the current object, but with the specified symbolic traits taking precedence over the existing ones.

- fontDescriptorWithDesign:

Returns a new font descriptor based on the current object, but with the specified design style.

NSFontDescriptorSystemDesign

Constants for font designs, such as monospace, rounded, and serif.

Finding Fonts

- matchingFontDescriptorsWithMandatoryKeys:

Returns all the fonts available on the system whose specified attributes match those of the receiver.

- matchingFontDescriptorWithMandatoryKeys:

Returns a normalized font descriptor whose specified attributes match those of the receiver.

Getting the Font Attributes

fontAttributes

The receiver’s dictionary of attributes.

- objectForKey:

Returns the font attribute specified by the given key.

NSFontDescriptorAttributeName

Constants for the names of font attributes.

NSFontDescriptorSymbolicTraits

Stylistic aspects of a font.

matrix

The current transform matrix of the receiver.

pointSize

The point size of the receiver.

postscriptName

The PostScript name of the receiver.

NSFontDescriptorFeatureKey

Constants to use as keys to retrieve information about a font descriptor from its feature dictionary.

NSFontFamilyClass

Constants that classify certain stylistic qualities of the font.

NSFontFamilyClassMask

Constant you use to access NSFontFamilyClass values in the upper four bits of NSFontSymbolicTraits.

Typeface Information

Constants for type faces such as italic or bold.

NSFontDescriptorVariationKey

Constants that can be used as keys to retrieve information about a font descriptor from its variation axis dictionary.

Getting the Font Traits

symbolicTraits

A bit mask that describes the traits of the receiver.

NSFontSymbolicTraits

A symbolic description of stylistic aspects of a font.

NSFontDescriptorTraitKey

Constants that can be used as keys to retrieve information about a font descriptor from its trait dictionary.

Requiring Font Assets

Relationships

Inherits From

See Also

Font Data

NSFont

The representation of a font in an app.

NSFontTraitMask

Constants for isolating specific traits of a font.

NSFontFamilyClass

Constants that classify certain stylistic qualities of the font.

NSFontDescriptorSymbolicTraits

Stylistic aspects of a font.

NSFontSymbolicTraits

A symbolic description of stylistic aspects of a font.