<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSFont",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSFont"
  },
  "title" : "NSFont"
}
-->

# NSFont

The representation of a font in an app.

```
class NSFont
```

## Overview

[`NSFont`](/documentation/AppKit/NSFont) objects represent fonts to an app, providing access to characteristics of the font and assistance in laying out glyphs relative to one another. Font objects are also used to establish the current font for drawing text directly into a graphics context, using the [`set()`](/documentation/AppKit/NSFont/set()) method.

You don’t create [`NSFont`](/documentation/AppKit/NSFont) objects using the `alloc` and `init` methods. Instead, you use either [`init(descriptor:size:)`](/documentation/AppKit/NSFont/init(descriptor:size:)) or [`init(name:size:)`](/documentation/AppKit/NSFont/init(name:size:)) to look up an available font and alter its size or matrix to your needs. These methods check for an existing font object with the specified characteristics, returning it if there is one. Otherwise, they look up the font data requested and create the appropriate object. [`NSFont`](/documentation/AppKit/NSFont) also defines a number of methods for getting standard system fonts, such as [`systemFont(ofSize:)`](/documentation/AppKit/NSFont/systemFont(ofSize:)), [`userFont(ofSize:)`](/documentation/AppKit/NSFont/userFont(ofSize:)), and [`messageFont(ofSize:)`](/documentation/AppKit/NSFont/messageFont(ofSize:)). To request the default size for these standard fonts, pass a negative number or `0` as the font size. For more information on system fonts, see Human Interface Guidelines > <doc://com.apple.documentation/design/Human-Interface-Guidelines/typography>.

## Topics

### Creating Arbitrary Fonts

[`+  fontWithName:size:`](/documentation/AppKit/NSFont/init(name:size:))

Creates a font object for the specified font name and font size.

[`+  fontWithDescriptor:size:`](/documentation/AppKit/NSFont/init(descriptor:size:))

Returns a font object for the specified font descriptor and font size.

[`+  fontWithDescriptor:textTransform:`](/documentation/AppKit/NSFont/init(descriptor:textTransform:))

Returns a font object for the specified font descriptor and text transform.

[`+  fontWithName:matrix:`](/documentation/AppKit/NSFont/init(name:matrix:))

Returns a font object for the specified font name and matrix.

### Creating User Fonts

[`+  userFontOfSize:`](/documentation/AppKit/NSFont/userFont(ofSize:))

Returns the font used by default for documents and other text under the user’s control (that is, text whose font the user can normally change), in the specified size.

[`+  userFixedPitchFontOfSize:`](/documentation/AppKit/NSFont/userFixedPitchFont(ofSize:))

Returns the font used by default for documents and other text under the user’s control (that is, text whose font the user can normally change), when that font should be fixed-pitch, in the specified size.

### Creating System Fonts

[`+  preferredFontForTextStyle:options:`](/documentation/AppKit/NSFont/preferredFont(forTextStyle:options:))

Returns the font associated with the text style.

[`+  systemFontOfSize:`](/documentation/AppKit/NSFont/systemFont(ofSize:))

Returns the standard system font with the specified size.

[`+  systemFontOfSize:weight:`](/documentation/AppKit/NSFont/systemFont(ofSize:weight:))

Returns the standard system font with the specified size and weight.

[`+  boldSystemFontOfSize:`](/documentation/AppKit/NSFont/boldSystemFont(ofSize:))

Returns the standard system font in boldface type with the specified size.

[`+  monospacedSystemFontOfSize:weight:`](/documentation/AppKit/NSFont/monospacedSystemFont(ofSize:weight:))

Returns a monospace version of the system font with the specified size and weight.

[`+  monospacedDigitSystemFontOfSize:weight:`](/documentation/AppKit/NSFont/monospacedDigitSystemFont(ofSize:weight:))

Returns a version of the standard system font that contains monospaced digit glyphs.

[`systemFontSize`](/documentation/AppKit/NSFont/systemFontSize)

