<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/NSLayoutManager",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSLayoutManager"
  },
  "title" : "NSLayoutManager"
}
-->

# NSLayoutManager

An object that coordinates the layout and display of text characters.

```
class NSLayoutManager
```

## Overview

[`NSLayoutManager`](/documentation/UIKit/NSLayoutManager) maps Unicode character codes to glyphs, sets the glyphs in a series of [`NSTextContainer`](/documentation/UIKit/NSTextContainer) objects, and displays them in a series of <doc://com.apple.documentation/documentation/AppKit/NSTextView> objects. In addition to its core function of laying out text, a layout manager object coordinates its text view objects, provides services to those text views to support <doc://com.apple.documentation/documentation/AppKit/NSRulerView> instances for editing paragraph styles, and handles the layout and display of text attributes not inherent in glyphs (such as underline or strikethrough). You can create a subclass of [`NSLayoutManager`](/documentation/UIKit/NSLayoutManager) to handle additional text attributes, whether inherent or not.

### Text Antialiasing

[`NSLayoutManager`](/documentation/UIKit/NSLayoutManager) provides the threshold for text antialiasing. It looks at the `AppleAntiAliasingThreshold` default value. If the font size is smaller than or equal to this threshold size, the text is rendered aliased by [`NSLayoutManager`](/documentation/UIKit/NSLayoutManager). In macOS, you can change the threshold value from the Appearance pane of System Preferences.

### Thread Safety of NSLayoutManager

Generally speaking, a specific layout manager (and associated objects) should not be used in more than one block, operation, or thread at a time. Most layout managers are used on the main thread, since it is the main thread on which their text views are displayed, and since background layout occurs on the main thread.

If you want to use a layout manager on a background thread, first make sure that text views associated with that layout manager (if any) are not displayed while the layout manager is being used on the background thread, and, second, turn off background layout for that layout manager while it is being used on the background thread. The most effective way to ensure that no text view is displayed, without knowing deep implementation, is just not to connect a text view to the layout manager.

### Noncontiguous Layout

Noncontiguous layout is an optional layout manager behavior. Previously, both glyph generation and layout were always performed, in order, from the beginning to the end of the document. When noncontiguous layout is turned on, however, the layout manager gains the option of performing glyph generation or layout for one portion of the document without having done so for previous sections. This can provide significant performance improvements for large documents.

Noncontiguous layout is not turned on automatically because direct clients of `NSLayoutManager` typically have relied on the previous behavior—for example, by forcing layout for a specific glyph range, and then assuming that previous glyphs would therefore be laid out. Clients who use [`NSLayoutManager`](/documentation/UIKit/NSLayoutManager) only indirectly—for example, those who use <doc://com.apple.documentation/documentation/AppKit/NSTextView> without directly calling the underlying layout manager—can usually turn on noncontiguous layout without difficulty. Clients using [`NSLayoutManager`](/documentation/UIKit/NSLayoutManager) directly need to examine their usage before turning on noncontiguous layout.

