Next Page > Hide TOC

NSFontManager Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AppKit.framework
Availability
Available in Mac OS X v10.0 and later.
Companion guide
Declared in
NSFontManager.h
Related sample code

Overview

NSFontManager is the center of activity for the font conversion system. It records the currently selected font, updates the Font panel and Font menu to reflect the selected font, initiates font changes, and converts fonts in response to requests from text-bearing objects. In a more prosaic role, NSFontManager can be queried for the fonts available to the application and for the particular attributes of a font, such as whether it’s condensed or extended.

You normally set up a font manager and the Font menu using Interface Builder. However, you can also do so programmatically by getting the shared font manager instance and having it create the standard Font menu at runtime:

NSFontManager *fontManager = [NSFontManager sharedFontManager];
NSMenu *fontMenu = [fontManager fontMenu:YES];

You can then add the Font menu to your application’s main menu. Once the Font menu is installed, your application automatically gains the functionality of both the Font menu and the Font panel.

As of Mac OS X version 10.3, font collections are managed by NSFontManager.

Tasks

Getting the Shared Font Manager

Changing the Default Font Conversion Classes

Getting Available Fonts

Setting and Examining the Selected Font

Sending Action Methods

Converting Fonts Automatically

Converting Fonts Manually

Getting a Particular Font

Examining Fonts

Managing the Font Panel and Font Menu

Setting the Delegate

Accessing the Action Method

Setting Attributes

Working with Font Descriptors

Class Methods

setFontManagerFactory:

Sets the class object used to create the font manager to the given class.

+ (void)setFontManagerFactory:(Class)aClass

Parameters
aClass

The new font manager factory class, which should be a subclass of NSFontManager.

Discussion

When the NSFontManager class object receives a sharedFontManager message, it creates an instance of aClass, if no instance already exists. Your font manager class should implement init as its designated initializer. The default font manager factory is NSFontManager.

This method must be invoked before your application’s main nib file is loaded, such as in the application delegate’s applicationWillFinishLaunching: method.

Availability
See Also
Declared In
NSFontManager.h

setFontPanelFactory:

Sets the class used to create the Font panel to the given class.

+ (void)setFontPanelFactory:(Class)factoryId

Parameters
factoryId

The new font panel factory class, which should be a subclass of NSFontPanel.

Discussion

Invoke this method before accessing the Font panel in any way, such as in the application delegate’s applicationWillFinishLaunching: method.

Availability
See Also
Declared In
NSFontManager.h

sharedFontManager

Returns the shared instance of the font manager for the application, creating it if necessary.

+ (NSFontManager *)sharedFontManager

Return Value

The shared font manager.

Availability
See Also
Related Sample Code
Declared In
NSFontManager.h

Instance Methods

action

Returns the action sent to the first responder when the user selects a new font from the Font panel or chooses a command from the Font menu.

- (SEL)action

Return Value

The selector for the action.

Discussion

The default action is changeFont:.

Availability
See Also
Declared In
NSFontManager.h

addCollection:options:

Adds a specified font collection to the font manager with a given set of options.

- (BOOL)addCollection:(NSString *)collectionName options:(NSInteger)collectionOptions

Parameters
collectionName

The collection to add.

collectionOptions

The option described in “Font Collection Mask”. This option is not yet implemented.

Return Value

YES if the font collection was successfully added; otherwise, NO.

Availability
See Also
Declared In
NSFontManager.h

addFontDescriptors:toCollection:

Adds an array of font descriptors to the specified font collection.

- (void)addFontDescriptors:(NSArray *)descriptors toCollection:(NSString *)collectionName

Parameters
descriptors

The font descriptors to add.

collectionName

The font collection to which descriptors are added.

Availability
See Also
Declared In
NSFontManager.h

addFontTrait:

This action method causes the receiver to send its action message up the responder chain.

- (void)addFontTrait:(id)sender

Parameters
sender

The control that sent the message.

Discussion

By default, the action message is changeFont:.

