Mac Developer Library

Developer

AppKit Framework Reference NSFontCollection Class Reference

Options
Deployment Target:

On This Page
Language:

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.

  • Returns a font collection matching the given descriptors.

    Declaration

    Swift

    init(descriptors queryDescriptors: [NSFontDescriptor])

    Objective-C

    + (NSFontCollection *)fontCollectionWithDescriptors:(NSArray<NSFontDescriptor *> *)queryDescriptors

    Parameters

    queryDescriptors

    The descriptors used to match the returned collection.

    Return Value

    The font collection matching the given descriptors.

    Availability

    Available in OS X v10.7 and later.

  • Returns a font collection matching all registered fonts.

    Declaration

    Swift

    class func fontCollectionWithAllAvailableDescriptors() -> NSFontCollection

    Objective-C

    + (NSFontCollection *)fontCollectionWithAllAvailableDescriptors

    Return Value

    The collection of all fonts available to the current application.

    Availability

    Available in OS X v10.7 and later.

  • Returns a collection of fonts matching the given locale.

    Declaration

    Swift

    init?(locale locale: NSLocale)

    Objective-C

    + (NSFontCollection *)fontCollectionWithLocale:(NSLocale *)locale

    Parameters

    locale

    The locale to match.

    Return Value

    A collection of fonts matching the given locale.

    Availability

    Available in OS X v10.7 and later.

  • 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.

    Declaration

    Swift

    let NSFontCollectionAllFonts: String let NSFontCollectionUser: String let NSFontCollectionFavorites: String let NSFontCollectionRecentlyUsed: String

    Objective-C

    NSString * const NSFontCollectionAllFonts; NSString * const NSFontCollectionUser; NSString * const NSFontCollectionFavorites; NSString * const NSFontCollectionRecentlyUsed;

    Constants

    • NSFontCollectionAllFonts

      NSFontCollectionAllFonts

      All fonts in the system.

      Available in OS X v10.7 and later.

    • NSFontCollectionUser

      NSFontCollectionUser

      Per-user unmodifiable collection.

      Available in OS X v10.7 and later.

    • NSFontCollectionFavorites

      NSFontCollectionFavorites

      Font collection of the user's preferred font descriptors.

      Available in OS X v10.7 and later.

    • NSFontCollectionRecentlyUsed

      NSFontCollectionRecentlyUsed

      Font collection automatically maintained by NSFontManager.

      Available in OS X v10.7 and later.

  • These constants are used by the matchingDescriptorsWithOptions: and matchingDescriptorsForFamily:options: options dictionary parameters.

    Declaration

    Swift

    let NSFontCollectionIncludeDisabledFontsOption: String let NSFontCollectionRemoveDuplicatesOption: String let NSFontCollectionDisallowAutoActivationOption: String

    Objective-C

    NSString * const NSFontCollectionIncludeDisabledFontsOption; NSString * const NSFontCollectionRemoveDuplicatesOption; NSString * const NSFontCollectionDisallowAutoActivationOption;

    Constants

    • NSFontCollectionIncludeDisabledFontsOption

      NSFontCollectionIncludeDisabledFontsOption

      An NSNumber object containing a Boolean value specifying whether disabled fonts should be included in the list of matching descriptors; YEStrue if they should be included, NOfalse otherwise.. When unspecified, CoreText assumes NOfalse. This option is intended only for font management applications. This option will make descriptor matching slower.

      Available in OS X v10.7 and later.

    • NSFontCollectionRemoveDuplicatesOption

      NSFontCollectionRemoveDuplicatesOption

      An NSNumber object containing a Boolean value controlling whether more than one copy of a font with the same PostScript name should be included in the list of matching descriptors.

      Available in OS X v10.7 and later.

    • NSFontCollectionDisallowAutoActivationOption

      NSFontCollectionDisallowAutoActivationOption

      An NSNumber object containing a Boolean value specifying that auto-activation should not be used to find missing fonts.

      Available in OS X v10.7 and later.

  • These constants specify the visibility of font collections.

    Declaration

    Swift

    struct NSFontCollectionVisibility : OptionSetType { init(rawValue rawValue: UInt) static var Process: NSFontCollectionVisibility { get } static var User: NSFontCollectionVisibility { get } static var Computer: NSFontCollectionVisibility { get } }

    Objective-C

    enum { NSFontCollectionVisibilityProcess = (1UL << 0), NSFontCollectionVisibilityUser = (1UL << 1), NSFontCollectionVisibilityComputer = (1UL << 2) }; typedef NSUInteger NSFontCollectionVisibility;

    Constants

    • Process

      NSFontCollectionVisibilityProcess

      The font collection is visible within this process and is not persistent.

      Available in OS X v10.7 and later.

    • User

      NSFontCollectionVisibilityUser

      The font collection is visible to all processes and is stored persistently.

      Available in OS X v10.7 and later.

    • Computer

      NSFontCollectionVisibilityComputer

      The font collection is visible to all users and is stored persistently.

      Available in OS X v10.7 and later.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    let NSFontCollectionActionKey: String let NSFontCollectionNameKey: String let NSFontCollectionOldNameKey: String let NSFontCollectionVisibilityKey: String

    Objective-C

    NSString * const NSFontCollectionActionKey; NSString * const NSFontCollectionNameKey; NSString * const NSFontCollectionOldNameKey; NSString * const NSFontCollectionVisibilityKey;

    Constants

    • NSFontCollectionActionKey

      NSFontCollectionActionKey

      An action was taken. See NSFontCollectionAction Key Values for the possible values. An NSString.

      Available in OS X v10.7 and later.

    • NSFontCollectionNameKey

      NSFontCollectionNameKey

      The font collection’s name. If renamed, this is the new name. An NSString.

      Available in OS X v10.7 and later.

    • NSFontCollectionOldNameKey

      NSFontCollectionOldNameKey

      Included as a value for the NSFontCollectionOldNameKey key, if present. This is the previous name. An NSString.

      Available in OS X v10.7 and later.

    • NSFontCollectionVisibilityKey

      NSFontCollectionVisibilityKey

      The visibly of the font collection. An NSNumber containing a value from the NSFontCollectionVisibility enum.

      Available in OS X v10.7 and later.

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

    Declaration

    Swift

    let NSFontCollectionWasShown: String let NSFontCollectionWasHidden: String let NSFontCollectionWasRenamed: String

    Objective-C

    NSString * const NSFontCollectionWasShown; NSString * const NSFontCollectionWasHidden; NSString * const NSFontCollectionWasRenamed;

    Constants

    • NSFontCollectionWasShown

      NSFontCollectionWasShown

      The font collection was shown.

      Available in OS X v10.7 and later.

    • NSFontCollectionWasHidden

      NSFontCollectionWasHidden

      The font collection was hidden.

      Available in OS X v10.7 and later.

    • NSFontCollectionWasRenamed

      NSFontCollectionWasRenamed

      The font collection was renamed.

      Available in OS X v10.7 and later.