Class

UIFontDescriptor

Describes a font with a dictionary of attributes.

Declaration

@interface UIFontDescriptor : NSObject

Overview

A font descriptor can be used to create or modify a UIFont object. Font descriptors have 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 use matchingFontDescriptorsWithMandatoryKeys: to find all the available fonts in the system with a matching family name. Font descriptors can also be archived and unarchived.

There are several ways to create a new UIFontDescriptor object. To take advantage of text styles and respect the user’s current content size category, use preferredFontDescriptorWithTextStyle:. You can also use alloc and initWithFontAttributes:, fontDescriptorWithFontAttributes:, fontDescriptorWithName:matrix:, or fontDescriptorWithName:size: to create a font descriptor based on 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

+ preferredFontDescriptorWithTextStyle:

Returns a font descriptor containing the given text style and the user's selected content size category.

+ preferredFontDescriptorWithTextStyle:compatibleWithTraitCollection:

Returns a font descriptor containing the text style and the content size category specified by the provided trait collection.

+ fontDescriptorWithFontAttributes:

Returns a font descriptor with a dictionary of attributes.

+ fontDescriptorWithName:matrix:

Returns a font descriptor with the UIFontDescriptorNameAttribute and UIFontDescriptorMatrixAttribute dictionary attributes set to the given values.

+ fontDescriptorWithName:size:

Returns a font descriptor with the UIFontDescriptorNameAttribute and UIFontDescriptorSizeAttribute dictionary attributes set to the given values.

- fontDescriptorByAddingAttributes:

Returns a new font descriptor that is the same as the existing descriptor, but with the specified attributes taking precedence over the existing ones.

- fontDescriptorWithDesign:

Returns a new font descriptor that is the same as the existing descriptor, but with the specified design.

- fontDescriptorWithFamily:

Returns a new font descriptor whose attributes are the same as the existing font descriptor, but from the specified family.

- fontDescriptorWithFace:

Returns a new font descriptor that is the same as the existing font descriptor, but with the specified face.

- fontDescriptorWithMatrix:

Returns a new font descriptor that is the same as the existing font descriptor, but with the specified matrix.

- fontDescriptorWithSize:

Returns a new font descriptor that is the same as the existing font descriptor, but with the specified point size.

- fontDescriptorWithSymbolicTraits:

Returns a new font descriptor that is the same as the existing font descriptor, but with the specified symbolic traits.

Initializing a Font Descriptor

- initWithFontAttributes:

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

Finding Fonts

- matchingFontDescriptorsWithMandatoryKeys:

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

Querying a Font Descriptor

fontAttributes

Returns the font descriptor's dictionary of attributes.

matrix

The current transform matrix of the font descriptor.

- objectForKey:

Returns the font attribute specified by the given key.

pointSize

The point size of the font descriptor.

postscriptName

The PostScript name of the font descriptor.

symbolicTraits

A bit mask that describes the traits of the font descriptor.

Constants

UIFontTextStyle

Constants that describe the preferred styles to use for fonts.

UIFontDescriptorSystemDesign

Constants that describe the system-defined typeface designs.

UIFontDescriptorSymbolicTraits

A symbolic description of the stylistic aspects of a font.

UIFontDescriptorClass

UIFontDescriptorClass classifies certain stylistic qualities of the font.

UIFontDescriptorAttributeName

These font attributes are defined by UIFontDescriptor.

UIFontDescriptorFeatureKey

Constants that you use to retrieve feature settings.

UIFontDescriptorTraitKey

Keys that you use to retrieve the font descriptor's trait information.

Font Weights

The following constants represent font weights that can be used as values for UIFontWeightTrait.

Relationships

Inherits From

See Also

Fonts

Scaling Fonts Automatically

Scale text in your interface automatically by using Dynamic Type.

Adding a Custom Font to Your App

Add a custom font to your app and use it in your app’s interface.

UIFont

The interface for getting and setting font information.

UIFontDescriptorSymbolicTraits

A symbolic description of the stylistic aspects of a font.

UIContentSizeCategoryAdjusting

A collection of methods that give controls an easy way to adopt automatic adjustment to content category changes.

UIFontMetrics

A utility object for obtaining custom fonts that scale to support Dynamic Type.