Returns the size of the standard system font.

[`smallSystemFontSize`](/documentation/AppKit/NSFont/smallSystemFontSize)

Returns the size of the standard small system font.

[`Weight`](/documentation/AppKit/NSFont/Weight)

System-defined font-weight values.

[`TextStyle`](/documentation/AppKit/NSFont/TextStyle)

Constants that specify the preferred text styles you use with fonts.

[`TextStyleOptionKey`](/documentation/AppKit/NSFont/TextStyleOptionKey)

The options that you apply when requesting the font or font descriptor of a preferred text style.

### Creating UI Element Fonts

[`+  labelFontOfSize:`](/documentation/AppKit/NSFont/labelFont(ofSize:))

Returns the font used for standard interface labels in the specified size.

[`+  messageFontOfSize:`](/documentation/AppKit/NSFont/messageFont(ofSize:))

Returns the font used for standard interface items, such as button labels, menu items, and so on, in the specified size.

[`+  menuBarFontOfSize:`](/documentation/AppKit/NSFont/menuBarFont(ofSize:))

Returns the font used for menu bar items, in the specified size.

[`+  menuFontOfSize:`](/documentation/AppKit/NSFont/menuFont(ofSize:))

Returns the font used for menu items, in the specified size.

[`+  controlContentFontOfSize:`](/documentation/AppKit/NSFont/controlContentFont(ofSize:))

Returns the font used for the content of controls in the specified size.

[`+  titleBarFontOfSize:`](/documentation/AppKit/NSFont/titleBarFont(ofSize:))

Returns the font used for window title bars, in the specified size.

[`+  paletteFontOfSize:`](/documentation/AppKit/NSFont/paletteFont(ofSize:))

Returns the font used for palette window title bars, in the specified size.

[`+  toolTipsFontOfSize:`](/documentation/AppKit/NSFont/toolTipsFont(ofSize:))

Returns the font used for tool tips labels, in the specified size.

[`labelFontSize`](/documentation/AppKit/NSFont/labelFontSize)

Returns the size of the standard label font.

[`+  systemFontSizeForControlSize:`](/documentation/AppKit/NSFont/systemFontSize(for:))

Returns the font size used for the specified control size.

### Using a Font to Draw

[`-  set`](/documentation/AppKit/NSFont/set())

Sets this font as the font for the current graphics context.

[`-  setInContext:`](/documentation/AppKit/NSFont/set(in:))

Sets this font as the font for the specified graphics context.

### Getting Font Metrics and Information

[`pointSize`](/documentation/AppKit/NSFont/pointSize)

The point size of the font.

[`coveredCharacterSet`](/documentation/AppKit/NSFont/coveredCharacterSet)

The character set containing all of the nominal characters that the font can render.

[`fontDescriptor`](/documentation/AppKit/NSFont/fontDescriptor)

The font descriptor object for the font.

[`fixedPitch`](/documentation/AppKit/NSFont/isFixedPitch)

A Boolean value indicating whether all glyphs in the font have the same advancement.

[`mostCompatibleStringEncoding`](/documentation/AppKit/NSFont/mostCompatibleStringEncoding)

The string encoding that works best with the font.

[Advanced Font Metrics](/documentation/AppKit/advanced-font-metrics)

Retrieve details about ascender and descender heights, glyph bounding rectangles, glyph advancements, and more.

### Getting Information About Glyphs

[`numberOfGlyphs`](/documentation/AppKit/NSFont/numberOfGlyphs)

The number of glyphs in the font.

[`NSGlyph`](/documentation/AppKit/NSGlyph)

The type used to specify glyphs.

[`NSControlGlyph`](/documentation/AppKit/NSControlGlyph)

The reserved code for a control glyph.

[`NSNullGlyph`](/documentation/AppKit/NSNullGlyph)

The reserved code for a null glyph.

### Getting Font Names

[`displayName`](/documentation/AppKit/NSFont/displayName)

The name of the font, including family and face names, to use when displaying the font information to the user.