When a responder replies by providing a font to convert in a convertFont: message, the receiver converts the font by adding the trait specified by sender. This trait is determined by sending a tag message to sender and interpreting it as a font trait mask for a convertFont:toHaveTrait: message.

Availability
See Also
Declared In
NSFontManager.h

availableFontFamilies

Returns the names of the font families available in the system.

- (NSArray *)availableFontFamilies

Return Value

The names of the available font families.

Discussion

These fonts are in various system font directories.

Availability
See Also
Declared In
NSFontManager.h

availableFontNamesMatchingFontDescriptor:

Returns the names of the fonts that match the attributes in the given font descriptor.

- (NSArray *)availableFontNamesMatchingFontDescriptor:(NSFontDescriptor *)descriptor

Parameters
descriptor

The font descriptor whose attributes are matched.

Return Value

The names of the matching fonts.

Availability
Declared In
NSFontManager.h

availableFontNamesWithTraits:

Returns the names of the fonts available in the system whose traits are described exactly by the given font trait mask (not the NSFont objects themselves).

- (NSArray *)availableFontNamesWithTraits:(NSFontTraitMask)fontTraitMask

Parameters
fontTraitMask

The font traits for which to return font names. You specify the desired traits by combining the font trait mask values described in “Constants” using the C bitwise OR operator.

Return Value

The names of the corresponding fonts.

Discussion

These fonts are in various system font directories.

If fontTraitMask is 0, this method returns all fonts that are neither italic nor bold. This result is the same one you’d get if fontTraitMask were NSUnitalicFontMask | NSUnboldFontMask.

Availability
See Also
Declared In
NSFontManager.h

availableFonts

Returns the names of the fonts available in the system (not the NSFont objects themselves).

- (NSArray *)availableFonts

Return Value

The names of the available fonts.

Discussion

These fonts are in various system font directories.

Availability
See Also
Related Sample Code
Declared In
NSFontManager.h

availableMembersOfFontFamily:

Returns an array with one entry for each available member of a font family.

- (NSArray *)availableMembersOfFontFamily:(NSString *)family

Parameters
family

The name of a font family, like one that availableFontFamilies returns.

Return Value

The available members of family. See the following discussion for a specific description.

Discussion

Each entry of the returned NSArray is another NSArray with four members, as follows:

The members of the family are arranged in the font panel order (narrowest to widest, lightest to boldest, plain to italic).

For example, if you call availableMembersOfFontFamily:@"Times", it might return an array like this:

(("Times-Roman", "Roman", 5, 4),
 ("Times-Italic", "Italic", 6, 5),
 ("Times-Bold", "Bold", 9, 2),
 ("Times-BoldItalic", "Bold Italic", 9, 3)
)
Availability
Declared In
NSFontManager.h

collectionNames

Returns the names of the currently loaded font collections.

- (NSArray *)collectionNames

Return Value

The names of the current font collections.

Availability
See Also
Declared In
NSFontManager.h

convertAttributes:

Converts attributes in response to an object initiating an attribute change, typically the Font panel or Font menu.

- (NSDictionary *)convertAttributes:(NSDictionary *)attributes

Parameters
attributes

The current attributes.

Return Value

The converted attributes, or attributes itself if the conversion isn’t possible.

Discussion

Attributes unused by the sender should not be changed or removed.

This method is usually invoked on the sender of changeAttributes:. See NSTextView for more information.

Availability
See Also
Declared In
NSFontManager.h

convertFont:

Converts the given font according to the object that initiated a font change, typically the Font panel or Font menu.

- (NSFont *)convertFont:(NSFont *)aFont

Parameters
aFont

The font to convert.

Return Value

The converted font, or aFont itself if the conversion isn’t possible.

Discussion

This method is invoked in response to an action message such as addFontTrait: or modifyFontViaPanel:. These initiating methods cause the font manager to query the sender for the action to take and the traits to change. See “Converting Fonts Manually” for more information.