Enable noncontiguous layout using the [`allowsNonContiguousLayout`](/documentation/UIKit/NSLayoutManager/allowsNonContiguousLayout) property. In addition, see the other methods in [`Causing glyph generation and layout`](/documentation/UIKit/NSLayoutManager#Causing-glyph-generation-and-layout), many of which enable you to ensure that glyph generation and layout are performed for specified portions of the text. The behavior of a number of other layout manager methods is affected by the state of noncontiguous layout, as noted in the discussion sections of those method descriptions.

## Topics

### Creating a layout manager

[`init()`](/documentation/UIKit/NSLayoutManager/init())

Initializes a newly created layout manager object.

[`init(coder:)`](/documentation/UIKit/NSLayoutManager/init(coder:))

Creates a layout manager from data in an unarchiver.

### Managing the layout process

[`delegate`](/documentation/UIKit/NSLayoutManager/delegate)

The layout manager’s delegate.

[`NSLayoutManagerDelegate`](/documentation/UIKit/NSLayoutManagerDelegate)

A set of optional methods that delegates of layout manager objects implement.

### Accessing the text storage

[`textStorage`](/documentation/UIKit/NSLayoutManager/textStorage)

The text storage object that contains the content to lay out.

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/replaceTextStorage(_:)>

### Configuring the global layout manager options

[`allowsNonContiguousLayout`](/documentation/UIKit/NSLayoutManager/allowsNonContiguousLayout)

A Boolean value that indicates whether the layout manager allows noncontiguous layout.

[`hasNonContiguousLayout`](/documentation/UIKit/NSLayoutManager/hasNonContiguousLayout)

A Boolean value that indicates whether the layout manager currently has any areas of noncontiguous layout.

[`showsInvisibleCharacters`](/documentation/UIKit/NSLayoutManager/showsInvisibleCharacters)

A Boolean value that indicates whether to substitute visible glyphs for whitespace and other typically invisible characters.

[`showsControlCharacters`](/documentation/UIKit/NSLayoutManager/showsControlCharacters)

A Boolean value that indicates whether the layout manager substitutes visible glyphs for control characters in the layout.

[`usesFontLeading`](/documentation/UIKit/NSLayoutManager/usesFontLeading)

A Boolean value that indicates whether the layout manager uses the leading of the font.

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/backgroundLayoutEnabled>

[`limitsLayoutForSuspiciousContents`](/documentation/UIKit/NSLayoutManager/limitsLayoutForSuspiciousContents)

A Boolean value that indicates whether the layout manager avoids laying out unusually long or suspicious input.

[`usesDefaultHyphenation`](/documentation/UIKit/NSLayoutManager/usesDefaultHyphenation)

A Boolean value that indicates whether the layout manager uses the default hyphenation rules to wrap lines.

### Managing the text containers

[`textContainers`](/documentation/UIKit/NSLayoutManager/textContainers)

The current text containers of the layout manager.

[`addTextContainer(_:)`](/documentation/UIKit/NSLayoutManager/addTextContainer(_:))

Appends the specified text container to the series of text containers where the layout manager arranges text.

[`insertTextContainer(_:at:)`](/documentation/UIKit/NSLayoutManager/insertTextContainer(_:at:))

Inserts a text container at the specified index in the list of text containers.

[`removeTextContainer(at:)`](/documentation/UIKit/NSLayoutManager/removeTextContainer(at:))

Removes the text container at the specified index and invalidates the layout as necessary.

[`setTextContainer(_:forGlyphRange:)`](/documentation/UIKit/NSLayoutManager/setTextContainer(_:forGlyphRange:))

Associates a text container with the specified range of glyphs.

[`textContainerChangedGeometry(_:)`](/documentation/UIKit/NSLayoutManager/textContainerChangedGeometry(_:))

Invalidates the layout information, and possibly glyphs, for the specified text container and all subsequent text container objects.

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/textContainerChangedTextView(_:)>

[`textContainer(forGlyphAt:effectiveRange:)`](/documentation/UIKit/NSLayoutManager/textContainer(forGlyphAt:effectiveRange:))

Returns the text container that manages the layout for the specified glyph, causing layout to happen as necessary.

[`textContainer(forGlyphAt:effectiveRange:withoutAdditionalLayout:)`](/documentation/UIKit/NSLayoutManager/textContainer(forGlyphAt:effectiveRange:withoutAdditionalLayout:))

Returns the text container that manages the layout for the specified glyph.

[`usedRect(for:)`](/documentation/UIKit/NSLayoutManager/usedRect(for:))

Returns the bounding rectangle for the glyphs in the specified text container.

### Invalidating glyphs and layout

[`invalidateDisplay(forCharacterRange:)`](/documentation/UIKit/NSLayoutManager/invalidateDisplay(forCharacterRange:))

Invalidates display for the specified character range.

[`invalidateDisplay(forGlyphRange:)`](/documentation/UIKit/NSLayoutManager/invalidateDisplay(forGlyphRange:))

Invalidates a range of glyphs, requiring new layout information, and updates the appropriate regions of any text views that display those glyphs.

[`invalidateGlyphs(forCharacterRange:changeInLength:actualCharacterRange:)`](/documentation/UIKit/NSLayoutManager/invalidateGlyphs(forCharacterRange:changeInLength:actualCharacterRange:))

Invalidates and adjusts the glyphs in the specified character range.

[`invalidateLayout(forCharacterRange:actualCharacterRange:)`](/documentation/UIKit/NSLayoutManager/invalidateLayout(forCharacterRange:actualCharacterRange:))

Invalidates the layout information for the glyphs that map to the specified character range.

[`processEditing(for:edited:range:changeInLength:invalidatedRange:)`](/documentation/UIKit/NSLayoutManager/processEditing(for:edited:range:changeInLength:invalidatedRange:))

Notifies the layout manager when an edit action changes the contents of its text storage object.

### Causing glyph generation and layout

[`ensureGlyphs(forCharacterRange:)`](/documentation/UIKit/NSLayoutManager/ensureGlyphs(forCharacterRange:))

Forces the layout manager to generate glyphs for the specified character range if it hasn’t already.

[`ensureGlyphs(forGlyphRange:)`](/documentation/UIKit/NSLayoutManager/ensureGlyphs(forGlyphRange:))

Forces the layout manager to generate glyphs for the specified glyph range if it hasn’t already.

[`ensureLayout(forBoundingRect:in:)`](/documentation/UIKit/NSLayoutManager/ensureLayout(forBoundingRect:in:))

Forces the layout manager to perform layout for the specified area in the specified text container if it hasn’t already.

[`ensureLayout(forCharacterRange:)`](/documentation/UIKit/NSLayoutManager/ensureLayout(forCharacterRange:))

Forces the layout manager to perform layout for the specified character range if it hasn’t already.

[`ensureLayout(forGlyphRange:)`](/documentation/UIKit/NSLayoutManager/ensureLayout(forGlyphRange:))

Forces the layout manager to perform layout for the specified glyph range if it hasn’t already.

[`ensureLayout(for:)`](/documentation/UIKit/NSLayoutManager/ensureLayout(for:))

Forces the layout manager to perform layout for the specified text container if it hasn’t already.

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/glyphGenerator>

### Accessing glyphs

[`getGlyphs(in:glyphs:properties:characterIndexes:bidiLevels:)`](/documentation/UIKit/NSLayoutManager/getGlyphs(in:glyphs:properties:characterIndexes:bidiLevels:))

Fills a passed-in buffer with a sequence of glyphs.

[`cgGlyph(at:)`](/documentation/UIKit/NSLayoutManager/cgGlyph(at:))

Returns the glyph at the specified index.

[`cgGlyph(at:isValidIndex:)`](/documentation/UIKit/NSLayoutManager/cgGlyph(at:isValidIndex:))

Returns the glyph at the specified index along with information about whether the glyph index is valid.

[`setGlyphs(_:properties:characterIndexes:font:forGlyphRange:)`](/documentation/UIKit/NSLayoutManager/setGlyphs(_:properties:characterIndexes:font:forGlyphRange:))

Stores the initial glyphs and glyph properties for a character range.

[`characterIndexForGlyph(at:)`](/documentation/UIKit/NSLayoutManager/characterIndexForGlyph(at:))

Returns the index in the text storage for the first character of the specified glyph.

[`glyphIndexForCharacter(at:)`](/documentation/UIKit/NSLayoutManager/glyphIndexForCharacter(at:))

Returns the index of the first glyph of the character at the specified index.

[`isValidGlyphIndex(_:)`](/documentation/UIKit/NSLayoutManager/isValidGlyphIndex(_:))

Indicates whether the specified index refers to a valid glyph.

[`numberOfGlyphs`](/documentation/UIKit/NSLayoutManager/numberOfGlyphs)

The number of glyphs in the layout manager.

[`propertyForGlyph(at:)`](/documentation/UIKit/NSLayoutManager/propertyForGlyph(at:))

Returns the glyph property of the glyph at the specified index.

[`NSLayoutManager.GlyphProperty`](/documentation/UIKit/NSLayoutManager/GlyphProperty)

Glyph properties.

### Setting layout information

[`setAttachmentSize(_:forGlyphRange:)`](/documentation/UIKit/NSLayoutManager/setAttachmentSize(_:forGlyphRange:))

Sets the size to use when drawing a glyph that represents an attachment.

[`setDrawsOutsideLineFragment(_:forGlyphAt:)`](/documentation/UIKit/NSLayoutManager/setDrawsOutsideLineFragment(_:forGlyphAt:))

Indicates whether the specified glyph exceeds the bounds of the line fragment for its layout.

[`setExtraLineFragmentRect(_:usedRect:textContainer:)`](/documentation/UIKit/NSLayoutManager/setExtraLineFragmentRect(_:usedRect:textContainer:))

Sets the bounds and container for the extra line fragment.

[`setLineFragmentRect(_:forGlyphRange:usedRect:)`](/documentation/UIKit/NSLayoutManager/setLineFragmentRect(_:forGlyphRange:usedRect:))

Associates the line fragment bounds for the specified range of glyphs.

[`setLocation(_:forStartOfGlyphRange:)`](/documentation/UIKit/NSLayoutManager/setLocation(_:forStartOfGlyphRange:))

Sets the location for the first glyph in the specified range.

[`setNotShownAttribute(_:forGlyphAt:)`](/documentation/UIKit/NSLayoutManager/setNotShownAttribute(_:forGlyphAt:))

Sets the visibility of the glyph at the specified index.

### Getting layout information

[`attachmentSize(forGlyphAt:)`](/documentation/UIKit/NSLayoutManager/attachmentSize(forGlyphAt:))

Returns the size of the attachment glyph at the specified index.

[`drawsOutsideLineFragment(forGlyphAt:)`](/documentation/UIKit/NSLayoutManager/drawsOutsideLineFragment(forGlyphAt:))

Indicates whether the glyph draws outside its line fragment rectangle.

[`extraLineFragmentRect`](/documentation/UIKit/NSLayoutManager/extraLineFragmentRect)

The rectangle for the extra line fragment at the end of a document.

[`extraLineFragmentTextContainer`](/documentation/UIKit/NSLayoutManager/extraLineFragmentTextContainer)

The text container for the extra line fragment rectangle.

[`extraLineFragmentUsedRect`](/documentation/UIKit/NSLayoutManager/extraLineFragmentUsedRect)

The rectangle that encloses the insertion point in the extra line fragment rectangle.

[`firstUnlaidCharacterIndex()`](/documentation/UIKit/NSLayoutManager/firstUnlaidCharacterIndex())

Returns the index for the first character in the layout manager that isn’t in the layout.

[`firstUnlaidGlyphIndex()`](/documentation/UIKit/NSLayoutManager/firstUnlaidGlyphIndex())

Returns the index for the first glyph in the layout manager that isn’t in the layout.

[`getFirstUnlaidCharacterIndex(_:glyphIndex:)`](/documentation/UIKit/NSLayoutManager/getFirstUnlaidCharacterIndex(_:glyphIndex:))

Returns the indexes for the first character and glyph that have invalid layout information.

[`lineFragmentRect(forGlyphAt:effectiveRange:)`](/documentation/UIKit/NSLayoutManager/lineFragmentRect(forGlyphAt:effectiveRange:))

Returns the rectangle for the line fragment where the glyph lies and (optionally), by reference, the entire range of glyphs in that fragment.

[`lineFragmentRect(forGlyphAt:effectiveRange:withoutAdditionalLayout:)`](/documentation/UIKit/NSLayoutManager/lineFragmentRect(forGlyphAt:effectiveRange:withoutAdditionalLayout:))

Returns the line fragment rectangle that contains the glyph at the specified glyph index.

[`lineFragmentUsedRect(forGlyphAt:effectiveRange:)`](/documentation/UIKit/NSLayoutManager/lineFragmentUsedRect(forGlyphAt:effectiveRange:))

Returns the usage rectangle for the line fragment and (optionally) returns the entire range of glyphs in that fragment.

[`lineFragmentUsedRect(forGlyphAt:effectiveRange:withoutAdditionalLayout:)`](/documentation/UIKit/NSLayoutManager/lineFragmentUsedRect(forGlyphAt:effectiveRange:withoutAdditionalLayout:))

Returns the usage rectangle for the line fragment and (optionally) returns the entire range of glyphs in that fragment.

[`location(forGlyphAt:)`](/documentation/UIKit/NSLayoutManager/location(forGlyphAt:))

Returns the location for the specified glyph within its line fragment.

[`notShownAttribute(forGlyphAt:)`](/documentation/UIKit/NSLayoutManager/notShownAttribute(forGlyphAt:))

Indicates whether the glyph at the specified index has a visible representation.

[`truncatedGlyphRange(inLineFragmentForGlyphAt:)`](/documentation/UIKit/NSLayoutManager/truncatedGlyphRange(inLineFragmentForGlyphAt:))

Returns the range of truncated glyphs for a line fragment that contains the specified index.

### Performing advanced layout queries

[`boundingRect(forGlyphRange:in:)`](/documentation/UIKit/NSLayoutManager/boundingRect(forGlyphRange:in:))

Returns the bounding rectangle for the specified glyphs in a container.

[`characterIndex(for:in:fractionOfDistanceBetweenInsertionPoints:)`](/documentation/UIKit/NSLayoutManager/characterIndex(for:in:fractionOfDistanceBetweenInsertionPoints:))

Returns the index of the character that lies beneath the specified point using the specified container’s coordinate system.

[`characterRange(forGlyphRange:actualGlyphRange:)`](/documentation/UIKit/NSLayoutManager/characterRange(forGlyphRange:actualGlyphRange:))

Returns the range of characters that correspond to the glyphs in the specified glyph range.

[`enumerateEnclosingRects(forGlyphRange:withinSelectedGlyphRange:in:using:)`](/documentation/UIKit/NSLayoutManager/enumerateEnclosingRects(forGlyphRange:withinSelectedGlyphRange:in:using:))

Enumerates enclosing rectangles for the specified glyph range in a text container.

[`enumerateLineFragments(forGlyphRange:using:)`](/documentation/UIKit/NSLayoutManager/enumerateLineFragments(forGlyphRange:using:))

Enumerates line fragments intersecting with the specified glyph range.

[`fractionOfDistanceThroughGlyph(for:in:)`](/documentation/UIKit/NSLayoutManager/fractionOfDistanceThroughGlyph(for:in:))

Returns the fraction of the distance between the glyph at the specified point and the next glyph.

[`getLineFragmentInsertionPoints(forCharacterAt:alternatePositions:inDisplayOrder:positions:characterIndexes:)`](/documentation/UIKit/NSLayoutManager/getLineFragmentInsertionPoints(forCharacterAt:alternatePositions:inDisplayOrder:positions:characterIndexes:))

Returns insertion points in bulk for a specified line fragment.

[`glyphIndex(for:in:)`](/documentation/UIKit/NSLayoutManager/glyphIndex(for:in:))

Returns the index of the glyph at the specified location in a text container.

[`glyphIndex(for:in:fractionOfDistanceThroughGlyph:)`](/documentation/UIKit/NSLayoutManager/glyphIndex(for:in:fractionOfDistanceThroughGlyph:))

Returns the index of the glyph at the specified point using the container’s coordinate system.

[`glyphRange(forBoundingRect:in:)`](/documentation/UIKit/NSLayoutManager/glyphRange(forBoundingRect:in:))

Returns the smallest contiguous range for glyphs lying wholly or partially within the specified rectangle of the text container.

[`glyphRange(forBoundingRectWithoutAdditionalLayout:in:)`](/documentation/UIKit/NSLayoutManager/glyphRange(forBoundingRectWithoutAdditionalLayout:in:))

Returns the smallest contiguous range for glyphs lying wholly or partially within the specified rectangle of the text container.

[`glyphRange(for:)`](/documentation/UIKit/NSLayoutManager/glyphRange(for:))

Returns the range of glyphs lying within the specified text container.

[`glyphRange(forCharacterRange:actualCharacterRange:)`](/documentation/UIKit/NSLayoutManager/glyphRange(forCharacterRange:actualCharacterRange:))

Returns the range of glyphs that the specified range of characters generates.

[`range(ofNominallySpacedGlyphsContaining:)`](/documentation/UIKit/NSLayoutManager/range(ofNominallySpacedGlyphsContaining:))

Returns the range of displayable glyphs that surround the glyph at the specified index.

### Drawing

[`drawBackground(forGlyphRange:at:)`](/documentation/UIKit/NSLayoutManager/drawBackground(forGlyphRange:at:))

Draws background marks for the specified glyphs, which must lie completely within a single text container.

[`drawGlyphs(forGlyphRange:at:)`](/documentation/UIKit/NSLayoutManager/drawGlyphs(forGlyphRange:at:))

Draws the specified glyphs, which must lie completely within a single text container.

[`drawStrikethrough(forGlyphRange:strikethroughType:baselineOffset:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:)`](/documentation/UIKit/NSLayoutManager/drawStrikethrough(forGlyphRange:strikethroughType:baselineOffset:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:))

Draws a strikethrough for the specified glyphs.

[`drawUnderline(forGlyphRange:underlineType:baselineOffset:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:)`](/documentation/UIKit/NSLayoutManager/drawUnderline(forGlyphRange:underlineType:baselineOffset:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:))

Draws underlining for the glyphs in a specified range.

[`fillBackgroundRectArray(_:count:forCharacterRange:color:)`](/documentation/UIKit/NSLayoutManager/fillBackgroundRectArray(_:count:forCharacterRange:color:))

Fills background rectangles with a color.

[`showCGGlyphs(_:positions:count:font:textMatrix:attributes:in:)`](/documentation/UIKit/NSLayoutManager/showCGGlyphs(_:positions:count:font:textMatrix:attributes:in:))

Renders the glyphs at the specified positions, using the specified attributes.

[`strikethroughGlyphRange(_:strikethroughType:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:)`](/documentation/UIKit/NSLayoutManager/strikethroughGlyphRange(_:strikethroughType:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:))

Calculates and draws strikethrough for the specified glyphs.

[`underlineGlyphRange(_:underlineType:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:)`](/documentation/UIKit/NSLayoutManager/underlineGlyphRange(_:underlineType:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:))

Calculates subranges to underline for the specified glyphs and draws the underlining as appropriate.

### Handling layout for text blocks

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/setLayoutRect(_:for:glyphRange:)>

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/layoutRect(for:glyphRange:)>

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/setBoundsRect(_:for:glyphRange:)>

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/boundsRect(for:glyphRange:)>

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/layoutRect(for:at:effectiveRange:)>

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/boundsRect(for:at:effectiveRange:)>

### Managing attachments

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/defaultAttachmentScaling>

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/showAttachmentCell(_:in:characterIndex:)>

### Handling Rulers

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/rulerAccessoryView(for:paragraphStyle:ruler:enabled:)>

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/rulerMarkers(for:paragraphStyle:ruler:)>

### Managing the responder chain

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/layoutManagerOwnsFirstResponder(in:)>

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/firstTextView>

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/textViewForBeginningOfSelection>

### Managing the typesetter

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/typesetter>

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/typesetterBehavior-swift.property>

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/TypesetterBehavior-swift.enum>

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/defaultLineHeight(for:)>

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/defaultBaselineOffset(for:)>

### Managing temporary attribute support

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/addTemporaryAttributes(_:forCharacterRange:)>

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/addTemporaryAttribute(_:value:forCharacterRange:)>

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/setTemporaryAttributes(_:forCharacterRange:)>

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/removeTemporaryAttribute(_:forCharacterRange:)>

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/temporaryAttribute(_:atCharacterIndex:effectiveRange:)>

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/temporaryAttribute(_:atCharacterIndex:longestEffectiveRange:in:)>

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/temporaryAttributes(atCharacterIndex:effectiveRange:)>

  <doc://com.apple.documentation/documentation/AppKit/NSLayoutManager/temporaryAttributes(atCharacterIndex:longestEffectiveRange:in:)>

### Supporting types

[`NSLayoutManager.TextLayoutOrientation`](/documentation/UIKit/NSLayoutManager/TextLayoutOrientation)

Constants that describe the text layout orientation.

### Deprecated

[Deprecated symbols](/documentation/UIKit/nslayoutmanager-deprecated-symbols)

Review unsupported symbols and their replacements.



---

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)