[`familyName`](/documentation/AppKit/NSFont/familyName)

The family name of the font—for example, “Times” or “Helvetica.”

[`fontName`](/documentation/AppKit/NSFont/fontName)

The full name of the font, as used in PostScript language code—for example, “Times-Roman” or “Helvetica-Oblique.”

### Setting User Fonts

[`+  setUserFont:`](/documentation/AppKit/NSFont/setUser(_:))

Sets the font used by default for documents and other text under the user’s control to the specified font.

[`+  setUserFixedPitchFont:`](/documentation/AppKit/NSFont/setUserFixedPitch(_:))

Sets the font used by default for documents and other text under the user’s control, when that font should be fixed-pitch, to the specified font.

### Vertical Fonts

[`vertical`](/documentation/AppKit/NSFont/isVertical)

A Boolean value indicating whether the font is a vertical font.

[`verticalFont`](/documentation/AppKit/NSFont/vertical-6ym79)

A vertical version of the font.

### Responding to Font-Related Notifications

[`NSAntialiasThresholdChangedNotification`](/documentation/AppKit/NSFont/antialiasThresholdChangedNotification)

Posted after the threshold for antialiasing changes.

[`NSFontSetChangedNotification`](/documentation/AppKit/NSFont/fontSetChangedNotification)

Posted after the currently-set font changes.

### Deprecated

[Deprecated Symbols](/documentation/AppKit/nsfont-deprecated-symbols)

Review unsupported symbols and their replacements.

### Type Aliases

[`Width`](/documentation/AppKit/NSFont/Width)

### Instance Properties

[`printerFont`](/documentation/AppKit/NSFont/printer)

The scalable PostScript font corresponding to current font.

[`renderingMode`](/documentation/AppKit/NSFont/renderingMode)

The rendering mode of the font.

[`screenFont`](/documentation/AppKit/NSFont/screen)

The bitmapped screen font for the current font.

### Instance Methods

[`-  advancementForGlyph:`](/documentation/AppKit/NSFont/advancement(forGlyph:))

Returns the nominal spacing for the given glyph—the distance the current point moves after showing the glyph—accounting for the receiver’s size.

[`-  boundingRectForGlyph:`](/documentation/AppKit/NSFont/boundingRect(forGlyph:))

Returns the bounding rectangle for the specified glyph, scaled to the receiver’s size.

[`-  getAdvancements:forGlyphs:count:`](/documentation/AppKit/NSFont/getAdvancements(_:forGlyphs:count:))

Returns an array of the advancements for the specified glyphs rendered by the receiver.

[`-  getAdvancements:forPackedGlyphs:length:`](/documentation/AppKit/NSFont/getAdvancements(_:forPackedGlyphs:length:))

Returns an array of the advancements for the specified packed glyphs and rendered by the receiver.

[`-  getBoundingRects:forGlyphs:count:`](/documentation/AppKit/NSFont/getBoundingRects(_:forGlyphs:count:))

Returns an array of the bounding rectangles for the specified glyphs rendered by the receiver.

[`-  glyphWithName:`](/documentation/AppKit/NSFont/glyph(withName:))

Returns the named encoded glyph, or –1 if the receiver contains no such glyph.

[`-  screenFontWithRenderingMode:`](/documentation/AppKit/NSFont/screenFont(with:))

Returns a bitmapped screen font, when sent to a font object representing a scalable PostScript font, with the specified rendering mode, matching the receiver in typeface and matrix (or size), or `nil` if such a font can’t be found.

[`-  fontWithSize:`](/documentation/AppKit/NSFont/withSize(_:))

### Type Methods

[`+  systemFontOfSize:weight:width:`](/documentation/AppKit/NSFont/systemFont(ofSize:weight:width:))

## Relationships

### Conforms To

[`NSCoding`](/documentation/Foundation/NSCoding)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

[`Hashable`](/documentation/Swift/Hashable)

[`NSCopying`](/documentation/Foundation/NSCopying)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)