Availability
See Also
Declared In
NSFontManager.h

convertFont:toFace:

Returns a font whose traits are as similar as possible to those of the given font except for the typeface, which is changed to the given typeface.

- (NSFont *)convertFont:(NSFont *)aFont toFace:(NSString *)typeface

Parameters
aFont

The font whose traits are matched.

typeface

The new typeface; a fully specified family-face name, such as Helvetica-BoldOblique or Times-Roman.

Return Value

A font with matching traits and the given typeface, or aFont if it can’t be converted.

Discussion

This method attempts to match the weight and posture of aFont as closely as possible. Italic is mapped to Oblique, for example. Weights are mapped based on an approximate numeric scale of 0 to 15.

Availability
See Also
Declared In
NSFontManager.h

convertFont:toFamily:

Returns a font whose traits are as similar as possible to those of the given font except for the font family, which is changed to the given family.

- (NSFont *)convertFont:(NSFont *)aFont toFamily:(NSString *)family

Parameters
aFont

The font whose traits are matched.

family

The new font famliy; a generic font name, such as Helvetica or Times.

Return Value

A font with matching traits and the given family, or aFont if it can’t be converted.

Discussion

This method attempts to match the weight and posture of aFont as closely as possible. Italic is mapped to Oblique, for example. Weights are mapped based on an approximate numeric scale of 0 to 15.

Availability
See Also
Declared In
NSFontManager.h

convertFont:toHaveTrait:

Returns a font whose traits are the same as those of the given font, except that the traits are changed to include the single specified trait.

- (NSFont *)convertFont:(NSFont *)aFont toHaveTrait:(NSFontTraitMask)fontTrait

Parameters
aFont

The font whose traits are matched.

fontTrait

The new trait; may be any one of the traits described in “Constants.” Using NSUnboldFontMask or NSUnitalicFontMask removes the bold or italic trait, respectively.

Return Value

A font with matching traits including the given trait, or aFont if it can’t be converted.

Discussion

Using NSUnboldFontMask or NSUnitalicFontMask removes the bold or italic trait, respectively.

Availability
See Also
Related Sample Code
Declared In
NSFontManager.h

convertFont:toNotHaveTrait:

Returns an NSFont object with the same traits as the given font, except for the traits in the given font trait mask, which are removed.

- (NSFont *)convertFont:(NSFont *)aFont toNotHaveTrait:(NSFontTraitMask)fontTraitMask

Parameters
aFont

The font whose traits are matched.

fontTraitMask

The mask for the traits to remove, created using the C bitwise OR operator to combine the traits described in “Constants.” Using NSUnboldFontMask or NSUnitalicFontMask removes the bold or italic trait, respectively.

Return Value

A font with matching traits minus the given traits, or aFont if it can’t be converted.

Availability
See Also
Related Sample Code
Declared In
NSFontManager.h

convertFont:toSize:

Returns an NSFont object whose traits are the same as those of the given font, except for the size, which is changed to the given size.

- (NSFont *)convertFont:(NSFont *)aFont toSize:(CGFloat)size

Parameters
aFont

The font whose traits are matched.

size

The new font size.

Return Value

A font with matching traits except in the new size, or aFont if it can’t be converted.

Availability
See Also
Related Sample Code
Declared In
NSFontManager.h

convertFontTraits:

Converts font traits to a new traits mask value.

- (NSFontTraitMask)convertFontTraits:(NSFontTraitMask)traits

Parameters
traits

The current font traits.

Return Value

The new traits mask value to be used by convertFont:.

Discussion

This method is intended to be invoked to query the font traits while the action message (usually changeFont:) is being invoked when the current font action is either NSAddTraitFontAction or NSRemoveTraitFontAction.

Availability
Declared In
NSFontManager.h

convertWeight:ofFont:

Returns an NSFont object whose weight is greater or lesser than that of the given font, if possible.

- (NSFont *)convertWeight:(BOOL)increaseFlag ofFont:(NSFont *)aFont

