Class

NSFontCollection

A font collection, which is a group of font descriptors taken together as a single object.

Overview

You can publicize the font collection as a named collection and it is presented through the System user interface such as the font panel and Font Book. The queries can be modified using the NSMutableFontCollection subclass.

Topics

Creating Font Collections

init(descriptors: [NSFontDescriptor])

Returns a font collection matching the given descriptors.

class var withAllAvailableDescriptors: NSFontCollection

Returns a font collection matching all registered fonts.

init?(locale: Locale)

Returns a collection of fonts matching the given locale.

Naming Font Collections

class func rename(fromName: NSFontCollection.Name, visibility: NSFontCollection.Visibility, toName: NSFontCollection.Name)

Renames the font collection with the specified name and visibility to the second name specified.

class func hide(withName: NSFontCollection.Name, visibility: NSFontCollection.Visibility)

Remove from view the named font collection with the specified visibility.

class var allFontCollectionNames: [NSFontCollection.Name]

Returns all named collections visible to this process.

init?(name: NSFontCollection.Name)

Returns the font collection with the specified name.

init?(name: NSFontCollection.Name, visibility: NSFontCollection.Visibility)

Returns the font collection with the specified name and visibility.

Font Collection Descriptor Matching

var matchingDescriptors: [NSFontDescriptor]?

An array of font descriptors matching the logical descriptors.

func matchingDescriptors(forFamily: String)

Returns an array of font descriptors matching the logical descriptors for the given font family.

func matchingDescriptors(forFamily: String, options: [NSFontCollectionMatchingOptionKey : NSNumber]? = nil)

Returns an array of font descriptors matching the logical descriptors for the given font family and options.

func matchingDescriptors(options: [NSFontCollectionMatchingOptionKey : NSNumber]? = nil)

Returns an array of font descriptors matching the logical descriptors with the given options.

var queryDescriptors: [NSFontDescriptor]?

An array of font descriptors whose matching results produce the collection’s matching descriptors.

var exclusionDescriptors: [NSFontDescriptor]?

A list of query font descriptors whose matching results are excluded from the list of matching descriptors.

Constants

Standard Named Font Collections

The constants represent the standard mutable collection names—these names are included in the list of allFontCollectionNames--they have special meaning to the Cocoa font system and should not be hidden or renamed.

struct NSFontCollection.Visibility

Constants that specify the visibility of font collections.

NSFontCollectionDidChangeNotification UserInfo Keys

These constants are used as keys in the didChangeNotification userInfo dictionary to indicate the changes that have taken place.

NSFontCollectionAction Key Values

The following actions are possible values of the action in the didChangeNotification userInfo method.

Notifications

class let didChangeNotification: NSNotification.Name

Posted whenever a font collection is changed.

See Also

Management

class NSFontManager

The center of activity for the font conversion system.

class NSMutableFontCollection

A mutable collection of fonts used to create a modifiable version of the NSFontCollection class.

struct NSFontCollectionOptions

Constants that support font collection management.

struct NSFontCollection.Visibility

Constants that specify the visibility of font collections.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software