Mac Developer Library

Developer

AppKit Framework Reference NSFontPanel Class Reference

Options
Deployment Target:

On This Page
Language:

NSFontPanel

Conforms To


Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.0 and later.

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.

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

    Declaration

    Swift

    class func sharedFontPanel() -> NSFontPanel

    Objective-C

    + (NSFontPanel *)sharedFontPanel

    Return Value

    The NSFontPanel instance for the application.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns YEStrue if the shared Font panel has been created, NOfalse if it hasn’t.

    Declaration

    Swift

    class func sharedFontPanelExists() -> Bool

    Objective-C

    + (BOOL)sharedFontPanelExists

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Specifies whether the receiver’s Set button is enabled.

    Declaration

    Swift

    var enabled: Bool

    Objective-C

    @property(getter=isEnabled) BOOL enabled

    Parameters

    flag

    If YEStrue the Set button is enabled; if NOfalse, it’s disabled.

    Discussion

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

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – isEnabled

  • isEnabled - isEnabled Available in OS X v10.0 through OS X v10.9

    Indicates whether the receiver’s Set button is enabled.

    Declaration

    Objective-C

    - (BOOL)isEnabled

    Return Value

    YEStrue if the receiver’s Set button is enabled; NOfalse if it isn’t.

    Discussion

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

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 through OS X v10.9.

    See Also

    – setEnabled:

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

    Declaration

    Swift

    func reloadDefaultFontFamilies()

    Objective-C

    - (void)reloadDefaultFontFamilies

    Discussion

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

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func setPanelFont(_ aFont: NSFont, isMultiple flag: Bool)

    Objective-C

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

    Parameters

    aFont

    The font to be selected.

    flag

    If NOfalse, 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.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func panelConvertFont(_ aFont: NSFont) -> NSFont

    Objective-C

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

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – convertFont: (NSFontManager)

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

    Declaration

    Swift

    var worksWhenModal: Bool

    Objective-C

    @property BOOL worksWhenModal

    Return Value

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

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – worksWhenModal (NSWindow)
    – worksWhenModal (NSPanel)

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

    Declaration

    Swift

    var accessoryView: NSView?

    Objective-C

    @property(strong) NSView *accessoryView

    Parameters

    aView

    The view to set.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the receiver’s accessory view.

    Declaration

    Swift

    var accessoryView: NSView?

    Objective-C

    @property(strong) NSView *accessoryView

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • These constants are obsolete and should not be used.

    Use the method and constants described in NSFontPanelValidation Protocol Reference instead.

    Declaration

    Swift

    var NSFPPreviewButton: Int { get } var NSFPRevertButton: Int { get } var NSFPSetButton: Int { get } var NSFPPreviewField: Int { get } var NSFPSizeField: Int { get } var NSFPSizeTitle: Int { get } var NSFPCurrentField: Int { get }

    Objective-C

    enum { NSFPPreviewButton = 131, NSFPRevertButton = 130, NSFPSetButton = 132, NSFPPreviewField = 128, NSFPSizeField = 129, NSFPSizeTitle = 133, NSFPCurrentField = 134 };

    Constants

    • NSFPPreviewButton

      NSFPPreviewButton

      Show the Preview button.

      Available in OS X v10.0 and later.

      Deprecated in OS X v10.0.

    • NSFPRevertButton

      NSFPRevertButton

      Show the Revert button.

      Available in OS X v10.0 and later.

      Deprecated in OS X v10.0.

    • NSFPSetButton

      NSFPSetButton

      Show the Set button.

      Available in OS X v10.0 and later.

      Deprecated in OS X v10.0.

    • NSFPPreviewField

      NSFPPreviewField

      Show the Preview field.

      Available in OS X v10.0 and later.

      Deprecated in OS X v10.0.

    • NSFPSizeField

      NSFPSizeField

      Show the Size field.

      Available in OS X v10.0 and later.

      Deprecated in OS X v10.0.

    • NSFPSizeTitle

      NSFPSizeTitle

      Show the Size title.

      Available in OS X v10.0 and later.

      Deprecated in OS X v10.0.

    • NSFPCurrentField

      NSFPCurrentField

      Show the Current field.

      Available in OS X v10.0 and later.

      Deprecated in OS X v10.0.