Parameters
increaseFlag

If YES, a heavier font is returned; if it’s NO, a lighter font is returned.

aFont

The font whose weight is increased or decreased.

Return Value

A font with matching traits except for the new weight, or aFont if it can’t be converted.

Discussion

Weights are graded along the following scale. The list on the left gives Apple’s terminology, and the list on the right gives the ISO equivalents. Names on the same line are treated as identical:

Apple Terminology

ISO Equivalent

1. ultralight

2. thin

W1. ultralight

3. light, extralight

W2. extralight

4. book

W3. light

5. regular, plain, display, roman

W4. semilight

6. medium

W5. medium

7. demi, demibold

8. semi, semibold

W6. semibold

9. bold

W7. bold

10. extra, extrabold

W8. extrabold

11. heavy, heavyface

12. black, super

W9. ultrabold

13. ultra, ultrablack, fat

14. extrablack, obese, nord

The NSFontManager implementation of this method refuses to convert a font’s weight if it can’t maintain all other traits, such as italic and condensed. You might wish to override this method to allow a looser interpretation of weight conversion.

Availability
See Also
Declared In
NSFontManager.h

currentFontAction

Returns the current font conversion action.

- (NSFontAction)currentFontAction

Return Value

The current font action used by the convertFont: method.

Discussion

This method is intended to be invoked to query the font conversion action while the action message (usually changeFont:) is being invoked.

Availability
Declared In
NSFontManager.h

delegate

Returns the receiver’s delegate.

- (id)delegate

Return Value

The receiver’s delegate.

Availability
See Also
Declared In
NSFontManager.h

fontDescriptorsInCollection:

Returns an array of the font descriptors in the collection specified by the given collection name.

- (NSArray *)fontDescriptorsInCollection:(NSString *)collectionName

Parameters
collectionName

The font collection for which to return descriptors.

Return Value

The font descriptors.

Availability
See Also
Declared In
NSFontManager.h

fontMenu:

Returns the menu that’s hooked up to the font conversion system, optionally creating it if necessary.

- (NSMenu *)fontMenu:(BOOL)createFlag

Parameters
createFlag

If YES, the menu object is created if necessary; if NO, it is not.

Return Value

The font conversion system menu.

Availability
See Also
Declared In
NSFontManager.h

fontNamed:hasTraits:

Indicates whether the given font has all the specified traits.

- (BOOL)fontNamed:(NSString *)typeface hasTraits:(NSFontTraitMask)fontTraitMask

Parameters
typeface

The name of the font.

fontTraitMask

The font traits to test, specified by combining the font trait mask values described in “Constants” using the C bitwise OR operator.

Return Value

YES if the font named typeface has all the traits specified in fontTraitMask; NO if it doesn’t.

Discussion

Using NSUnboldFontMask returns YES if the font is not bold, NO otherwise. Using NSUnitalicFontMask returns YES if the font is not italic, NO otherwise.

Availability
Declared In
NSFontManager.h

fontPanel:

Returns the application’s shared Font panel object, optionally creating it if necessary.

- (NSFontPanel *)fontPanel:(BOOL)createFlag

Parameters
createFlag

If YES, the Font panel object is created if necessary; if NO, it is not.

Return Value

The application’s shared Font panel object.

Availability
See Also
Declared In
NSFontManager.h

fontWithFamily:traits:weight:size:

Attempts to load a font with the specified characteristics.

- (NSFont *)fontWithFamily:(NSString *)family traits:(NSFontTraitMask)fontTraitMask weight:(NSInteger)weight size:(CGFloat)size

Parameters
family

The generic name of the desired font, such as Times or Helvetica.

fontTraitMask

The font traits, specified by combining the font trait mask values described in “Constants” using the C bitwise OR operator. Using NSUnboldFontMask or NSUnitalicFontMask loads a font that doesn’t have either the bold or italic trait, respectively.

weight

