Next Page > Hide TOC

NSFontPanel 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
NSFontPanel.h
Related sample code

Overview

The NSFontPanel class implements the Font panel—a user interface object that displays a list of available fonts, letting the user preview them and change the font used to display text. The actual changes are made through conversion messages sent to the shared NSFontManager instance. There’s only one Font panel for each application.

Tasks

Getting the Font Panel

Enabling Font Changes

Updating the Font Panel

Converting Fonts

Working in Modal Loops

Setting an Accessory View

Class Methods

sharedFontPanel

Returns the single NSFontPanel instance for the application, creating it if necessary.

+ (NSFontPanel *)sharedFontPanel

Return Value

The NSFontPanel instance for the application.

Availability
See Also
Related Sample Code
Declared In
NSFontPanel.h

sharedFontPanelExists

Returns YES if the shared Font panel has been created, NO if it hasn’t.

+ (BOOL)sharedFontPanelExists

Availability
See Also
Declared In
NSFontPanel.h

Instance Methods

accessoryView

Returns the receiver’s accessory view.

- (NSView *)accessoryView

Availability
See Also
Declared In
NSFontPanel.h

isEnabled

Indicates whether the receiver’s Set button is enabled.

- (BOOL)isEnabled

Return Value

YES if the receiver’s Set button is enabled; NO if it isn’t.

Discussion

The receiver continues to reflect the font of the selection for cooperating text objects regardless of this setting.

Availability
See Also
Declared In
NSFontPanel.h

panelConvertFont:

Converts the specified font using the settings in the receiver, with the aid of the shared NSFontManager if necessary.

- (NSFont *)panelConvertFont:(NSFont *)aFont

Parameters
aFont

The font to be converted.

Return Value

The converted font, or aFont itself if it can’t be converted.

Discussion

For example, if aFont is Helvetica Oblique 12.0 point and the user has selected the Times font family (and nothing else) in the Font panel, the font returned is Times Italic 12.0 point.

Availability
See Also
Declared In
NSFontPanel.h

reloadDefaultFontFamilies

Triggers a reload to the default state, so that the delegate is called.

- (void)reloadDefaultFontFamilies

Discussion

This reloading provides the delegate opportunity to scrutinize the default list of fonts to be displayed in the panel.

Availability
Declared In
NSFontPanel.h

setAccessoryView:

Establishes the specified view as the receiver’s accessory view, allowing you to add custom controls to your application’s Font panel without having to create a subclass.

- (void)setAccessoryView:(NSView *)aView

Parameters
aView

The view to set.

Availability
See Also
Declared In
NSFontPanel.h

setEnabled:

Specifies whether the receiver’s Set button is enabled.

- (void)setEnabled:(BOOL)flag

Parameters
flag

If YES the Set button is enabled; if NO, it’s disabled.

Discussion

The receiver continues to reflect the font of the selection for cooperating text objects regardless of this setting.

Availability
See Also
Declared In
NSFontPanel.h

setPanelFont:isMultiple:

Sets the selected font in the receiver to the specified font.

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

Parameters
aFont

The font to be selected.

flag

If NO, selects the specified font; otherwise selects no font and displays a message in the preview area indicating that multiple fonts are selected.

Discussion

You normally don’t use this method directly; instead, you send setSelectedFont:isMultiple: to the shared NSFontManager, which in turn invokes this method.

Availability
Related Sample Code
Declared In
NSFontPanel.h

worksWhenModal

Indicates whether the receiver allows fonts to be changed in modal windows and panels.

- (BOOL)worksWhenModal

Return Value

YES, regardless of the setting established using the NSPanel method setWorksWhenModal:.

Availability
See Also
Declared In
NSFontPanel.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.