NSFontCollection Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in OS X v10.7 and later. |
| Declared in | NSFontCollection.h |
Overview
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.
Tasks
Creating Font Collections
-
+ fontCollectionWithDescriptors: -
+ fontCollectionWithAllAvailableDescriptors -
+ fontCollectionWithLocale:
Naming Font Collections
-
+ renameFontCollectionWithName:visibility:toName:error: -
+ showFontCollection:withName:visibility:error: -
+ hideFontCollectionWithName:visibility:error: -
+ allFontCollectionNames -
+ fontCollectionWithName: -
+ fontCollectionWithName:visibility:
Font Collection Descriptor Matching
Class Methods
allFontCollectionNames
Returns all named collections visible to this process.
Return Value
NSString objects containing the names of all the named collections.
Availability
- Available in OS X v10.7 and later.
Declared In
NSFontCollection.hfontCollectionWithAllAvailableDescriptors
Returns a font collection matching all registered fonts.
Return Value
The collection of all fonts available to the current application.
Availability
- Available in OS X v10.7 and later.
Declared In
NSFontCollection.hfontCollectionWithDescriptors:
Returns a font collection matching the given descriptors.
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.
Declared In
NSFontCollection.hfontCollectionWithLocale:
Returns a collection of fonts matching the given 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.
Declared In
NSFontCollection.hfontCollectionWithName:
Returns the font collection with the specified name.
Parameters
- name
The name of the collection.
Return Value
The named font collection.
Availability
- Available in OS X v10.7 and later.
Declared In
NSFontCollection.hfontCollectionWithName:visibility:
Returns the font collection with the specified name and visibility.
Parameters
- name
The name of the collection.
- visibility
The visibility of the collection.
Return Value
The font collection with the specified nam and visibility.
Availability
- Available in OS X v10.7 and later.
Declared In
NSFontCollection.hhideFontCollectionWithName:visibility:error:
Remove from view the named font collection with the specified visibility.
Parameters
- name
The name of the collection.
- visibility
The visibility of the collection.
- error
If unsuccessful, a reference to an
NSFileManagererror object that encapsulates the reason the font collection could not be returned.
Return Value
YES if the method was successful; NO otherwise.
Discussion
For a persistent font collection, this method deletes the named font collection from disk.
Availability
- Available in OS X v10.7 and later.
Declared In
NSFontCollection.hrenameFontCollectionWithName:visibility:toName:error:
Renames the font collection with the specified name and visibility to the second name specified.
Parameters
- name
The collection to rename.
- visibility
The visibility of the collection to rename.
- name
The new name to give to the collection.
- error
If unsuccessful, a reference to an
NSFileManagererror object that encapsulates the reason the font collection could not be renamed.
Return Value
YES if the method was successful; NO otherwise.
Discussion
Named collections are shown by user interfaces such as the Font panel. When you change the collection, you must show it again to see the changes reflected on disk or in the Font panel.
Availability
- Available in OS X v10.7 and later.
Declared In
NSFontCollection.hshowFontCollection:withName:visibility:error:
Make the given font collection visible by giving it a name.
Parameters
- collection
The font collection to make visible.
- name
The name to associate with the collection.
- visibility
The visibility of the collection to show.
- error
If unsuccessful, a reference to an
NSFileManagererror object that encapsulates the reason the font collection could not be renamed.
Return Value
YES if the method was successful; NO otherwise.
Discussion
Named collections are shown by user interfaces such as the Font panel. When you change the collection, you must show it again to see the changes reflected on disk or in the Font panel.
Availability
- Available in OS X v10.7 and later.
Declared In
NSFontCollection.hInstance Methods
exclusionDescriptors
Returns a list of query font descriptors whose matching results are excluded from the list of matching descriptors.
Return Value
The font descriptors used to match for exclusion descriptors.
Availability
- Available in OS X v10.7 and later.
Declared In
NSFontCollection.hmatchingDescriptors
Returns an array of font descriptors matching the logical descriptors.
Return Value
The font descriptors matching queryDescriptors minus those matching exclusionDescriptors.
Availability
- Available in OS X v10.7 and later.
Declared In
NSFontCollection.hmatchingDescriptorsForFamily:
Returns an array of font descriptors matching the logical descriptors for the given font family.
Parameters
- family
The font family whose descriptors are matched.
Return Value
The matchingDescriptors for the given family.
Availability
- Available in OS X v10.7 and later.
Declared In
NSFontCollection.hmatchingDescriptorsForFamily:options:
Returns an array of font descriptors matching the logical descriptors for the given font family and options.
Parameters
- family
The font family whose descriptors are matched.
- options
A dictionary containing any combination of the “Matching Descriptors Options” keys or
nil.
Return Value
The matchingDescriptors for the given family and options.
Availability
- Available in OS X v10.7 and later.
Declared In
NSFontCollection.hmatchingDescriptorsWithOptions:
Returns an array of font descriptors matching the logical descriptors with the given options.
Parameters
- options
A dictionary containing any combination of the “Matching Descriptors Options” keys or
nil.
Return Value
The matchingDescriptors for the given options.
Availability
- Available in OS X v10.7 and later.
Declared In
NSFontCollection.hqueryDescriptors
Returns an array of font descriptors whose matching results produce the collection’s matching descriptors.
Return Value
The font descriptors matched at runtime to produce matchingDescriptors.
Discussion
The font descriptors matching exclusionDescriptors are removed from matchingDescriptors.
Availability
- Available in OS X v10.7 and later.
Declared In
NSFontCollection.hConstants
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.
NSString * const NSFontCollectionAllFonts; NSString * const NSFontCollectionUser; NSString * const NSFontCollectionFavorites; NSString * const NSFontCollectionRecentlyUsed;
Constants
NSFontCollectionAllFontsAll fonts in the system.
Available in OS X v10.7 and later.
Declared in
NSFontCollection.h.NSFontCollectionUserPer-user unmodifiable collection.
Available in OS X v10.7 and later.
Declared in
NSFontCollection.h.NSFontCollectionFavoritesFont collection of the user's preferred font descriptors.
Available in OS X v10.7 and later.
Declared in
NSFontCollection.h.NSFontCollectionRecentlyUsedFont collection automatically maintained by NSFontManager.
Available in OS X v10.7 and later.
Declared in
NSFontCollection.h.
Matching Descriptors Options
These constants are used by the matchingDescriptorsWithOptions: and matchingDescriptorsForFamily:options: options dictionary parameters.
NSString * const NSFontCollectionIncludeDisabledFontsOption; NSString * const NSFontCollectionRemoveDuplicatesOption; NSString * const NSFontCollectionDisallowAutoActivationOption;
Constants
NSFontCollectionIncludeDisabledFontsOptionAn NSNumber object containing a Boolean value specifying whether disabled fonts should be included in the list of matching descriptors;
YESif they should be included,NOotherwise.. When unspecified, CoreText assumesNO. This option is intended only for font management applications. This option will make descriptor matching slower.Available in OS X v10.7 and later.
Declared in
NSFontCollection.h.NSFontCollectionRemoveDuplicatesOptionAn 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.
Declared in
NSFontCollection.h.NSFontCollectionDisallowAutoActivationOptionAn 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.
Declared in
NSFontCollection.h.
NSFontCollectionVisibility
These constants specify the visibility of font collections.
enum {
NSFontCollectionVisibilityProcess = (1UL << 0),
NSFontCollectionVisibilityUser = (1UL << 1),
NSFontCollectionVisibilityComputer = (1UL << 2)
};
typedef NSUInteger NSFontCollectionVisibility;
Constants
NSFontCollectionVisibilityProcessThe font collection is visible within this process and is not persistent.
Available in OS X v10.7 and later.
Declared in
NSFontCollection.h.NSFontCollectionVisibilityUserThe font collection is visible to all processes and is stored persistently.
Available in OS X v10.7 and later.
Declared in
NSFontCollection.h.NSFontCollectionVisibilityComputerThe font collection is visible to all users and is stored persistently.
Available in OS X v10.7 and later.
Declared in
NSFontCollection.h.
NSFontCollectionDidChangeNotification UserInfo Keys
These constants are used as keys in the NSFontCollectionDidChangeNotification userInfo dictionary to indicate the changes that have taken place.
NSString * const NSFontCollectionActionKey; NSString * const NSFontCollectionNameKey; NSString * const NSFontCollectionOldNameKey; NSString * const NSFontCollectionVisibilityKey;
Constants
NSFontCollectionActionKeyAn action was taken. See “NSFontCollectionAction Key Values” for the possible values. An
NSString.Available in OS X v10.7 and later.
Declared in
NSFontCollection.h.NSFontCollectionNameKeyThe font collection’s name. If renamed, this is the new name. An
NSString.Available in OS X v10.7 and later.
Declared in
NSFontCollection.h.NSFontCollectionOldNameKeyIncluded as a value for the
NSFontCollectionOldNameKeykey, if present. This is the previous name. AnNSString.Available in OS X v10.7 and later.
Declared in
NSFontCollection.h.NSFontCollectionVisibilityKeyThe visibly of the font collection. An NSNumber containing a value from the “NSFontCollectionVisibility” enum.
Available in OS X v10.7 and later.
Declared in
NSFontCollection.h.
NSFontCollectionAction Key Values
The following actions are possible values of the NSFontCollectionActionKey in the NSFontCollectionDidChangeNotification userInfo method.
NSString * const NSFontCollectionWasShown; NSString * const NSFontCollectionWasHidden; NSString * const NSFontCollectionWasRenamed;
Constants
NSFontCollectionWasShownThe font collection was shown.
Available in OS X v10.7 and later.
Declared in
NSFontCollection.h.NSFontCollectionWasHiddenThe font collection was hidden.
Available in OS X v10.7 and later.
Declared in
NSFontCollection.h.NSFontCollectionWasRenamedThe font collection was renamed.
Available in OS X v10.7 and later.
Declared in
NSFontCollection.h.
Notifications
NSFontCollectionDidChangeNotification
The notification's object is the font collection that was affected. The notification's userInfo dictionary contains information about the the collection change containing the keys defined in “NSFontCollectionDidChangeNotification UserInfo Keys” and the corresponding values.
Availability
- Available in OS X v10.7 and later.
Declared In
NSFontCollection.h© 2011 Apple Inc. All Rights Reserved. (Last updated: 2011-07-02)