A hint for the weight desired, on a scale of 0 to 15: a value of 5 indicates a normal or book weight, and 9 or more a bold or heavier weight. The weight is ignored if fontTraitMask includes NSBoldFontMask.

size

The point size of the desired font.

Return Value

A font with the specified characteristics if successful, or nil if not.

Availability
Declared In
NSFontManager.h

isEnabled

Indicates whether the font conversion system’s user interface items (the Font panel and Font menu items) are enabled.

- (BOOL)isEnabled

Return Value

YES if the font conversion system’s user interface items (the Font panel and Font menu items) are enabled; NO if they’re not.

Availability
See Also
Declared In
NSFontManager.h

isMultiple

Indicates whether the last font selection recorded has multiple fonts.

- (BOOL)isMultiple

Return Value

YES if the last font selection recorded has multiple fonts; NO if it’s a single font.

Availability
See Also
Declared In
NSFontManager.h

localizedNameForFamily:face:

Returns a localized string with the name of the specified font family and face, if one exists.

- (NSString *)localizedNameForFamily:(NSString *)family face:(NSString *)face

Parameters
family

The font family, for example, @"Times".

face

The font face, for example, @"Roman".

Return Value

A localized string with the name of the specified font family and face, or, if face is nil, the font family only.

Discussion

The user’s locale is determined from the user’s NSLanguages default setting. The method also loads the localized strings for the font, if they aren’t already loaded.

Availability
Declared In
NSFontManager.h

modifyFont:

This action method causes the receiver to send its action message up the responder chain.

- (void)modifyFont:(id)sender

Parameters
sender

The control that sent the message.

Discussion

By default, the action message is changeFont:.

When a responder replies by providing a font to convert in a convertFont: message, the receiver converts the font in the manner specified by sender. The conversion is determined by sending a tag message to sender and invoking a corresponding method:

Sender’s Tag

Method Used

NSNoFontChangeAction

None; the font is returned unchanged.

NSViaPanelFontAction

The Font panel’s panelConvertFont:.

NSAddTraitFontAction

convertFont:toHaveTrait:.

NSRemoveTraitFontAction

convertFont:toNotHaveTrait:.

NSSizeUpFontAction

convertFont:toSize:.

NSSizeDownFontAction

convertFont:toSize:.

NSHeavierFontAction

convertWeight:ofFont:.

NSLighterFontAction

convertWeight:ofFont:.

Availability
See Also
Declared In
NSFontManager.h

modifyFontViaPanel:

This action method causes the receiver to send its action message up the responder chain.

- (void)modifyFontViaPanel:(id)sender

Parameters
sender

The control that sent the message.

Discussion

By default, the action message is changeFont:.

When a responder replies by providing a font to convert in a convertFont: message, the receiver converts the font by sending a panelConvertFont: message to the Font panel. The panel in turn may send convertFont:toFamily:, convertFont:toHaveTrait:, and other specific conversion methods to make its change.

Availability
See Also
Declared In
NSFontManager.h

orderFrontFontPanel:

This action method opens the Font panel by sending it an orderFront: message, creating the Font panel if necessary.

- (void)orderFrontFontPanel:(id)sender

Parameters
sender

The control that sent the message.

Availability
See Also
Related Sample Code
Declared In
NSFontManager.h

orderFrontStylesPanel:

This action method opens the Font styles panel.

- (void)orderFrontStylesPanel:(id)sender

Parameters
sender

The control that sent the message.

Availability
Declared In
NSFontManager.h

removeCollection:

Removes the specified font collection.

- (BOOL)removeCollection:(NSString *)collectionName

Parameters
collectionName

The collection to remove.

Return Value

YES if the font collection was successfully removed; otherwise, NO.

Availability
See Also
Declared In
NSFontManager.h

removeFontDescriptor:fromCollection:

Removes the specified font descriptor from the specified collection.

- (void)removeFontDescriptor:(NSFontDescriptor *)descriptor fromCollection:(NSString *)collection

