Class

NSFontCollection

The NSFontCollection class represents a font collection, that is, a group of font descriptors taken together as a single object. You can publicize the font collection as a named collection and it is presented through the System user interface such as the font panel & Font Book. The queries can be modifed using the NSMutableFontCollection subclass.

Symbols

Creating Font Collections

init(descriptors: [NSFontDescriptor])

Returns a font collection matching the given descriptors.

class func withAllAvailableDescriptors()

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: String, visibility: NSFontCollectionVisibility, toName: String)

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

class func hide(withName: String, visibility: NSFontCollectionVisibility)

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

class func allFontCollectionNames()

Returns all named collections visible to this process.

init?(name: String)

Returns the font collection with the specified name.

init?(name: String, visibility: NSFontCollectionVisibility)

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: [String : NSNumber]? = nil)

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

func matchingDescriptors(options: [String : 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.

Matching Descriptors Options

These constants are used by the matchingDescriptors(options:) and matchingDescriptors(forFamily:options:) options dictionary parameters.

NSFontCollectionVisibility

These constants specify the visibility of font collections.

NSFontCollectionDidChangeNotification UserInfo Keys

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

NSFontCollectionAction Key Values

The following actions are possible values of the NSFontCollectionActionKey in the NSFontCollectionDidChange userInfo method.

Notifications

static let NSFontCollectionDidChange: NSNotification.Name

Posted whenever a font collection is changed.