Parameters
descriptor

The font descriptor to remove.

collection

The font collection from which to remove the descriptor.

Availability
See Also
Declared In
NSFontManager.h

removeFontTrait:

This action method causes the receiver to send its action message up the responder chain.

- (void)removeFontTrait:(id)sender

Parameters
sender

The control that sent the message.

Discussion

By default, the action message is changeFont:.

When a responder replies by providing a font to convert in a convertFont: message, the receiver converts the font by removing the trait specified by sender. This trait is determined by sending a tag message to sender and interpreting it as a font trait mask for a convertFont:toNotHaveTrait: message.

Availability
See Also
Declared In
NSFontManager.h

selectedFont

Returns the last font recorded.

- (NSFont *)selectedFont

Return Value

The last font recorded with a setSelectedFont:isMultiple: message

Discussion

While fonts are being converted in response to a convertFont: message, you can determine the font selected in the Font panel like this:

NSFontManager *fontManager = [NSFontManager sharedFontManager];
panelFont = [fontManager convertFont:[fontManager selectedFont]];
Availability
See Also
Related Sample Code
Declared In
NSFontManager.h

sendAction

Sends the receiver’s action message up the responder chain, initiating a font change for whatever conversion and trait to change were last requested.

- (BOOL)sendAction

Return Value

YES if some object handled the changeFont: message; NO if the message went unheard.

Discussion

By default, the receiver’s action message is changeFont:.

This method is used internally by the font conversion system. You should never need to invoke it directly. Instead, use the action methods such as addFontTrait: or modifyFontViaPanel:.

Availability
See Also
Declared In
NSFontManager.h

setAction:

Sets the action that’s sent to the first responder, when the user selects a new font from the Font panel or chooses a command from the Font menu, to the given selector.

- (void)setAction:(SEL)aSelector

Parameters
aSelector

The selector to set.

Discussion

The default action is changeFont:. You should rarely need to change this setting.

Availability
See Also
Declared In
NSFontManager.h

setDelegate:

Sets the receiver’s delegate to the given object.

- (void)setDelegate:(id)anObject

Parameters
anObject

The new delegate.

Availability
See Also
Related Sample Code
Declared In
NSFontManager.h

setEnabled:

Controls whether the font conversion system’s user interface items (the Font panel and Font menu items) are enabled.

- (void)setEnabled:(BOOL)flag

Parameters
flag

If YES, they’re enabled; if NO, they’re disabled.

Availability
See Also
Declared In
NSFontManager.h

setFontMenu:

Records the given menu as the application’s Font menu.

- (void)setFontMenu:(NSMenu *)aMenu

Parameters
aMenu

The new Font menu.

Availability
See Also
Declared In
NSFontManager.h

setSelectedAttributes:isMultiple:

Informs the paragraph and character formatting panels when text in a selection has changed attributes.

- (void)setSelectedAttributes:(NSDictionary *)attributes isMultiple:(BOOL)flag

Parameters
attributes

The new attributes.

flag

If YES, informs the panel that multiple fonts or attributes are enclosed within the selection.

Discussion

This method is used primarily by NSTextView.

Availability
See Also
Declared In
NSFontManager.h

setSelectedFont:isMultiple:

Records the given font as the currently selected font and updates the Font panel to reflect this.

- (void)setSelectedFont:(NSFont *)aFont isMultiple:(BOOL)flag

Parameters
aFont

The font to set as selected.

flag

If YES, the Font panel indicates that more than one font is contained in the selection; if NO, it does not.

Discussion

An object that manipulates fonts should invoke this method whenever it becomes first responder and whenever its selection changes. It shouldn’t invoke this method in the process of handling a changeFont: message, as this causes the font manager to lose the information necessary to effect the change. After all fonts have been converted, the font manager itself records the new selected font.

Availability
See Also
Related Sample Code
Declared In
NSFontManager.h

setTarget:

Sets the target for the sendAction method.

- (void)setTarget:(id)aTarget

Parameters
aTarget

The target to set.

Availability
See Also
Declared In
NSFontManager.h

target

Returns the target for the sendAction method.

- (id)target

Return Value

The target for the receiver’s sendAction method.

Availability
See Also
Declared In
NSFontManager.h

traitsOfFont:

Returns the traits of the given font.

- (NSFontTraitMask)traitsOfFont:(NSFont *)aFont

Parameters
aFont

The font whose traits are returned.

Return Value

The font traits, returned as a mask created by combining values listed in “Constants” with the C bitwise OR operator.

Availability
Related Sample Code
Declared In
NSFontManager.h

weightOfFont:

Returns a rough numeric measure the weight of the given font.

- (NSInteger)weightOfFont:(NSFont *)aFont

Parameters
aFont

The font whose weight is returned.

Return Value

A rough numeric measure the weight of the given font, where 0 indicates the lightest possible weight, 5 indicates a normal or book weight, and 9 or more indicates a bold or heavier weight.

Availability
Declared In
NSFontManager.h

Delegate Methods

changeFont:

Informs responders of a font change.

- (void)changeFont:(id)sender

Parameters
sender

The object that sent the message.

Discussion

Generally this change is because the user changed the font either in the selection of a rich text field or in a whole plain text field. Any object that contains a font the user can change must respond to the changeFont: message by sending a convertFont: message back to sender (an NSFontManager object) for each font in the selection. For more information, see “Responding to Font Changes”.

Be aware that selectedFont at this point may return unpredictable results. The font returned from this method may not be the last font selected, or there may be multiple fonts selected at the time changeFont: is called. The use of selectedFont from within changeFont: is strongly discouraged.

Availability
See Also
Declared In
NSFontManager.h

fontManager:willIncludeFont:

Requests permission from the Font panel delegate to display the given font name in the Font panel.

- (BOOL)fontManager:(id)theFontManager willIncludeFont:(NSString *)fontName

Parameters
theFontManager

The font manager making the request.

fontName

The full PostScript name of the font to display, such as Helvetica-BoldOblique or Helvetica-Narrow-Bold.

Return Value

If the Font panel delegate returns YES, fontName is listed; if the delegate returns NO, it isn’t.

Discussion

In Mac OS X versions 10.2 and earlier, this method is invoked repeatedly as necessary whenever the Font panel needs updating, such as when the Font panel is first loaded, and when the user selects a family name to see which typefaces in that family are available. Your implementation should execute fairly quickly to ensure the responsiveness of the Font panel.

Important:  This delegate method is not called in Mac OS X versions 10.3 and later.

Availability
Declared In
NSFontManager.h

Constants

Font Collection Mask

This constant specifies options accepted by addCollection:options:.

enum {
   NSFontCollectionApplicationOnlyMask = 1 << 0
};

Constants
NSFontCollectionApplicationOnlyMask

Makes the collection available only to the application. This option is not yet implemented.

Available in Mac OS X v10.3 and later.

Declared in NSFontManager.h.

Declared In
NSFontManager.h

NSFontTraitMask

Mask of traits assigned to a font, assigned using the values in Font traits.

typedef unsigned int NSFontTraitMask;

Availability
Declared In
NSFontManager.h

Font traits

Font traits defined and supported by NSFontManager.

enum {
   NSItalicFontMask = 0x00000001,
   NSBoldFontMask = 0x00000002,
   NSUnboldFontMask = 0x00000004,
   NSNonStandardCharacterSetFontMask = 0x00000008,
   NSNarrowFontMask = 0x00000010,
   NSExpandedFontMask = 0x00000020,
   NSCondensedFontMask = 0x00000040,
   NSSmallCapsFontMask = 0x00000080,
   NSPosterFontMask = 0x00000100,
   NSCompressedFontMask = 0x00000200,
   NSFixedPitchFontMask = 0x00000400,
   NSUnitalicFontMask = 0x01000000
};

Constants
NSItalicFontMask

A mask that specifies an italic font.

Available in Mac OS X v10.0 and later.

Declared in NSFontManager.h.

NSBoldFontMask

A mask that specifies a bold font.

Available in Mac OS X v10.0 and later.

Declared in NSFontManager.h.

NSUnboldFontMask

A mask that specifies a font that is not bold.

Available in Mac OS X v10.0 and later.

Declared in NSFontManager.h.

NSNonStandardCharacterSetFontMask

A mask that specifies a font that uses a non-standard character set.

Available in Mac OS X v10.0 and later.

Declared in NSFontManager.h.

NSNarrowFontMask

A mask that specifies a narrow font.

Available in Mac OS X v10.0 and later.

Declared in NSFontManager.h.

NSExpandedFontMask

A mask that specifies an expanded font.

Available in Mac OS X v10.0 and later.

Declared in NSFontManager.h.

NSCondensedFontMask

A mask that specifies a condensed font.

Available in Mac OS X v10.0 and later.

Declared in NSFontManager.h.

NSSmallCapsFontMask

A mask that specifies a small-caps font.

Available in Mac OS X v10.0 and later.

Declared in NSFontManager.h.

NSPosterFontMask

A mask that specifies a poster-style font.

Available in Mac OS X v10.0 and later.

Declared in NSFontManager.h.

NSCompressedFontMask

A mask that specifies a compressed font.

Available in Mac OS X v10.0 and later.

Declared in NSFontManager.h.

NSFixedPitchFontMask

A mask that specifies a fixed pitch font.

Available in Mac OS X v10.0 and later.

Declared in NSFontManager.h.

NSUnitalicFontMask

A mask that specifies a font that is not italic.

Available in Mac OS X v10.0 and later.

Declared in NSFontManager.h.

Discussion

NSFontManager categorizes fonts according to a small set of traits. You can convert fonts by adding and removing individual traits, and you can get a font with a specific combination of traits.

These pairs of traits are mutually exclusive:

Declared In
NSFontManager.h

NSFontAction

These constants specify what action modifyFont: will take.

typedef enum _NSFontAction {
   NSNoFontChangeAction = 0,
   NSViaPanelFontAction = 1,
   NSAddTraitFontAction = 2,
   NSSizeUpFontAction = 3,
   NSSizeDownFontAction = 4,
   NSHeavierFontAction = 5,
   NSLighterFontAction = 6,
   NSRemoveTraitFontAction = 7
} NSFontAction;

Constants
NSNoFontChangeAction

No action; the font is returned unchanged.

Available in Mac OS X v10.0 and later.

Declared in NSFontManager.h.

NSViaPanelFontAction

Converts the font according to the NSFontPanel method panelConvertFont:.

Available in Mac OS X v10.0 and later.

Declared in NSFontManager.h.

NSAddTraitFontAction

Converts the font to have an additional trait using convertFont:toHaveTrait:.

Available in Mac OS X v10.0 and later.

Declared in NSFontManager.h.

NSSizeUpFontAction

Converts the font to a larger size using convertFont:toSize:.

Available in Mac OS X v10.0 and later.

Declared in NSFontManager.h.

NSSizeDownFontAction

Converts the font to a smaller size using convertFont:toSize:.

Available in Mac OS X v10.0 and later.

Declared in NSFontManager.h.

NSHeavierFontAction

Converts the font to a heavier weight using convertWeight:ofFont:.

Available in Mac OS X v10.0 and later.

Declared in NSFontManager.h.

NSLighterFontAction

Converts the font to a lighter weight using convertWeight:ofFont:.

Available in Mac OS X v10.0 and later.

Declared in NSFontManager.h.

NSRemoveTraitFontAction

Converts the font to remove a trait using convertFont:toNotHaveTrait:.

Available in Mac OS X v10.0 and later.

Declared in NSFontManager.h.

Availability
Declared In
NSFontManager.h

Next Page > Hide TOC


© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-04-06)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.